/* ==========================================================
   VibronTax Sacred App Shell Layout
   A calming, clarity-focused interface for financial management
   ========================================================== */

/* ---------- CSS Variables for Layout ---------- */
:root {
    /* Sacred dark theme */
    --nav-bg: linear-gradient(180deg, #0f1420 0%, #0a0d14 100%);
    --nav-text: #c8cdd8;
    --nav-text-active: #60a5fa;
    --nav-border: rgba(255, 255, 255, 0.06);
    --header-bg: rgba(18, 22, 32, 0.85);
    --header-border: rgba(255, 255, 255, 0.06);
    --body-bg: #0b0e14;
    --right-bg: rgba(15, 19, 28, 0.9);
    --text: #eef0f5;
    --text-muted: #c8cede; /* Better contrast for secondary text */
    --text-primary: #e0e4ed;
    --text-secondary: #c4c9d8;
    --vt-muted: #c8cede;
    --brand-gradient: linear-gradient(135deg, #2563eb, #3b82f6);

    /* Professional accent colors */
    --sacred-primary: #2563eb;
    --sacred-secondary: #3b82f6;
    --sacred-accent: #1d4ed8;
    --sacred-warm: #f59e0b;

    /* Z-index layering system */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed-nav: 500;
    --z-tooltip: 900;
    --z-floating: 1000;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1200;
    --z-keyboard-help: 1400;
    --z-onboarding: 1500;
    --z-ai-panel: 1600;
    --z-toast: 1650;
    --z-modal-high: 1700;
    --z-skip-link: 9999;
}

/* Dark mode (default) */
.dark {
    --nav-bg: #0f1419;
    --nav-text: #94a3b8;
    --nav-text-active: #60a5fa;
    --header-bg: rgba(15, 20, 25, 0.98);
    --header-border: rgba(255, 255, 255, 0.06);
    --body-bg: #0f1419;
    --right-bg: rgba(15, 20, 25, 0.98);
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --text-primary: #e5e7eb;
    --text-secondary: #94a3b8;
    --text-strong: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.02);
    --card-border: rgba(255, 255, 255, 0.08);
    --control-bg: rgba(255, 255, 255, 0.06);
    --control-border: rgba(255, 255, 255, 0.12);
    --control-text: #ffffff;
    --ghost-bg: rgba(255, 255, 255, 0.04);
    --ghost-text: #e5e7eb;
    --ghost-hover-bg: rgba(255, 255, 255, 0.06);
}

/* Light theme override */
.light,
.sacred-light {
    --nav-bg: linear-gradient(180deg, #1a2035 0%, #141828 100%);
    --nav-text: #c8d0e0;
    --header-bg: #ffffff;
    --header-border: rgba(0, 0, 0, 0.08);
    --body-bg: #f4f6fa;
    --right-bg: #fafbfc;
    --text: #1a1f2e;
    --text-muted: #4a5568;
    /* Component text colors for light mode */
    --text-primary: #1a1f2e;
    --text-secondary: #4a5568;
    --text-strong: #0f1422;
    --vt-muted: #4a5568;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.08);
    --control-bg: rgba(0, 0, 0, 0.04);
    --control-border: rgba(0, 0, 0, 0.15);
    --control-text: #1a1f2e;
    --ghost-bg: rgba(0, 0, 0, 0.04);
    --ghost-text: #374151;
    --ghost-hover-bg: rgba(0, 0, 0, 0.08);
}

/* ---------- App Shell Grid ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr 340px;
    grid-template-rows: 100vh;
    color: var(--text);
    background: var(--body-bg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    position: relative;
}

/* Without right sidebar - FloatingAI takes over */
.app-shell.app-shell-no-right {
    grid-template-columns: 260px 1fr;
}

/* Disable background orbs for professional look */
.app-shell::before,
.app-shell::after {
    display: none;
}

/* ---------- Navigation Sidebar ---------- */
.app-nav {
    background: var(--nav-bg);
    color: var(--nav-text);
    overflow: hidden;
    padding: 1rem 0.75rem;
    border-right: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

/* Remove glow line for professional look */
.app-nav::after {
    display: none;
}

.app-nav .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.625rem;
    color: var(--text, #e5e7eb);
    background: rgba(37, 99, 235, 0.08);
    border-radius: 4px;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.app-nav .brand::before {
    content: '\2736';
    font-size: 1.25rem;
    color: #2563eb;
}

/* ---------- Nav Menu Styles ---------- */
.vt-nav {
    flex: 1;
    padding: 0;
}

.vt-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.vt-nav a {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 450;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.vt-nav a:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--text, #e5e7eb);
}

.vt-nav a.active,
.vt-nav a:focus-visible {
    background: rgba(37, 99, 235, 0.12);
    color: var(--nav-text-active);
}

.vt-nav a:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ---------- Main Content Area ---------- */
.app-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--body-bg);
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1.25rem;
    border-bottom: 1px solid var(--header-border);
    background: var(--header-bg);
    min-height: 56px;
    position: relative;
    z-index: 10;
}

/* Remove glow line for professional look */
.app-header::after {
    display: none;
}

.app-header .btn {
    font-family: inherit;
}

/* ---------- Body Content ---------- */
.app-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    background: transparent;
    position: relative;
    z-index: 1;
}

/* Disable floating orb for professional look */
.app-body::before {
    display: none;
}

/* Custom scrollbar for app-body */
.app-body::-webkit-scrollbar {
    width: 6px;
}

.app-body::-webkit-scrollbar-track {
    background: transparent;
}

.app-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.app-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Light mode scrollbar */
.light .app-body::-webkit-scrollbar-thumb,
.sacred-light .app-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

.light .app-body::-webkit-scrollbar-thumb:hover,
.sacred-light .app-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ---------- Right Panel (AI Chat) ---------- */
.app-right {
    border-left: 1px solid var(--header-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--right-bg);
    padding: 1rem;
    position: relative;
    z-index: 10;
}

/* Remove glow line for professional look */
.app-right::before {
    display: none;
}

.right-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 4px;
    border: 1px solid rgba(37, 99, 235, 0.15);
    color: var(--text);
}

.right-panel-header::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

/* ---------- Entity Selector ---------- */
.entity-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.entity-selector label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.entity-selector select {
    padding: 0.375rem 0.625rem;
    font-family: inherit;
    font-size: 0.875rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.entity-selector select:hover {
    border-color: rgba(37, 99, 235, 0.4);
}

.entity-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* ---------- Cards in Main Body ---------- */
.card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.card-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-weight: 500;
}

/* ---------- Tables ---------- */
.table {
    color: var(--text);
}

.table th {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.table td {
    border-bottom-color: rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

/* ---------- Buttons Override ---------- */
.btn-primary {
    background: #2563eb;
    border: none;
    color: #ffffff;
    font-weight: 500;
    transition: background-color 0.15s ease;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-outline-primary {
    color: #3b82f6;
    border-color: #3b82f6;
}

.btn-outline-primary:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
    color: #2563eb;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ---------- Form Controls ---------- */
.form-control,
.form-select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    color: var(--text);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

.badge.bg-success {
    background: rgba(34, 201, 151, 0.15) !important;
    color: #22c997;
}

.badge.bg-warning {
    background: rgba(245, 166, 35, 0.15) !important;
    color: #f5a623;
}

.badge.bg-danger {
    background: rgba(239, 95, 95, 0.15) !important;
    color: #ef5f5f;
}

.badge.bg-info {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa;
}

.badge.bg-primary {
    background: rgba(37, 99, 235, 0.15) !important;
    color: #60a5fa;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: 4px;
    border: none;
}

.alert-success {
    background: rgba(34, 201, 151, 0.1);
    color: #22c997;
    border: 1px solid rgba(34, 201, 151, 0.2);
}

.alert-danger {
    background: rgba(239, 95, 95, 0.1);
    color: #ef5f5f;
    border: 1px solid rgba(239, 95, 95, 0.2);
}

.alert-warning {
    background: rgba(245, 166, 35, 0.1);
    color: #f5a623;
    border: 1px solid rgba(245, 166, 35, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ---------- Modal Overrides ---------- */
.modal-content {
    background: rgba(18, 22, 32, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.modal-footer {
    border-top-color: rgba(255, 255, 255, 0.06);
}

.btn-close {
    filter: invert(1) brightness(0.8);
}

/* ---------- Responsive Layout ---------- */
@media (max-width: 1400px) {
    .app-shell {
        grid-template-columns: 240px 1fr 300px;
    }
}

@media (max-width: 1200px) {
    .app-shell {
        grid-template-columns: 220px 1fr;
    }
    .app-right {
        display: none;
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .app-nav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }

    /* Show nav when mobile-nav-open is active */
    .app-shell.mobile-nav-open .app-nav {
        display: flex;
        transform: translateX(0);
    }

    /* Show hamburger button on mobile */
    .mobile-nav-toggle {
        display: flex;
    }

    /* Mobile overlay for closing nav */
    .mobile-nav-overlay {
        display: block;
    }
}

/* ---------- Mobile Navigation Hamburger Button ---------- */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.mobile-nav-toggle:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
}

.mobile-nav-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 20px;
    height: 16px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: #3b82f6;
    border-radius: 1px;
    transition: all 0.2s ease;
}

/* Animated hamburger to X transition */
.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile overlay backdrop */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Light theme adjustments for mobile nav */
.light .mobile-nav-toggle {
    background: rgba(74, 85, 104, 0.1);
    border-color: rgba(74, 85, 104, 0.3);
}

.light .mobile-nav-toggle:hover {
    background: rgba(74, 85, 104, 0.2);
}

.light .hamburger-icon span {
    background: #4a5568;
}

/* ---------- Responsive Header ---------- */
@media (max-width: 768px) {
    .app-header {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .header-context {
        min-width: 0;
        flex: 1 1 auto;
    }

    .header-context .entity-selector select {
        max-width: 140px;
        font-size: 0.85rem;
    }

    .header-actions {
        gap: 0.25rem !important;
    }

    /* Hide less critical header items on small screens */
    .header-actions .checkin-trigger,
    .header-actions .help-trigger {
        display: none;
    }
}

@media (max-width: 480px) {
    .app-header {
        gap: 0.35rem;
        padding: 0.5rem;
    }

    .header-context .entity-selector select {
        max-width: 100px;
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    /* Hide TaxProgressMini on very small screens */
    .header-actions .tax-progress-mini {
        display: none;
    }

    /* Keep mobile nav toggle at 44px for WCAG 2.5.5 touch target compliance */
    .mobile-nav-toggle {
        width: 44px;
        height: 44px;
        padding: 8px;
    }
}

/* ---------- Utility Classes ---------- */
.text-sacred-primary { color: #2563eb !important; }
.text-sacred-secondary { color: #3b82f6 !important; }
.text-sacred-accent { color: #1d4ed8 !important; }
.text-sacred-warm { color: #f59e0b !important; }

.bg-sacred-glass {
    background: rgba(255, 255, 255, 0.04);
}

/* ---------- Page Title Styling ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 1rem;
}

/* ---------- Light Theme Overrides ---------- */
.light .card {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
}

.light .table th {
    color: #4a5568; /* Improved contrast - ~7:1 on white */
}

.light .table td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.light .form-control,
.light .form-select {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.12);
    color: #1a1f2e;
}

.light .modal-content {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}

.light .btn-close {
    filter: none;
}

.light .entity-selector select {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.12);
    color: #1a1f2e;
}

/* ==============================================
   Skeleton Loader Animations
   ============================================== */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.sacred-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.sacred-skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.sacred-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sacred-skeleton-card {
    min-height: 120px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Light theme skeleton styles */
.light .sacred-skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.06) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.06) 100%
    );
    background-size: 200% 100%;
}

.light .sacred-skeleton-card {
    background: linear-gradient(
        90deg,
        rgba(26, 32, 53, 0.05) 0%,
        rgba(26, 32, 53, 0.08) 50%,
        rgba(26, 32, 53, 0.05) 100%
    );
    background-size: 200% 100%;
}
