/* ============================================
   6D AutoTools — Main Stylesheet
   ============================================ */

:root {
    --primary:      #004C99; /* ExBi Blue */
    --primary-dark: #003a75;
    --accent:       #FDCF00; /* ExBi Yellow */
    --sidebar-bg:   #0A1628;
    --sidebar-text: #A8B9CC;
    --body-bg:      #F0F4F8;
}

body {
    background-color: var(--body-bg);
    font-family: Arial, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar — always-visible icon rail on desktop --- */
.sidebar {
    width: 64px;
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 1050;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.sidebar.sidebar-expanded {
    width: 260px;
}
.sidebar:not(.sidebar-expanded):not(.open) .nav-group-body {
    max-height: 0 !important;
    overflow: hidden;
}
.sidebar:not(.sidebar-expanded):not(.open) .nav-item,
.sidebar:not(.sidebar-expanded):not(.open) .nav-group-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    border-left-color: transparent;
}
.sidebar:not(.sidebar-expanded):not(.open) .nav-item.active {
    border-left-color: transparent;
    background: rgba(0, 76, 153, 0.25);
}
.sidebar:not(.sidebar-expanded):not(.open) .nav-item span,
.sidebar:not(.sidebar-expanded):not(.open) .nav-group-toggle-inner span,
.sidebar:not(.sidebar-expanded):not(.open) .nav-group-chevron {
    display: none;
}
.sidebar:not(.sidebar-expanded):not(.open) .sidebar-nav {
    overflow-y: hidden !important;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
    display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    display: block;
}

/* Hamburger toggle — hidden on desktop, shown on mobile */
.sidebar-toggle {
    display: none !important;
}
@media (max-width: 991px) {
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        gap: 6px;
        background: #EBF0FF;
        border: 1px solid var(--primary-dark);
        padding: 6px 10px;
        cursor: pointer;
        flex-shrink: 0;
        border-radius: 6px;
    }
    .sidebar-toggle:hover { background: #DCE6FF; }
}
.sidebar-ham {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--primary-dark);
    border-radius: 2px;
    box-shadow: 0 6px 0 var(--primary-dark), 0 12px 0 var(--primary-dark);
    margin-bottom: 12px;
    flex-shrink: 0;
}
.sidebar-toggle-label {
    display: inline-flex;
    align-items: center;
    padding-left: 10px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    margin-left: 4px;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 16px;
    white-space: nowrap;
}

/* --- Sidebar brand --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    gap: 12px;
    white-space: nowrap;
    overflow: hidden;
    min-height: 64px;
}
.brand-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}
.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}
.brand-name {
    color: white;
    font-weight: 700;
    font-size: 15px;
}
.brand-sub {
    color: var(--sidebar-text);
    font-size: 11px;
}
.sidebar-pin-btn {
    display: none;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    flex-shrink: 0;
    margin-left: auto;
    line-height: 1;
}
.sidebar.sidebar-expanded .sidebar-pin-btn {
    display: inline-flex;
    align-items: center;
}
.sidebar-pin-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.sidebar-pin-btn.pinned { color: var(--accent); }

/* --- Sidebar navigation --- */
.sidebar-nav {
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    height: calc(100vh - 64px);
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 10px 20px;
    cursor: pointer;
    user-select: none;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
}
.nav-group-toggle:hover { background: rgba(255, 255, 255, 0.04); }
.nav-group-toggle.open { border-left-color: rgba(0, 76, 153, 0.6); }
.nav-group-toggle-inner { display: flex; align-items: center; gap: 10px; }
.nav-group-icon {
    font-size: 15px;
    width: 20px;
    min-width: 20px;
    text-align: center;
    color: #4A6080;
    transition: color 0.2s;
    flex-shrink: 0;
}
.nav-group-toggle.open .nav-group-icon { color: var(--accent); }
.nav-group-toggle-inner span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #4A6080;
    transition: color 0.2s;
}
.nav-group-toggle.open .nav-group-toggle-inner span { color: var(--accent); }
.nav-group-chevron {
    font-size: 11px;
    color: #4A6080;
    transition: transform 0.25s ease, color 0.2s;
}
.nav-group-chevron.rotated { transform: rotate(90deg); color: var(--accent); }

.nav-group-body {
    overflow: hidden;
    max-height: 1200px;
    transition: max-height 0.3s ease;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item-child { padding-left: 28px; font-size: 13px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: white; border-left-color: var(--primary); }
.nav-item.active { background: rgba(0, 76, 153, 0.3); color: white; border-left-color: var(--accent); }
.nav-item i { font-size: 18px; width: 20px; min-width: 20px; text-align: center; flex-shrink: 0; }
.nav-item-child i { font-size: 15px; }

.nav-logout {
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 12px;
}

/* --- Main content area --- */
.main-content {
    margin-left: 64px;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
html.sb-pinned .main-content { margin-left: 260px; }
@media (max-width: 991px) {
    html.sb-pinned .main-content { margin-left: 0 !important; }
}

/* --- Topbar --- */
.topbar {
    background: white;
    padding: 12px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 999;
}
.topbar-title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: #1A2B4A;
    margin: 0;
}
.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4A5568;
    font-size: 14px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.topbar-user-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 8px;
    color: #4A5568;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.topbar-user-toggle:hover,
.topbar-user-toggle[aria-expanded="true"] {
    background: #F0F4F8;
}
.topbar-user-chevron {
    font-size: 11px;
    color: #8A98AC;
    transition: transform 0.2s;
}
.topbar-user-toggle[aria-expanded="true"] .topbar-user-chevron {
    transform: rotate(180deg);
}

/* --- Page content --- */
.page-content {
    padding: 25px;
    flex: 1;
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}
.card-header {
    background: white;
    border-bottom: 1px solid #E8EDF2;
    border-radius: 12px 12px 0 0 !important;
    padding: 15px 20px;
    font-weight: 600;
    color: #1A2B4A;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* --- Mobile: sidebar hidden by default, hamburger opens full sidebar --- */
@media (max-width: 991px) {
    .sidebar {
        width: 260px;
        transform: translateX(-260px);
        transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; transition: none; }
}
@media (max-width: 768px) {
    .topbar { padding: 10px 14px; }
}

/* --- Processing overlay (shown while an upload form is submitting) --- */
.processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}
.processing-overlay.active { display: flex; }
.processing-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: processing-spin 0.8s linear infinite;
}
@keyframes processing-spin { to { transform: rotate(360deg); } }
.processing-text {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    padding: 0 20px;
}
.processing-subtext {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    text-align: center;
    padding: 0 20px;
    max-width: 320px;
}
