/**
 * OptimaDrywall Flow — Application tab bar (ERP module tabs)
 */

.app-main-area {
    padding-top: 0 !important;
}

.app-tab-bar {
    position: relative;
    z-index: 102;
    background: #eef1f4;
    border-bottom: none;
    margin: 0 -1rem 0;
    padding: 0.5rem 0.35rem 0.35rem;
}

.app-tab-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 44px;
}

.app-tab-list-viewport {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.app-tab-list-viewport::-webkit-scrollbar {
    display: none;
}

.app-tab-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 36px;
    padding: 0 0.15rem;
    width: max-content;
}

.app-tab-scroll-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid #d1d9e0;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-tab-scroll-btn:hover {
    background: #f8fafc;
    color: #023f80;
}

.app-tab-scroll-btn[hidden] {
    display: none !important;
}

.app-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 220px;
    min-width: 0;
    padding: 0.45rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #023f80;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-tab:hover {
    border-color: #cbd5e1;
}

.app-tab.active {
    border-color: #20c997;
    box-shadow: 0 1px 4px rgba(32, 201, 151, 0.18);
    font-weight: 700;
}

.app-tab.pinned {
    cursor: default;
}

.app-tab.pinned .app-tab-close {
    display: none;
}

.app-tab.pinned[draggable="false"] {
    -webkit-user-drag: none;
    user-drag: none;
}

.app-tab.dragging {
    opacity: 0.5;
}

.app-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    padding: 0;
    border: none;
    border-radius: 0.2rem;
    background: transparent;
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.app-tab-close:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.app-tab.dirty .app-tab-label::after {
    content: ' •';
    color: #f59e0b;
}

.app-tab-panels {
    position: relative;
    flex: 1;
    background: #fff;
    min-height: 0;
}

.app-tab-panel {
    display: none !important;
    padding-top: 1rem;
    animation: app-tab-fade-in 0.12s ease;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
    pointer-events: none;
    visibility: hidden;
}

.app-tab-panel.active {
    pointer-events: auto;
    visibility: visible;
}

body:not(.app-shell-active) .app-tab-panel.active {
    display: block !important;
}

@keyframes app-tab-fade-in {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.app-tab-panel .tab-messages {
    margin-bottom: 1rem;
}

.app-tab-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #64748b;
    gap: 0.5rem;
}

.app-tab-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

@media (max-width: 768px) {
    .app-tab {
        max-width: 150px;
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .app-tab-bar {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-tab-panel {
        animation: none;
    }

    .app-tab-list-viewport {
        scroll-behavior: auto;
    }
}
