/* ===================================== */
/* PANEL DE ADMINISTRACIÓN — TECNOLEASE  */
/* ===================================== */
:root {
    --azul: #0652DD;
    --azul-hover: #0441b3;
    --oscuro: #0f172a;
    --oscuro-2: #1e293b;
    --fondo: #f1f5f9;
    --borde: #e2e8f0;
    --texto: #1e293b;
    --suave: #64748b;
    --rojo: #dc2626;
    --verde: #16a34a;
    --ambar: #d97706;
    --ancho-menu: 240px;
    --ancho-menu-colapsado: 72px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    line-height: 1.5;
}

a { color: var(--azul); }

/* ===== Botones ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-hover); }
.btn-secundario { background: #fff; color: var(--texto); border-color: var(--borde); }
.btn-secundario:hover { border-color: var(--azul); color: var(--azul); }
.btn-peligro { background: #fff; color: var(--rojo); border-color: #fecaca; }
.btn-peligro:hover { background: var(--rojo); color: #fff; }
.btn-pequeno { padding: 5px 10px; font-size: 0.82rem; }
.btn-bloque { width: 100%; }

/* ===== Alertas ===== */
.alerta {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
}
.alerta-ok { background: #dcfce7; color: #166534; }
.alerta-error { background: #fee2e2; color: #991b1b; }

/* ===================================== */
/* LOGIN                                 */
/* ===================================== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--oscuro), #0a3d62 60%, var(--azul));
}

.login-caja {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.login-logo { height: 64px; border-radius: 12px; margin-bottom: 12px; }
.login-caja h1 { font-size: 1.3rem; margin-bottom: 20px; }

.login-caja form { text-align: left; display: grid; gap: 14px; }
.login-caja label { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }

.login-volver {
    display: inline-block;
    margin-top: 18px;
    font-size: 0.9rem;
    color: var(--suave);
    text-decoration: none;
}

/* ===== Campos (login y formularios) ===== */
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="file"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    background: #fff;
    color: var(--texto);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(6, 82, 221, 0.15);
}

/* ===================================== */
/* ESTRUCTURA: MENÚ LATERAL + CONTENIDO  */
/* ===================================== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--ancho-menu);
    background: var(--oscuro);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.sidebar-marca {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    font-weight: 700;
    color: #fff;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.sidebar-marca img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: grid; align-content: start; gap: 4px; }

.sidebar-nav a,
.sidebar-pie a,
.sidebar-pie button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font: inherit;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover,
.sidebar-pie a:hover,
.sidebar-pie button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.sidebar-nav a.activo { background: var(--azul); color: #fff; }

.nav-icono { font-size: 1.2rem; width: 24px; text-align: center; flex-shrink: 0; }

.sidebar-pie { padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.principal {
    margin-left: var(--ancho-menu);
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.barra-superior {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid var(--borde);
}

.barra-superior h1 { font-size: 1.2rem; flex: 1; }
.usuario { color: var(--suave); font-size: 0.9rem; }

.btn-menu {
    background: none;
    border: 1px solid var(--borde);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
}

.contenido { padding: 24px; max-width: 1400px; }

/* Menú colapsado (escritorio): solo íconos */
.menu-colapsado .sidebar { width: var(--ancho-menu-colapsado); }
.menu-colapsado .principal { margin-left: var(--ancho-menu-colapsado); }
.menu-colapsado .ocultable { display: none; }
.menu-colapsado .sidebar-nav a,
.menu-colapsado .sidebar-pie a,
.menu-colapsado .sidebar-pie button { justify-content: center; }
.menu-colapsado .sidebar-marca { justify-content: center; padding-inline: 0; }

.sidebar-fondo { display: none; }

/* ===================================== */
/* COMPONENTES                           */
/* ===================================== */
.metricas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metrica {
    display: grid;
    gap: 2px;
    padding: 18px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--borde);
    border-left: 4px solid var(--azul);
    color: var(--texto);
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metrica:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.metrica-icono { font-size: 1.4rem; }
.metrica strong { font-size: 2rem; line-height: 1.1; }
.metrica span:last-child { color: var(--suave); font-size: 0.9rem; }
.metrica-alerta { border-left-color: var(--ambar); }
.metrica-ok { border-left-color: var(--verde); }

.panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--borde);
    padding: 20px;
}

.panel-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-cabecera h2 { font-size: 1.1rem; }

.vacio { text-align: center; color: var(--suave); padding: 30px 0; }

/* ===== Filtros y pestañas ===== */
.filtros {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.filtros-derecha { display: flex; flex-wrap: wrap; gap: 10px; }

.pestanas { display: flex; flex-wrap: wrap; gap: 6px; }

.pestanas a {
    padding: 7px 14px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--borde);
    color: var(--texto);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
}

.pestanas a span {
    display: inline-block;
    min-width: 22px;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--fondo);
    font-size: 0.78rem;
    text-align: center;
}

.pestanas a.activa { background: var(--azul); border-color: var(--azul); color: #fff; }
.pestanas a.activa span { background: rgba(255, 255, 255, 0.25); }

.buscador { display: flex; gap: 8px; }
.buscador input { min-width: 220px; }

/* ===== Tablas ===== */
.tabla-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--suave);
    padding: 10px 12px;
    border-bottom: 1px solid var(--borde);
    white-space: nowrap;
}

td { padding: 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
td a { text-decoration: none; }

.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, monospace; }
.texto-suave { color: var(--suave); }

.acciones { display: flex; gap: 6px; justify-content: flex-end; }

.form-fila { display: flex; gap: 6px; align-items: center; min-width: 380px; }
.form-fila select { width: auto; }
.form-fila input { flex: 1; min-width: 120px; }

/* Estado de cotización con color */
select.estado-pendiente { border-color: #fcd34d; background: #fffbeb; }
select.estado-contactado { border-color: #93c5fd; background: #eff6ff; }
select.estado-cerrado { border-color: #86efac; background: #f0fdf4; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--fondo);
    color: var(--texto);
}

.badge-disponible { background: #dcfce7; color: #166534; }
.badge-alquilado { background: #dbeafe; color: #1e40af; }
.badge-mantenimiento { background: #fef3c7; color: #92400e; }
.badge-agotado { background: #fee2e2; color: #991b1b; }

.miniatura {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--borde);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.miniatura-vacia { font-size: 1.3rem; background: var(--fondo); }

.paginacion { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 16px; }

.paginacion a {
    min-width: 34px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--borde);
    text-align: center;
    text-decoration: none;
    color: var(--texto);
}

.paginacion a.activa { background: var(--azul); border-color: var(--azul); color: #fff; }

/* ===== Formularios de creación/edición ===== */
.formulario {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.formulario > label,
.campo-imagen > label { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }

.formulario .completo { grid-column: 1 / -1; }

fieldset {
    border: 1px solid var(--borde);
    border-radius: 8px;
    padding: 10px 14px 12px;
}

legend { font-weight: 600; font-size: 0.9rem; padding: 0 6px; }

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-top: 6px;
    cursor: pointer;
}

label.check input { width: 18px; height: 18px; accent-color: var(--azul); }

.campo-imagen { display: grid; gap: 10px; }

.preview {
    max-width: 180px;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 6px;
    background: #fff;
}

.oculto { display: none; }

.acciones-form { display: flex; justify-content: flex-end; }

/* ===================================== */
/* RESPONSIVE                            */
/* ===================================== */
@media (max-width: 900px) {
    /* En móvil el menú es un panel deslizable */
    .sidebar,
    .menu-colapsado .sidebar { width: var(--ancho-menu); transform: translateX(-100%); }
    .menu-abierto .sidebar { transform: none; }
    .principal,
    .menu-colapsado .principal { margin-left: 0; }
    .menu-colapsado .ocultable { display: inline; }
    .menu-colapsado .sidebar-nav a,
    .menu-colapsado .sidebar-pie a,
    .menu-colapsado .sidebar-pie button { justify-content: flex-start; }

    .menu-abierto .sidebar-fondo {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 90;
    }

    .contenido { padding: 16px; }
    .barra-superior { padding: 12px 16px; }
    .usuario { display: none; }

    .formulario { grid-template-columns: 1fr; }
    .buscador input { min-width: 0; }
    .filtros-derecha, .buscador { width: 100%; }
    .buscador input { flex: 1; }
}

/* ===================================== */
/* HERRAMIENTAS INTEGRADAS (iframe)      */
/* ===================================== */
.herramienta-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 115px);
    min-height: 560px;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #fff;
}

/* En las herramientas el espacio vale más que el margen */
.contenido:has(.herramienta-frame) { padding: 12px; max-width: none; }

.form-cotizar { margin-top: 6px; }

.texto-alerta { color: var(--rojo); font-weight: 600; }

select.cot-borrador { background: #f8fafc; }
select.cot-enviada { border-color: #93c5fd; background: #eff6ff; }
select.cot-aceptada { border-color: #86efac; background: #f0fdf4; }
select.cot-rechazada { border-color: #fecaca; background: #fef2f2; }
