/* Floating Bar - Frontend Styles */

:root {
    --fb-offset-bottom: 0px;
}

.fb-container {
    position: relative;
}

.fb-bar {
    --fb-z: 9999;
    --fb-margin-x: 0;
    --fb-margin-y: 0;
    --fb-padding-x: 16px;
    --fb-padding-y: 0px;
    --fb-safe-bottom: calc(var(--fb-padding-y) + env(safe-area-inset-bottom, 0));
    --fb-gap: 8px;
    --fb-bg: #fff;
    --fb-font-size: 11px;
    --fb-line-height: 1.3;
    --fb-shadow: 0 1px 42px -10px rgba(85, 111, 175, 0.2);
    --fb-label-display: block;
    --fb-border-width: 0;
    --fb-border-style: solid;
    --fb-border-color: rgba(193, 201, 209, 0.10);
    --fb-border-radius: 0;
    --fb-span-base: 2;
    --fb-item-gap: 6px;
    --fb-item-padding-y: 12px;
    --fb-item-padding-x: 4px;
    --fb-item-radius: 0;
    --fb-item-color: #484C52;
    --fb-item-color-hover: #1e304c;
    --fb-item-color-active: #539DF3;
    --fb-item-bg: transparent;
    --fb-item-bg-hover: rgba(17, 31, 58, 0.03);
    --fb-item-bg-active: transparent;
    --fb-icon-size: 22px;
    --fb-panel-bg: #ffffff;
    --fb-panel-color: #2f3747;
    --fb-panel-border-radius: .875rem;
    --fb-panel-shadow: 0 .75rem 2rem -1.5rem rgba(22, 40, 78, 0.45);
}

.fb-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--fb-z);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--fb-gap);
    padding: var(--fb-padding-y) var(--fb-padding-x);
    padding-bottom: var(--fb-safe-bottom);
    margin: var(--fb-margin-y) var(--fb-margin-x);
    background: var(--fb-bg);
    box-shadow: var(--fb-shadow);
    border: var(--fb-border-width) var(--fb-border-style) var(--fb-border-color);
    border-radius: var(--fb-border-radius);
    font-size: var(--fb-font-size);
    line-height: var(--fb-line-height);
    max-width: 100%;
}

/* Items */
.fb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--fb-item-gap);
    padding: var(--fb-item-padding-y) var(--fb-item-padding-x);
    color: var(--fb-item-color);
    background: var(--fb-item-bg);
    border-radius: var(--fb-item-radius);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.fb-item:hover {
    color: var(--fb-item-color-hover);
    background: var(--fb-item-bg-hover);
}

.fb-item--active {
    color: var(--fb-item-color-active) !important;
    background: var(--fb-item-bg-active) !important;
}

.fb-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--fb-icon-size);
    height: var(--fb-icon-size);
    flex-shrink: 0;
}

.fb-item__icon svg {
    width: var(--fb-icon-size);
    height: var(--fb-icon-size);
}

.fb-item__label {
    display: var(--fb-label-display);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Counter */
.fb-counter {
    position: absolute;
    top: var(--fb-counter-top, -4px);
    left: 50%;
    transform: translateX(6px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--fb-counter-bg, #FB1842);
    color: var(--fb-counter-color, #fff);
    font-size: var(--fb-counter-font-size, 10px);
    font-weight: var(--fb-counter-font-weight, 600);
    line-height: 16px;
    text-align: center;
    border-radius: var(--fb-counter-radius, 10px);
    border: var(--fb-counter-border, 1px solid #fff);
}

/* Panel (overlay) */
.fb-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: calc(var(--fb-z) + 1);
    display: none;
}

.fb-panel.is-open {
    display: block;
}

.fb-panel__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

.fb-panel__content {
    position: relative;
    z-index: 1;
    background: var(--fb-panel-bg);
    color: var(--fb-panel-color);
    border-radius: var(--fb-panel-border-radius) var(--fb-panel-border-radius) 0 0;
    box-shadow: var(--fb-panel-shadow);
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.fb-panel.is-open .fb-panel__content {
    transform: translateY(0);
}

.fb-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.fb-panel__title {
    font-size: 16px;
    font-weight: 600;
}

.fb-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.fb-panel__close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.fb-panel__body {
    padding: 16px 20px 24px;
}

/* Menu in panel */
.fb-panel__menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fb-panel__menu-list li {
    margin: 0;
}

.fb-panel__menu-list a {
    display: block;
    padding: 10px 12px;
    color: var(--fb-panel-color);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s;
    font-size: 14px;
    line-height: 1.4;
}

.fb-panel__menu-list a:hover {
    background: rgba(31, 87, 255, 0.08);
    color: #1f57ff;
}

.fb-panel__menu-list .sub-menu {
    list-style: none;
    margin: 0;
    padding-left: 24px;
}

/* Search form */
.fb-search-form {
    display: flex;
    gap: 8px;
}

.fb-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(33, 48, 77, 0.15);
    border-radius: 10px;
    font-size: 14px;
    background: #f6f8fc;
    color: #2f3747;
    outline: none;
    transition: border-color 0.15s;
}

.fb-search-input:focus {
    border-color: #1f57ff;
}

.fb-search-input::placeholder {
    color: #7a8497;
}

.fb-search-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #1f57ff;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.fb-search-submit:hover {
    background: #1a4adb;
}

/* Scroll to top button */
.fb-scroll-top {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 9998;
    width: 40px;
    height: 40px;
    background: var(--fb-bg, #fff);
    color: var(--fb-item-color, #484C52);
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.fb-scroll-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fb-scroll-top.is-visible {
    display: flex;
}

/* Hide on scroll down */
.fb-bar.is-hidden {
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.fb-bar.is-visible {
    transform: translateY(0);
    transition: transform 0.3s ease;
}

/* Content offset */
body.fb-has-offset {
    padding-bottom: var(--fb-offset-bottom) !important;
}

/* Responsive label hiding */
@media (max-width: 360px) {
    .fb-item__label {
        font-size: 9px;
    }
}

/* SVG icon colors */
.fb-item svg.fb-icon {
    color: inherit;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .fb-bar {
        --fb-bg: #1a1a2e;
        --fb-item-color: #a0a0b0;
        --fb-item-color-hover: #ffffff;
        --fb-item-bg-hover: rgba(255, 255, 255, 0.05);
        --fb-panel-bg: #16213e;
        --fb-panel-color: #e0e0e0;
    }
}
