/* =============================================
   Carverse — Main Stylesheet
   ============================================= */

:root {
    --color-primary: #e74c3c;
    --color-primary-dark: #c0392b;
    --color-secondary: #2c3e50;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-danger: #e74c3c;
    --color-info: #3498db;
    --color-muted: #95a5a6;
    --color-bg: #f5f6fa;
    --color-card: #ffffff;
    --color-sidebar: #1a1a2e;
    --color-sidebar-text: #eee;
    --color-text: #2c3e50;
    --color-border: #dcdde1;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --sidebar-width: 240px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* =============================================
   Layout
   ============================================= */

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.sidebar-subtitle {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
}

.sidebar-nav .nav-item {
    margin: 2px 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-icon {
    font-size: 0.6rem;
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.locale-select {
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* =============================================
   Page Header
   ============================================= */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
}

/* =============================================
   Cards & Stats
   ============================================= */

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

.stat-card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--color-muted);
}

.stat-card h3 {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.stat-card p {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.stat-green { border-left-color: var(--color-success); }
.stat-blue { border-left-color: var(--color-info); }
.stat-orange { border-left-color: var(--color-warning); }
.stat-info { border-left-color: var(--color-info); }
.stat-purple { border-left-color: #9b59b6; }
.stat-red { border-left-color: var(--color-danger); }
.stat-teal { border-left-color: #1abc9c; }

/* =============================================
   Tables
   ============================================= */

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

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    background: var(--color-secondary);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table tbody tr:hover {
    background: rgba(52, 152, 219, 0.04);
}

.clickable-row {
    cursor: pointer;
}

/* =============================================
   Badges
   ============================================= */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-info { background: #cce5ff; color: #004085; }

/* =============================================
   Forms
   ============================================= */

.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--color-secondary);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* =============================================
   Buttons
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-secondary { background: var(--color-muted); color: white; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* =============================================
   Filters
   ============================================= */

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.filters .form-control {
    max-width: 300px;
}

/* =============================================
   Vehicule Cards Grid
   ============================================= */

.vehicule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.vehicule-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.vehicule-card:hover {
    transform: translateY(-2px);
}

.vehicule-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

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

.vehicule-card-body p {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 2px;
}

.vehicule-card-price {
    color: var(--color-success) !important;
    font-weight: 600;
    margin-top: 4px !important;
}

/* =============================================
   Detail Pages
   ============================================= */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.detail-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.detail-card h3 {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-primary);
}

.detail-card dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px;
}

.detail-card dt {
    font-weight: 600;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* =============================================
   Login
   ============================================= */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-sidebar);
}

.login-card {
    background: var(--color-card);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-title {
    color: var(--color-primary);
    text-align: center;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--color-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* =============================================
   Pagination
   ============================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--color-muted);
}

/* =============================================
   Calendar
   ============================================= */

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 120px;
    box-shadow: var(--shadow);
}

.calendar-day h4 {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.calendar-event {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 4px;
    background: #eef2ff;
    border-left: 3px solid var(--color-info);
}

.calendar-event-essai { border-left-color: var(--color-info); background: #cce5ff; }
.calendar-event-livraison { border-left-color: var(--color-success); background: #d4edda; }
.calendar-event-remise_cles { border-left-color: #9b59b6; background: #f0e6ff; }
.calendar-event-entretien { border-left-color: var(--color-warning); background: #fff3cd; }

.event-time {
    font-weight: 600;
    margin-right: 4px;
}

/* =============================================
   Documents (BC & Facture)
   ============================================= */

.document-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.document {
    background: white;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px;
    box-shadow: var(--shadow);
}

.document-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--color-primary);
}

.company-name {
    color: var(--color-primary);
    font-size: 1.8rem;
}

.company-info p {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.document-meta h2 {
    color: var(--color-primary);
    text-align: right;
}

.document-meta p {
    text-align: right;
    font-size: 0.9rem;
}

.document-section {
    margin-bottom: 24px;
}

.document-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    color: var(--color-secondary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--color-border);
}

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

.document-table td {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.document-table td:nth-child(odd) {
    font-weight: 600;
    background: #f8f9fa;
    width: 25%;
}

.financial td:first-child {
    width: 70%;
}

.financial td:last-child {
    text-align: right;
}

.payment-terms {
    margin-top: 8px;
    font-style: italic;
    color: var(--color-muted);
}

.legal-mention {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.85rem;
}

.export-mention {
    background: #fff3cd;
    border: 1px solid var(--color-warning);
}

.document-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
}

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

.signature-line {
    width: 200px;
    height: 1px;
    background: var(--color-text);
    margin: 60px auto 8px;
}

/* =============================================
   Conditions Page
   ============================================= */

.conditions-page {
    max-width: 800px;
    margin: 0 auto;
}

.conditions-list li {
    margin-bottom: 16px;
    line-height: 1.6;
}

.conditions-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 2px solid var(--color-primary);
}

/* =============================================
   Settings
   ============================================= */

.settings-section {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.settings-section h2 {
    margin-bottom: 16px;
}

/* =============================================
   Toast
   ============================================= */

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); color: #333; }
.toast-info { background: var(--color-info); }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =============================================
   Alerts
   ============================================= */

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* =============================================
   Loading
   ============================================= */

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 12px;
}

.loading-screen h1 {
    color: var(--color-primary);
    font-size: 2rem;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    gap: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =============================================
   Modal
   ============================================= */

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

.modal-dialog {
    background: var(--color-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* =============================================
   Utilities
   ============================================= */

.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-center { text-align: center; }
.mt-5 { margin-top: 40px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* =============================================
   Print Styles
   ============================================= */

@media print {
    .no-print,
    .sidebar,
    .topbar,
    .toast-container {
        display: none;
    }

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

    .document {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
    }

    .document-header {
        border-bottom-color: var(--color-primary);
    }

    .company-name {
        color: var(--color-primary);
    }

    body {
        background: white;
    }
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

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

    .form-row {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

/* =============================================
   Frais Section (Vehicle Detail)
   ============================================= */

.frais-section {
    margin-top: 32px;
}

.frais-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.frais-header h2 {
    font-size: 1.2rem;
}

.frais-form-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--color-primary);
}

.table tfoot td {
    background: #f8f9fa;
    font-weight: 600;
    border-top: 2px solid var(--color-border);
}

/* =============================================
   Quick Actions (Dashboard)
   ============================================= */

.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.dashboard-section {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.dashboard-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-primary);
}
