/* ============================================================
   AUTOEVOLUZIONE - Estilos principales
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1a1f2e;
    --sidebar-hover: #2d3446;
    --sidebar-active: #e63946;
    --sidebar-text: #a8b2c8;
    --sidebar-text-active: #ffffff;
    --topbar-height: 60px;
    --primary: #e63946;
    --primary-dark: #c1121f;
    --accent: #ffee00;
    --bg-light: #f4f6fb;
    --card-shadow: 0 2px 12px rgba(0,0,0,.08);
    --transition: 0.25s ease;
    /* Sobreescribir Bootstrap warning con amarillo corporativo */
    --bs-warning:         #ffee00;
    --bs-warning-rgb:     255, 238, 0;
    --bs-warning-bg-subtle: #fffde0;
    --bs-warning-text-emphasis: #6b6300;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: #333;
    margin: 0;
    overflow-x: hidden;
}

/* ── Login / Register pages ─────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3446 50%, #1a1f2e 100%);
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}
.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo img { max-width: 200px; }
.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1f2e;
    margin-bottom: 0.25rem;
}
.auth-subtitle {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}
.btn-auth {
    background: var(--primary);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    width: 100%;
    transition: background var(--transition), transform var(--transition);
}
.btn-auth:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* ── Layout principal ────────────────────────────────────────── */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: width var(--transition);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
}
.sidebar-logo {
    max-width: 160px;
    max-height: 48px;
    object-fit: contain;
    filter: brightness(1.1) contrast(1.1);
    transition: var(--transition);
}
.sidebar.collapsed .sidebar-logo { display: none; }

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(168,178,200,.5);
    padding: 1rem 1.25rem 0.4rem;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item { position: relative; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.7rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: background var(--transition), color var(--transition), border-left var(--transition);
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.nav-link i {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}
.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}
.nav-item.active .nav-link {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active);
}
.nav-item.active .nav-link i { color: var(--sidebar-active); }

.sidebar-footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-avatar { font-size: 1.75rem; color: var(--sidebar-text); }
.user-details { flex: 1; overflow: hidden; }
.user-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { font-size: 0.65rem; }
.btn-logout {
    color: var(--sidebar-text);
    background: transparent;
    border: none;
    padding: 0.4rem;
    border-radius: 6px;
    font-size: 1.1rem;
    transition: color var(--transition), background var(--transition);
    cursor: pointer;
    text-decoration: none;
}
.btn-logout:hover { color: var(--primary); background: rgba(230,57,70,.1); }
.sidebar.collapsed .user-details,
.sidebar.collapsed .btn-logout { display: none; }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: margin-left var(--transition);
    min-width: 0;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-width); }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8ecf0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1f2e;
    margin: 0;
    flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.btn-icon {
    background: transparent;
    border: none;
    color: #6c757d;
    padding: 0.4rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--primary); background: rgba(230,57,70,.06); }

/* ── Content area ────────────────────────────────────────────── */
.content-area {
    padding: 1.5rem;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f2f5;
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
}
.card-header .card-title {
    margin: 0;
    font-size: 1rem;
    color: #1a1f2e;
}

/* ── Botones personalizados ─────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

/* ── Stat cards (dashboard) ─────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}
.stat-icon.red    { background: linear-gradient(135deg, #e63946, #c1121f); }
.stat-icon.blue   { background: linear-gradient(135deg, #0077b6, #023e8a); }
.stat-icon.green  { background: linear-gradient(135deg, #2dc653, #1a7a31); }
.stat-icon.orange { background: linear-gradient(135deg, #f77f00, #d62828); }
.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: #1a1f2e; line-height: 1; }
.stat-label { font-size: 0.8rem; color: #6c757d; margin-top: 0.25rem; }

/* ── Tables ──────────────────────────────────────────────────── */
.table > :not(caption) > * > * { padding: 0.7rem 0.875rem; }
.table-hover tbody tr:hover { background: rgba(230,57,70,.04); }
.badge { font-weight: 500; }

/* ── Form styles ─────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 0.85rem; color: #495057; margin-bottom: 0.3rem; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #dee2e6;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(230,57,70,.15);
}
.input-group .form-control, .input-group .form-select { border-radius: 8px !important; }
.input-group-text {
    border-radius: 8px !important;
    background: #f8f9fa;
    border: 1.5px solid #dee2e6;
    color: #6c757d;
}

/* ── Document / Invoice line items ──────────────────────────── */
.items-table { border-radius: 8px; overflow: hidden; border: 1px solid #e0e4ea; }
.items-table th {
    background: #1a1f2e;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}
.items-table td { padding: 0.4rem 0.4rem; vertical-align: middle; }
.items-table .line-discount     { width: 62px; }
.items-table .line-discount-amt { width: 80px; background: #f8f9fa; }
.items-table tr.type-MAT { border-left: 3px solid #0077b6; }
.items-table tr.type-MO  { border-left: 3px solid #2dc653; }
.items-table tr.type-FREE { border-left: 3px solid #f77f00; }

.badge-MAT  { background: #e3f2fd; color: #0077b6; }
.badge-MO   { background: #e8f5e9; color: #2dc653; }
.badge-FREE { background: #fff3e0; color: #f77f00; }

/* ── Totals box ──────────────────────────────────────────────── */
.totals-box {
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 12px;
    overflow: hidden;
}
.totals-box .totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #f0f2f5;
    font-size: 0.9rem;
}
.totals-box .totals-row:last-child { border-bottom: none; }
.totals-box .totals-row.total-mat { color: #0077b6; }
.totals-box .totals-row.total-mo  { color: #2dc653; }
.totals-box .totals-row.grand-total {
    background: #1a1f2e;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

/* ── Vehicle info box ────────────────────────────────────────── */
.vehicle-box {
    background: linear-gradient(135deg, #f8f9fa, #fff);
    border: 1px solid #e0e4ea;
    border-radius: 10px;
    padding: 1rem;
    border-left: 4px solid var(--primary);
}
.vehicle-box .vehicle-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

/* ── PDF / Print view ────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .no-print, .btn, .dataTables_wrapper .dataTables_filter { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none !important; border: none !important; }

    /* Encabezado de factura */
    .invoice-header { display: flex; gap: 1rem; }
    .invoice-logo { display: none; } /* No imprimir logo */
}

/* ── Invoice print layout ───────────────────────────────────── */
.print-view {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}
.print-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: start;
}
.print-logo img { max-width: 180px; max-height: 60px; object-fit: contain; }
.print-company { text-align: center; }
.print-company h2 { font-size: 1.1rem; font-weight: 800; color: #1a1f2e; }
.print-company p { font-size: 0.75rem; color: #555; margin: 0; line-height: 1.4; }
.doc-number-box {
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    text-align: center;
    min-width: 180px;
}
.doc-number-box .doc-type { font-size: 0.75rem; font-weight: 600; opacity: 0.85; }
.doc-number-box .doc-number { font-size: 1.5rem; font-weight: 800; }
.doc-number-box .doc-date { font-size: 0.8rem; opacity: 0.9; }

.client-box, .vehicle-info-box {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.875rem 1rem;
}
.client-box h6, .vehicle-info-box h6 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* ── Signature box ───────────────────────────────────────────── */
.signature-box {
    margin-top: 2rem;
    padding: 1rem;
    border: 1px dashed #adb5bd;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.signature-field {
    text-align: center;
}
.signature-field .sig-line {
    border-bottom: 1px solid #333;
    height: 60px;
    margin-bottom: 0.5rem;
}
.signature-field p { font-size: 0.8rem; color: #6c757d; margin: 0; }

/* ── Bootstrap warning override (#ffee00) ───────────────────── */
.bg-warning, .badge.bg-warning          { background-color: #ffee00 !important; color: #1a1f2e !important; }
.text-warning                           { color: #b8ac00 !important; }
.btn-warning                            { background-color: #ffee00; border-color: #ffee00; color: #1a1f2e; }
.btn-warning:hover                      { background-color: #e6d500; border-color: #e6d500; color: #1a1f2e; }
.btn-outline-warning                    { color: #b8ac00; border-color: #ffee00; }
.btn-outline-warning:hover              { background-color: #ffee00; border-color: #ffee00; color: #1a1f2e; }
.alert-warning                          { background-color: #fffde0; border-color: #ffee00; color: #6b6300; }

/* ── Status badges ───────────────────────────────────────────── */
.status-pending  { background: #fffde0; color: #6b6300; }
.status-accepted { background: #d1e7dd; color: #0f5132; }
.status-rejected { background: #f8d7da; color: #842029; }
.status-invoiced { background: #cff4fc; color: #055160; }
.status-paid     { background: #d1e7dd; color: #0f5132; }
.status-cancelled{ background: #e2e3e5; color: #41464b; }

/* ── DataTable custom ────────────────────────────────────────── */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: 0.85rem; }
.dataTables_wrapper .dataTables_filter input { border-radius: 8px; border: 1.5px solid #dee2e6; padding: 0.375rem 0.75rem; }

/* ── Select2 custom ─────────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: 8px;
    border: 1.5px solid #dee2e6;
    min-height: calc(1.5em + 0.75rem + 2px);
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.content-area > * { animation: fadeIn 0.2s ease; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .print-header { grid-template-columns: 1fr; }
    .signature-box { grid-template-columns: 1fr; }
}
