/* ==========================================================================
   CarSolutions - estilos base
   ========================================================================== */

:root {
    --cs-primary: #0b57d0;
    --cs-primary-dark: #08479e;
    --cs-sidebar-bg: #1f2937;
    --cs-sidebar-hover: #374151;
    --cs-sidebar-active: #0b57d0;
    --cs-sidebar-text: #cbd5e1;
}

html, body {
    min-height: 100vh;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ==========================================================================
   Preloader
   ========================================================================== */

.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .4s ease, visibility .4s ease;
}

body.loaded .preloader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(11, 87, 208, .2);
    border-top-color: var(--cs-primary);
    border-radius: 50%;
    animation: cs-spin 1s linear infinite;
}

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

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

body.login {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    min-height: 100vh;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 85px;
}

.sing-in {
    width: 100%;
    max-width: 420px;
}

.sing-in h1,
.sing-in p {
    color: #ffffff !important;
}

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3));
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    cursor: pointer;
    color: #6c757d;
    z-index: 2;
}

body.login > center {
    width: 100%;
    margin-top: 8px;
    font-size: .8rem;
    text-align: center;
}

body.login > center a {
    color: rgba(255, 255, 255, .55);
    text-decoration: none;
}

body.login > div[style*="height: 65px"] {
    display: none;
}

/* ==========================================================================
   Sidebar (backend)
   ========================================================================== */

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

.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--cs-sidebar-bg);
    color: var(--cs-sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width .25s ease, min-width .25s ease;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #ffffff;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar .nav {
    flex: 1;
    min-height: 0;
    padding: .5rem 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar .nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--cs-sidebar-text);
    padding: .65rem 1.25rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.sidebar .nav-item .nav-link:hover {
    color: #ffffff;
    background: var(--cs-sidebar-hover);
}

.sidebar > .nav > .nav-item.active > .nav-link {
    color: #ffffff;
    background: var(--cs-sidebar-active);
    border-left-color: #ffffff;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f1f5f9;
}

.topbar {
    background: #ffffff;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.topbar-toggle {
    color: var(--cs-sidebar-bg);
    font-size: 1.25rem;
}

.topbar-user {
    color: #475569;
    font-weight: 500;
}

.topbar-user i {
    margin-right: .35rem;
}

/* Criterios de contraseña */
.password-criteria li {
    color: #6c757d;
    margin-bottom: .25rem;
}

.password-criteria li i {
    width: 20px;
    margin-right: .25rem;
}

.password-criteria li.met {
    color: #198754;
}

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

/* Sidebar colapsado */
body.sidebar-collapsed .sidebar {
    width: 64px;
    min-width: 64px;
}

body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar .nav-link span {
    display: none;
}

body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: .65rem 0;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

/* ==========================================================================
   Dashboard / tarjetas
   ========================================================================== */

.page-title h1 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.stat-card {
    border: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.stat-icon {
    font-size: 1.6rem;
    color: var(--cs-primary);
    margin-bottom: .5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.stat-label {
    color: #6b7280;
}

.home-icon {
    font-size: 4rem;
    color: var(--cs-primary);
}

/* ==========================================================================
   Tabla / ABM de usuarios
   ========================================================================== */

.btn-icon {
    color: #475569;
}

.btn-icon:hover {
    color: var(--cs-primary);
}

#usuariosTable th {
    font-weight: 600;
    color: #475569;
    border-top: 0;
    white-space: nowrap;
}

#usuariosTable .dropdown-menu .dropdown-item i {
    width: 18px;
    margin-right: .25rem;
}

/* ==========================================================================
   Marcas de auto
   ========================================================================== */

.expand-icon {
    transition: transform .2s ease;
}

.marca-row {
    cursor: pointer;
}

.marca-row.expanded .expand-icon {
    transform: rotate(90deg);
}

.model-badge {
    font-weight: 500;
}

.modelos-row td {
    background: #f8fafc;
    border-top: 0;
}

.modelos-container {
    max-height: 320px;
    overflow-y: auto;
}

.model-item {
    border-bottom: 1px solid #e9ecef;
    padding: .3rem .25rem;
}

.model-item:last-child {
    border-bottom: 0;
}

/* ==========================================================================
   Submenú del sidebar (Configuración)
   ========================================================================== */

.nav-item-config > .nav-link {
    cursor: pointer;
}

.submenu-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .22s ease;
}

.submenu-wrap.is-open {
    grid-template-rows: 1fr;
}

.submenu-wrap > .submenu {
    overflow: hidden;
    min-height: 0;
}

.submenu {
    padding-left: 0;
    margin: 0;
    border-left: 2px solid transparent;
}

.submenu-wrap.is-open .submenu {
    padding-left: 0.5rem;
    margin-left: 1rem;
    border-left-color: rgba(255, 255, 255, 0.12);
}

.submenu .nav-item .nav-link {
    border-left: 0;
    padding-top: .45rem;
    padding-bottom: .45rem;
    padding-left: 1.75rem;
    font-size: .92rem;
}

.submenu > .nav-item.active > .nav-link {
    background: var(--cs-sidebar-active);
    color: #ffffff;
    border-left: 0;
}

.submenu > .nav-item:not(.active) > .nav-link {
    background: transparent;
    color: var(--cs-sidebar-text);
}

.submenu-caret {
    transition: transform .22s ease;
    font-size: .8rem;
}

#btnConfigMenu[aria-expanded="true"] .submenu-caret {
    transform: rotate(180deg);
}

/* ==========================================================================
   Autocomplete (combobox con búsqueda)
   ========================================================================== */

.autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    display: none;
    margin: 2px 0 0;
    padding: .25rem 0;
    max-height: 220px;
    overflow-y: auto;
    list-style: none;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}

.autocomplete-list li {
    padding: .4rem .75rem;
    cursor: pointer;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
    background: #e9ecef;
}

/* ==========================================================================
   Modal de órdenes de trabajo
   ========================================================================== */

.modal-section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
    font-size: .95rem;
    font-weight: 600;
    color: var(--cs-primary);
}

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

@media (max-width: 768px) {
    .wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
    }

    body.sidebar-collapsed .sidebar {
        width: 100%;
        min-width: 100%;
    }

    body.sidebar-collapsed .sidebar-title,
    body.sidebar-collapsed .sidebar .nav-link span {
        display: inline;
    }
}

body.sidebar-mobile-active {
    overflow: hidden;
}

body.sidebar-mobile-active .sidebar {
    z-index: 1050;
}

/* Overlay semi-transparente cuando el menú está abierto en móvil */
body.sidebar-mobile-active::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 1040;
    pointer-events: auto;
}