/* =============================================
   Boekhoudapplicatie - Stylesheet
   ============================================= */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --info: #0891b2;
    --info-light: #ecfeff;
    --grey-50: #f9fafb;
    --grey-100: #f3f4f6;
    --grey-200: #e5e7eb;
    --grey-300: #d1d5db;
    --grey-400: #9ca3af;
    --grey-500: #6b7280;
    --grey-600: #4b5563;
    --grey-700: #374151;
    --grey-800: #1f2937;
    --grey-900: #111827;
    --white: #ffffff;
    --sidebar-width: 250px;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

html {
    font-size: 15px;
    line-height: 1.5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--grey-800);
    background: var(--grey-50);
}

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

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
}

/* =============================================
   Login pagina
   ============================================= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
    font-size: 1.8rem;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--grey-600);
    font-size: 1.1rem;
    font-weight: 400;
}

/* =============================================
   Layout: Sidebar + Main
   ============================================= */
.admin-body, .client-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--grey-800);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem 1.2rem 1rem;
    border-bottom: 1px solid var(--grey-700);
}

.sidebar-header h2 {
    font-size: 1.3rem;
    color: var(--white);
}

.sidebar-subtitle {
    font-size: 0.8rem;
    color: var(--grey-400);
    display: block;
    margin-top: 0.2rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-nav li a {
    display: block;
    padding: 0.7rem 1.2rem;
    color: var(--grey-300);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover {
    background: var(--grey-700);
    color: var(--white);
    text-decoration: none;
}

.sidebar-nav li a.active {
    background: var(--primary);
    color: var(--white);
}

.sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--grey-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--grey-400);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--white);
    padding: 1.2rem 2rem;
    border-bottom: 1px solid var(--grey-200);
    box-shadow: var(--shadow);
}

.top-bar h1 {
    font-size: 1.4rem;
    color: var(--grey-800);
}

.content {
    padding: 1.5rem 2rem;
    flex: 1;
}

/* =============================================
   Formulieren
   ============================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--grey-700);
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--grey-800);
    background: var(--white);
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control[readonly] {
    background: var(--grey-100);
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--grey-500);
    margin-top: 0.2rem;
}

/* =============================================
   Knoppen
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    border-color: var(--grey-300);
    color: var(--grey-700);
}
.btn-outline:hover {
    background: var(--grey-100);
    border-color: var(--grey-400);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
}

/* =============================================
   Tabellen
   ============================================= */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

thead th {
    background: var(--grey-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--grey-600);
    border-bottom: 2px solid var(--grey-200);
    white-space: nowrap;
}

tbody td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--grey-100);
    font-size: 0.9rem;
}

tbody tr:hover {
    background: var(--grey-50);
}

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

.table-actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.text-right {
    text-align: right;
}

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

.text-muted {
    color: var(--grey-500);
}

/* =============================================
   Kaarten / Cards
   ============================================= */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--grey-500);
    margin-bottom: 0.3rem;
}

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

.stat-card .stat-value.text-success { color: var(--success); }
.stat-card .stat-value.text-danger { color: var(--danger); }
.stat-card .stat-value.text-primary { color: var(--primary); }

/* =============================================
   Badges
   ============================================= */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-grey { background: var(--grey-200); color: var(--grey-700); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* =============================================
   Flash berichten
   ============================================= */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.flash-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: var(--info-light); color: #155e75; border: 1px solid #a5f3fc; }

.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0 0.25rem;
}
.flash-close:hover { opacity: 1; }

/* =============================================
   Paginering
   ============================================= */
.pagination {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.page-link {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--grey-700);
    text-decoration: none;
}

.page-link:hover {
    background: var(--grey-100);
    text-decoration: none;
}

.page-link.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.page-dots {
    padding: 0.4rem 0.3rem;
    color: var(--grey-400);
}

/* =============================================
   Toolbar / Filter bar
   ============================================= */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.toolbar-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 0.3rem;
}

.filter-group .btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

.filter-group .btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--grey-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 250px;
}

/* =============================================
   Factuur regels (dynamisch formulier)
   ============================================= */
.invoice-lines {
    width: 100%;
    margin: 1rem 0;
}

.invoice-lines th {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
}

.invoice-lines td {
    padding: 0.3rem 0.3rem;
    vertical-align: top;
}

.invoice-lines .form-control {
    font-size: 0.85rem;
    padding: 0.4rem 0.5rem;
}

.invoice-lines .desc-col { width: 35%; }
.invoice-lines .qty-col { width: 10%; }
.invoice-lines .price-col { width: 15%; }
.invoice-lines .vat-col { width: 12%; }
.invoice-lines .total-col { width: 18%; }
.invoice-lines .action-col { width: 10%; }

.invoice-totals {
    margin-left: auto;
    width: 300px;
}

.invoice-totals table {
    box-shadow: none;
}

.invoice-totals td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--grey-100);
}

.invoice-totals tr:last-child td {
    font-weight: 700;
    font-size: 1.1rem;
    border-top: 2px solid var(--grey-300);
}

/* =============================================
   Activiteiten feed
   ============================================= */
.activity-feed {
    list-style: none;
}

.activity-feed li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--grey-100);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.activity-feed li:last-child {
    border-bottom: none;
}

.activity-time {
    color: var(--grey-400);
    font-size: 0.8rem;
    white-space: nowrap;
    margin-left: 1rem;
}

/* =============================================
   Upload zone
   ============================================= */
.upload-zone {
    border: 2px dashed var(--grey-300);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone p {
    color: var(--grey-500);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* =============================================
   AI review formulier
   ============================================= */
.ai-review-form .form-group {
    position: relative;
}

.ai-confidence {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 0.75rem;
    color: var(--grey-400);
}

/* =============================================
   Loader / Spinner
   ============================================= */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--grey-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
    gap: 1rem;
}

.loading-overlay p {
    color: var(--grey-600);
    font-size: 0.95rem;
}

/* =============================================
   BTW-aangifte
   ============================================= */
.vat-rubriek-header {
    background: var(--grey-800);
    color: var(--white);
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
}

.vat-table {
    width: 100%;
    border-collapse: collapse;
}

.vat-table td,
.vat-table th {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--grey-100);
    font-size: 0.9rem;
}

.vat-table th {
    font-weight: 600;
    color: var(--grey-500);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.vat-table tbody tr:last-child td {
    border-bottom: none;
}

.vat-saldo-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.vat-saldo-betalen {
    background: #fff5f5;
    border: 1px solid #fecaca;
}

.vat-saldo-ontvangen {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.vat-saldo-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.vat-saldo-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--grey-500);
}

.vat-saldo-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--grey-800);
}

.vat-saldo-amount {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.vat-saldo-betalen .vat-saldo-amount {
    color: var(--danger);
}

.vat-saldo-ontvangen .vat-saldo-amount {
    color: var(--success);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .top-bar {
        padding: 1rem;
    }

    .content {
        padding: 1rem;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box input {
        width: 100%;
    }

    .invoice-totals {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   Utilities
   ============================================= */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--grey-500);
}

.empty-state p {
    margin-bottom: 1rem;
}

.confirm-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.confirm-dialog-box {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
}

.confirm-dialog-box p {
    margin-bottom: 1.5rem;
}

.confirm-dialog-box .form-actions {
    justify-content: flex-end;
    margin-top: 0;
}
