/* ==========================================================================
   ACUITY ACCOUNTING - MASTER STYLESHEET
   Merged with User Submenu & Grid Styles
   ========================================================================== */

:root {
    /* Your Original Colors */
    --sidebar-bg: #1e293b;
    --sidebar-text: #f8fafc;
    --accent-blue: #3b82f6;
    --bg-light: #f1f5f9;
    --border-color: #e2e8f0;
    --text-dark: #0f172a;

    /* Colors */
    --primary-blue: #00008b;
    --light-blue: #3b82f6;
    --accent-blue: #dbeafe;
    --bg-grey: #f8fafc;
    --text-muted: #64748b;
    --border-grey: #e2e8f0;
    --border-yellow: #ffff00;
    --white: #ffffff;
    --success-green: #10b981;
    --danger-red: #ef4444;

    /* 🔧 Dashboard aliases */
    --white: #ffffff;
    --radius: 12px;
    --border-grey: #e2e8f0;
    --text-muted: #64748b;
    --primary-blue: var(--accent-blue);
    
    /* Layout Sizes */
    --top-bar-height: 60px;
    --sidebar-width: 260px;
}

/* --- 1. BASE RESET --- */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent body scroll, use ID containers instead */
}

/* --- 2. THE THREE-ID SYSTEM LAYOUT --- */

/* ID 1: TOP BAR (Full Width) */
#app-top-bar {
    height: var(--top-bar-height);
    background-color: var(--sidebar-bg); /* Matching your sidebar color */
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

/* Wrapper for Sidebar + Main */
.main-layout-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ID 2: SIDEBAR */
#app-sidebar {
    width: var(--sidebar-width);
    background-color: #27354a; /* Slightly lighter than top bar for contrast */
    color: var(--sidebar-text);
    overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,0.1);
}

/* ID 3: MAIN CONTENT AREA */
#app-main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* --- 3. TOP BAR COMPONENTS --- */
.top-left { display: flex; align-items: center; gap: 1rem; }

/* Update these in app-style.css */
.logo-box { 
    height: 40px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: transform 0.2s;
}

.logo-box:hover {
    transform: scale(1.05); /* Slight pop when hovering */
}

.logo-box img { 
    height: 100%; 
    width: auto; 
    object-fit: contain; 
}

.company-name-display {
    font-weight: 500;
    font-size: 0.95rem;
    color: #cbd5e1; /* Slightly muted so the logo pops more */
}


.divider { color: #475569; font-weight: 300; font-size: 1.2rem; }

.company-switcher-wrapper {
    position: relative;
}

.company-switcher-select {
    background: #334155;
    color: #f8fafc;
    border: 1px solid #475569;
    padding: 6px 32px 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    min-width: 160px;
    transition: background 0.2s, border-color 0.2s;
}

.company-switcher-select:hover {
    background: #475569;
    border-color: #64748b;
}

.company-switcher-select:focus {
    border-color: var(--accent-blue);
    background: #334155;
}

.company-switcher-wrapper::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.search-bar {
    width: 65ch; /* As per request */
    background: #ffffff;
    border: 1px solid #475569;
    color: black;
    padding: 8px 16px;
    border-radius: 6px;
    outline: none;
}
.search-bar:focus { border-color: var(--accent-blue); }

.top-right { display: flex; align-items: center; gap: 1.5rem; }

/* Updated .nav-link in app-style.css */
.nav-link { 
    display: flex;          /* Changed from block to flex */
    align-items: center;    /* Vertically centers icon and text */
    gap: 12px;              /* Space between icon and text */
    padding: 0.75rem 1rem; 
    cursor: pointer; 
    border-radius: 6px; 
    margin-bottom: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background 0.2s;
}

.nav-link i {
    width: 20px;            /* Ensures icons don't push text unevenly */
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.8;           /* Slightly subtle icons look cleaner */
}

/* 1. Force white text and high opacity when active */
.nav-link.active { 
    background-color: var(--accent-blue) !important; 
    color: blue; !important; 
    font-weight: 700; /* Bold makes it much easier to read */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Subtle lift to separate from background */
}

/* 2. Ensure the icon glows white too */
.nav-link.active i { 
    opacity: 1 !important; 
    color: #ffffff !important;
}

/* 3. Add a slight left-border "indicator" for extra clarity */
.nav-link.active {
    border-left: 4px solid #ffffff;
    padding-left: calc(1rem - 4px); /* Adjust padding so text doesn't shift */
}

.nav-link:hover { background-color: #334155; }
/*.nav-link.active { background-color: var(--accent-blue); color: #ffffff; }
.nav-link.active i { opacity: 1; }*/

/* --- 4. NAVIGATION (Sidebar Links) --- */

#app-sidebar ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#app-sidebar li {
    list-style: none;
}

/*nav ul { list-style: none; padding: 1rem; margin: 0; }
.nav-link { 
    display: block;
    padding: 0.75rem 1rem; 
    cursor: pointer; 
    border-radius: 6px; 
    margin-bottom: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background 0.2s;
}
.nav-link:hover { background-color: #334155; }
.nav-link.active { background-color: var(--accent-blue); color: white; }*/

/* --- 5. SUBMENU & GRID STYLES (Your Original Logic) --- */
.submenu-header { 
    margin-bottom: 2rem; 
    border-bottom: 2px solid var(--accent-blue); 
    padding-bottom: 1rem; 
}
.submenu-header h2 { margin: 0; color: var(--text-dark); }
.submenu-header p { margin: 5px 0 0 0; color: #64748b; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.menu-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.menu-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}
.menu-card h3 { margin-top: 0; color: #1e293b; font-size: 1.1rem; }
.menu-card p { font-size: 0.9rem; color: #475569; line-height: 1.4; }

/* --- 6. UTILITY CLASSES --- */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: var(--accent-blue);
    color: white;
    font-weight: 600;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    border: 1px solid #bbf7d0;
}
/* Feedback Containers */
.settings-container {
    max-width: 800px;
    margin: 20px auto;
}

.alert-card {
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid;
    margin-bottom: 20px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Reusable Buttons for HTMX Fragments */
.btn-back {
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-back:hover {
    background: #f8fafc;
}

.btn-action {
    margin-top: 15px;
    padding: 10px 24px;
    background: #166534;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.org-form-container label {
        display: block;
        font-weight: 600;
        margin-bottom: 8px;
        color: #334155;
        font-size: 0.9rem;
    }
    .org-form-container .form-control {
        width: 100%;
        padding: 11px 13px;
        border: 1px solid #cbd5e1;
        border-radius: 6px;
        font-size: 1rem;
        transition: border-color 0.2s, box-shadow 0.2s;
        box-sizing: border-box;
        color: #1e293b;
    }
    .org-form-container .form-control:focus {
        outline: none;
        border-color: #2563eb;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }
    .org-form-container .form-control.readonly {
        background-color: #f8fafc;
        color: #64748b;
        cursor: not-allowed;
        border-color: #e2e8f0;
    }
    .org-form-container textarea.form-control {
        resize: vertical;
        min-height: 90px;
        font-family: inherit;
    }
    .org-form-container .btn-primary {
        background-color: #2563eb;
        color: white;
        border: none;
        padding: 12px 28px;
        border-radius: 6px;
        font-weight: 600;
        cursor: pointer;
        font-size: 1rem;
        transition: background-color 0.2s;
    }
    .org-form-container .btn-primary:hover {
        background-color: #1d4ed8;
    }
    #form-status {
        margin-bottom: 20px;
    }

/* Tax Module Specific Styles */
.tax-table-container {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tax-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tax-badge-active { background: #dcfce7; color: #166534; }
.tax-badge-inactive { background: #fee2e2; color: #991b1b; }

.tax-rate-display {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    color: #1e293b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}
/* AP Module Specific Styles */
.ap-container { padding: 25px; }
.ap-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }

/* KPI Section */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 25px; }
.kpi-card { background: #f8fafc; padding: 20px; border-radius: 12px; border: 1px solid #e2e8f0; }
.kpi-label { color: #64748b; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; margin-bottom: 5px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: #1e293b; }

/* Filter Bar */
.filter-panel { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; background: #f1f5f9; padding: 20px; border-radius: 10px; margin-bottom: 25px; }
.filter-group { display: flex; flex-direction: column; gap: 5px; flex-grow: 1; }
.filter-label { font-size: 0.75rem; font-weight: 700; color: #475569; }
.filter-input { padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; height: 42px; }
.multi-select { min-height: 100px; padding: 8px; }

/* Table Styling - "Comfortable" */
.acuity-table-container { background: white; border-radius: 12px; border: 1px solid #e2e8f0; overflow: hidden; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); }
.acuity-table { width: 100%; border-collapse: collapse; text-align: left; }
.acuity-table th { background: #f8fafc; padding: 18px 20px; color: #64748b; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; border-bottom: 1px solid #e2e8f0; }
.acuity-table td { padding: 18px 20px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.acuity-table tr:hover { background-color: #f8fafc; transition: 0.2s; }
/* Report Drill-down Links */
/* Report drill-down links */
td .report-drill-link {
    color: #1a73e8; /* professional ERP blue */
    font-weight: 600;
    cursor: pointer;
}

td .report-drill-link:hover {
    text-decoration: underline;
}
/* P&L drill-down links */
a.pl-drill-link {
    color: #0d6efd !important;   /* bootstrap primary blue */
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

a.pl-drill-link:hover {
    text-decoration: underline;
}



/* Status Badges */
.badge { padding: 6px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef9c3; color: #854d0e; }
.badge-void { background: #f1f5f9; color: #64748b; }

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-grey);
}

.card h3 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }
.card .value { font-size:1.8rem; font-weight: 600; color: var(--primary-blue); margin-top: 5px; }


/* Printing CSS */

@media print {
    /* 1. Hide UI elements that don't belong on paper */
    #sidebar, 
    .submenu-header .btn-back, 
    .submenu-header .report-actions .btn:not(.print-only), 
    form, 
    nav, 
    .htmx-indicator {
        display: none !important;
    }

    /* 2. Reset layout for the page */
    body {
        background: #fff !important;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact; /* Keeps your brand colors if desired */
    }

    #app-main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        position: absolute;
        left: 0;
        top: 0;
    }

    /* 3. Professional Table Styling for Paper */
    .acuity-table {
        width: 100% !important;
        border-collapse: collapse;
        margin-top: 20px;
    }

    .acuity-table th {
        background-color: #f1f5f9 !important; /* Light grey header */
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
    }

    .acuity-table td {
        border-bottom: 1px solid #e2e8f0 !important;
        font-size: 10pt;
    }

    /* 4. Page Break logic */
    tr {
        page-break-inside: avoid;
    }
}

/* ============================================
   Remove Number Input Spinners (Accounting UI)
   ============================================ */

/* Chrome, Safari, Edge */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type="number"] {
    -moz-appearance: textfield;
}

/* Prevent scroll wheel changing values */
input[type="number"] {
    pointer-events: auto;
}
