/* 
   Tax Preparation Services - Premium Design System 
   Focus: Luxury, Professional, Fintech, Accessible
*/

:root {
    /* Color Palette - Premium & Professional */
    --color-primary: #0A192F;
    /* Deep Navy Blue - Trust */
    --color-primary-light: #162a47;
    --color-accent: #10B981;
    /* Emerald Green - Growth/Success */
    --color-accent-hover: #059669;
    --color-gold: #D4AF37;
    /* Subtle Gold for Luxury highlights */

    --color-bg-light: #F8FAFC;
    /* Off-white background */
    --color-surface-light: #FFFFFF;
    --color-text-light: #1E293B;
    /* Slate 800 */
    --color-text-muted-light: #64748B;

    --color-bg-dark: #0F172A;
    /* Slate 900 */
    --color-surface-dark: #1E293B;
    /* Slate 800 */
    --color-text-dark: #F1F5F9;
    /* Slate 100 */
    --color-text-muted-dark: #94A3B8;

    /* Semantic Aliases (Default: Light Mode) */
    --bg-body: var(--color-bg-light);
    --bg-surface: var(--color-surface-light);
    --bg-card: rgba(255, 255, 255, 0.7);
    /* Glassmorphism base */
    --text-main: var(--color-text-light);
    --text-muted: var(--color-text-muted-light);
    --heading-color: var(--color-primary);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);

    /* Typography */
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    /* Spacing */
    --container-padding: 2rem;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: var(--color-bg-dark);
    --bg-surface: var(--color-surface-dark);
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: var(--color-text-dark);
    --text-muted: var(--color-text-muted-dark);
    --heading-color: var(--color-text-dark);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* RTL Support */
/* RTL variables can be added here if needed */

/* Reset & Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--heading-color);
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Utilities */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.flex {
    display: flex;
}

.grid {
    display: grid;
}

.hidden {
    display: none !important;
}

.section-padding {
    padding: 5rem 0;
}

.text-center {
    text-align: center !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-heading);
    border: none;
    outline: none;
    text-transform: capitalize;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    box-shadow: 0 4px 6px rgba(10, 25, 47, 0.2);
}

.btn-primary:hover {
    background-color: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px rgba(10, 25, 47, 0.3);
}

.btn-accent {
    background-color: var(--color-accent);
    color: white;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-accent:hover {
    background-color: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

[data-theme="dark"] .btn-outline {
    border-color: white;
    color: white;
}

.btn-outline:hover {
    background-color: var(--color-primary);
    color: white;
}

[data-theme="dark"] .btn-outline:hover {
    background-color: white;
    color: var(--color-primary);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-lg);
}

/* Utilities */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* RTL Helpers */
[dir="rtl"] .mr-auto {
    margin-right: 0;
    margin-left: auto;
}

[dir="rtl"] .ml-auto {
    margin-left: 0;
    margin-right: auto;
}

/* Mobile Navigation */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: none;
    border: none;
    color: var(--heading-color);
    cursor: pointer;
    z-index: 2001;
    padding: 0.5rem;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-surface);
    z-index: 2000;
    padding: 6rem 2rem 2rem;
    flex-direction: column;
    gap: 1.5rem;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    display: flex;
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .mobile-nav a {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.mobile-nav a.active {
    color: var(--color-accent);
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 1024px) {
    .desktop-nav {
        display: none !important;
    }

    .mobile-nav-toggle {
        display: flex;
    }

    .mobile-hide {
        display: none !important;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2050;
}

.sidebar-overlay.active {
    display: block;
}

/* Topbar & Dashboard Mobile Layout */
@media (max-width: 1023px) {
    .dashboard-layout {
        grid-template-columns: 1fr !important;
        padding-top: 80px;
        display: block !important;
        /* Ensure block layout on mobile */
    }

    .topbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 80px !important;
        padding: 0 1rem !important;
        background: var(--bg-surface) !important;
        border-bottom: 1px solid var(--border-color) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
        z-index: 1000 !important;
        /* Keep below sidebar and overlay */
    }

    .dashboard-content {
        padding: 1.5rem !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

    .page-title {
        font-size: 1.2rem !important;
        font-weight: 700 !important;
        max-width: 150px;
    }

    #sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        font-size: 1.2rem;
        border-radius: var(--radius-md);
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 0 0.5rem !important;
    }

    .topbar .flex {
        gap: 0.25rem !important;
    }

    .page-title {
        font-size: 1rem !important;
        max-width: 90px;
    }

    #sidebar-toggle {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* Global Responsive Adjustments */
@media (max-width: 768px) {
    :root {
        --container-padding: 1rem;
    }

    .section-padding {
        padding: 3rem 0;
    }

    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.75rem !important;
    }

    h3 {
        font-size: 1.5rem !important;
    }

    .container.grid,
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        width: 100% !important;
    }

    /* Better grid for tablets (min 601px to 1024px) */
    @media (min-width: 601px) {
        .widget-grid {
            grid-template-columns: repeat(2, 1fr) !important;
        }

        /* Ensure dashboard content grid uses 1 column and full width on tablet */
        .grid[style*="grid-template-columns: repeat(auto-fit, minmax(400px, 1fr))"],
        .grid {
            grid-template-columns: 1fr !important;
            width: 100% !important;
            max-width: 100% !important;
        }

        .status-card {
            width: 100% !important;
            max-width: 100% !important;
        }

        main {
            width: 100% !important;
        }
    }

    /* Mobile Table Stacking (under 600px) */
    @media (max-width: 600px) {

        .table-responsive table,
        .table-responsive thead,
        .table-responsive tbody,
        .table-responsive th,
        .table-responsive td,
        .table-responsive tr {
            display: block;
        }

        .table-responsive thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }

        .table-responsive tr {
            border: 1px solid var(--border-color);
            margin-bottom: 1rem;
            border-radius: var(--radius-md);
            padding: 0.5rem;
        }

        .table-responsive td {
            border: none;
            position: relative;
            padding-left: 50% !important;
            text-align: left !important;
            border-bottom: 1px solid var(--border-color);
        }

        .table-responsive td:last-child {
            border-bottom: none;
        }

        .table-responsive td:before {
            position: absolute;
            top: 1rem;
            left: 1rem;
            width: 45%;
            padding-right: 10px;
            white-space: nowrap;
            font-weight: 600;
            color: var(--text-muted);
        }

        .table-responsive td:nth-of-type(1):before {
            content: "Action";
        }

        .table-responsive td:nth-of-type(2):before {
            content: "Date";
        }

        .table-responsive td:nth-of-type(3):before {
            content: "Status";
        }
    }

    /* Override inline grid styles if they cause overflow */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard & Profile Specific Fixes */
    .topbar {
        padding: 0 1rem !important;
    }

    .dashboard-content {
        padding: 0.75rem !important;
    }

    .settings-grid,
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Auth pages padding */
    body {
        padding: 1rem !important;
    }

    .auth-content {
        padding: 2rem 1rem !important;
    }

    /* Robust Table Scroll Fix */
    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        /* Enable horizontal scroll */
        display: block !important;
        -webkit-overflow-scrolling: touch;
        margin-top: 1rem;
        border-radius: var(--radius-md);
    }

    .table-responsive table {
        width: 100% !important;
        min-width: 600px !important;
        /* Increased for better column spacing */
        table-layout: auto !important;
        /* Allow columns to fit content */
        border-collapse: collapse !important;
    }

    .table-responsive th,
    .table-responsive td {
        white-space: normal !important;
        /* Allow wrapping if needed */
        word-wrap: break-word;
        padding: 1rem 0.75rem !important;
        /* Generous padding for separation */
        text-align: left !important;
    }

    /* Status cards full width */
    .widget-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem !important;
    }

    .hero-btns {
        flex-direction: column;
    }

    .hero-btns .btn {
        width: 100%;
    }
}

/* Sidebar Styling - Global Consistency (Light Theme) */
.sidebar {
    background: var(--bg-surface) !important;
    /* Adapt to theme background */
    color: var(--text-main) !important;
    border-right: 1px solid var(--border-color) !important;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    /* Increased left padding for mobile logo */
    transition: transform 0.3s ease;
    z-index: 2100;
    /* Ensure high enough for mobile */
}

@media (max-width: 1023px) {
    .sidebar {
        display: none;
        /* Force hide by default on mobile */
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        display: flex !important;
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
    }

    .sidebar-close {
        display: block !important;
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-muted);
    }
}

.sidebar .logo a {
    color: var(--heading-color) !important;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted) !important;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    flex-shrink: 0;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(16, 185, 129, 0.1) !important;
    /* Subtle accent background */
    color: var(--color-accent) !important;
    box-shadow: none;
}

.nav-item.active {
    background: var(--color-accent) !important;
    color: white !important;
}

.user-profile {
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    margin-top: auto;
}

.user-profile .flex {
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.user-profile img {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.user-profile .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.user-profile .user-plan {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar .btn-outline {
    width: 100%;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0.6rem;
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
    white-space: nowrap;
}

.sidebar .btn-outline:hover {
    background-color: var(--color-primary) !important;
    color: white !important;
}