/* assets/css/style.css */
:root {
    --primary: #0F172A;
    --accent: #38BDF8;
    --neutral: #F8FAFC;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--neutral);
    color: var(--text-dark);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Auth Pages */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--primary);
    padding: 1rem;
}

.auth-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
}

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

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

.alert {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative; /* For overlay */
}

.sidebar, .client-sidebar {
    width: 250px;
    background-color: #ffffff;
    color: var(--text-dark);
    flex-shrink: 0;
    border-right: 1px solid #e2e8f0;
    transition: transform 0.3s ease;
}

/* Specific Client Sidebar overrides if needed, but keeping common */
.client-sidebar {
    height: 100vh;
    position: fixed; /* Keep fixed for client as per original */
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-dark);
    transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
    background-color: #f1f5f9;
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.main-content {
    flex: 1;
    background-color: var(--neutral);
    overflow-y: auto;
    /* transition: margin-left 0.3s ease; removed to avoid jitter */
}

/* Handle client portal margin */
body:has(.client-sidebar) .main-content {
    margin-left: 250px;
}

.top-bar {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-wrapper {
    padding: 2rem;
}

/* Toolbar (Action Bar) */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table doesn't squash too much */
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-light);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-paid, .status-approved { background-color: #dcfce7; color: #166534; }
.status-unpaid, .status-sent { background-color: #fef9c3; color: #854d0e; }
.status-overdue, .status-rejected { background-color: #fee2e2; color: #991b1b; }
.status-draft { background-color: #f1f5f9; color: #475569; }

/* Dashboard Widgets */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-title {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Responsive Logic */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
    padding: 0.5rem;
    margin-right: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

@media (max-width: 768px) {
    .sidebar, .client-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }

    .sidebar.active, .client-sidebar.active {
        transform: translateX(0);
    }

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

    .main-content {
        width: 100%;
        margin-left: 0 !important; /* Force override */
    }

    .mobile-menu-btn {
        display: block;
    }

    .top-bar {
        padding: 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar button, .toolbar a.btn {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Adjust search inputs in top bars */
    form[method="GET"] {
        flex-wrap: wrap;
        width: 100%;
    }
    
    form[method="GET"] input {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }
    
    form[method="GET"] button {
        width: 100% !important;
    }
}
