/* assets/css/style.css */
/* Modern Reset & Variables */
:root {
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    /* Emerald 500 */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-card: #ffffff;
    --text-main: #111827;
    /* Gray 900 */
    --text-muted: #6b7280;
    /* Gray 500 */
    --border-color: #e5e7eb;
    /* Gray 200 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --danger: #ef4444;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3,
h4 {
    margin-top: 0;
    font-weight: 600;
}

/* Navbar */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-menu li a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-menu li a:hover {
    color: var(--text-main);
    background-color: #f9fafb;
}

.nav-menu li a.active {
    color: var(--primary);
    background-color: #eef2ff;
}

.btn-logout {
    color: white !important;
    background-color: var(--danger) !important;
    padding: 0.5rem 1rem !important;
}

.btn-logout:hover {
    background-color: #dc2626 !important;
}

/* Main Layout */
.app-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    box-sizing: border-box;
}

/* Components: Card */
.card {
    background: var(--bg-card);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Components: Buttons */
.btn-primary,
.btn-danger,
button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    line-height: inherit;
}

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

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

.btn-danger {
    background-color: var(--danger);
    color: white;
    text-decoration: none;
}

/* Review: specific to dashboard stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    background-color: #f9fafb;
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f9fafb;
}

/* Login Page specific */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Use a rich, modern gradient */
    background: linear-gradient(135deg, #4f46e5 0%, #0f172a 100%);
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease;
}

.login-card:hover {
    transform: translateY(-5px);
}

.login-card input {
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    transition: all 0.2s;
}

.login-card input:focus {
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.login-card button {
    background: linear-gradient(to right, #4f46e5, #4338ca);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transition: all 0.2s;
}

.login-card button:hover {
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        padding: 0.5rem 1rem;
        height: auto;
        gap: 0.5rem;
    }

    .nav-menu {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        width: 100%;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        /* Hide Scrollbar */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-menu li {
        flex: 0 0 auto;
        /* Don't shrink */
    }

    .nav-menu li a {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
        background: #f3f4f6;
        border-radius: 15px;
    }

    .stats-grid,
    .grid-container {
        grid-template-columns: 1fr;
    }

    .stats-grid>div,
    .card {
        margin-bottom: 1rem;
        padding: 1rem;
        /* Reduce padding on mobile */
    }

    .main-content {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }
}

/* Helper for tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

/* Force inline grid styles to break on mobile if needed */
@media (max-width: 600px) {
    .grid-responsive {
        display: block !important;
    }

    .grid-responsive>div {
        margin-bottom: 1rem;
    }
}

/* PRINT STYLES */
@media print {

    /* Page Setup - Maximize space */
    @page {
        size: A4;
        margin: 1cm;
        /* Reduced margin */
    }

    /* Hide everything by default */
    body * {
        visibility: hidden;
    }

    /* Only show the printable area and its children */
    .printable-area,
    .printable-area * {
        visibility: visible;
    }

    /* Position the printable area at the absolute top to remove whitespace */
    .printable-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        /* Ensure it fits page width */
        max-width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        background: white;
        border: none !important;
        box-sizing: border-box;
        z-index: 9999;
        overflow: visible !important;
        /* Ensure no scrollbars */
    }

    /* Remove scroll handling from wrappers in print */
    .card,
    .table-responsive,
    div[style*="overflow-x"] {
        overflow: visible !important;
        width: 100% !important;
        display: block !important;
    }

    /* Scale down slightly to fit typically tight tables */
    body {
        transform: scale(0.95);
        transform-origin: top left;
        width: 105%;
        /* Compensate for scale */
    }

    /* Ensure body and html don't add spacing */
    html,
    body {
        height: auto;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible;
        width: 100%;
    }

    /* Hide specific non-print elements even inside printable area */
    .btn-primary,
    .btn-danger,
    button,
    .no-print,
    .pagination-controls {
        display: none !important;
    }

    /* Ensure tables print well */
    table {
        border: 1px solid #000;
        width: 100% !important;
        max-width: 100% !important;
        border-collapse: collapse;
        margin-top: 5px;
        table-layout: fixed;
        /* Force table to stay within width */
        word-wrap: break-word;
        /* Wrap long text */
    }

    th,
    td {
        border: 1px solid #000;
        padding: 4px 5px;
        /* Compact padding */
        color: #000;
        font-size: 9pt;
        /* Smaller font */
        vertical-align: top;
    }

    /* Grid Adjustments for Print: Remove 2-column if needed, or adjust gap */
    .grid-container {
        display: block !important;
        /* Stack vertically if needed, or keep grid with smaller gap */
    }

    /* Specific for P&L Card in Print */
    .grid-container .card {
        width: 100% !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        margin-bottom: 10px;
    }

    /* Badge colors adjustment for print */
    .badge-green,
    .badge-red,
    .badge-blue {
        border: 1px solid #000;
        background: none !important;
        color: #000 !important;
        padding: 0 4px;
    }

    /* Print Header Display */
    .print-header {
        display: block !important;
        text-align: center;
        border-bottom: 2px solid #000;
        margin-bottom: 20px;
        padding-bottom: 15px;
    }

    .print-header h2 {
        font-size: 18pt;
        margin-bottom: 5px;
    }

    .print-header p {
        font-size: 11pt;
    }
}

.print-header {
    display: none;