/* assets/css/style.css - estilos base LubriAdmin v1.4 */

:root {
    --color-bg: #f4f6fb;
    --color-sidebar-bg: #263238;
    --color-sidebar-hover: #37474f;
    --color-sidebar-text: #eceff1;
    --color-primary: #1976d2;
    --color-success: #2e7d32;
    --color-info: #0288d1;
    --color-danger: #d32f2f;
    --color-card-text: #455a64;
    --color-border: #e0e0e0;
    --radius-lg: 12px;
    --shadow-soft: 0 8px 20px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg);
    color: #263238;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
}

.sidebar__header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__logo {
    font-weight: 500;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar__logo i {
    color: #ffca28;
}

.sidebar__nav {
    flex: 1;
    padding: 8px 0;
}

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

.sidebar__link i {
    width: 18px;
}

.sidebar__link:hover {
    background-color: var(--color-sidebar-hover);
    opacity: 1;
    padding-left: 24px;
}

.sidebar__link--active {
    background: linear-gradient(90deg, #1e88e5, #42a5f5);
    opacity: 1;
}

.sidebar__footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.8rem;
    opacity: 0.7;
}

.sidebar__version {
    display: block;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: 56px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    justify-content: space-between;
}

.topbar__menu-btn {
    display: none;
    border: none;
    background: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #37474f;
}

.topbar__title {
    font-weight: 500;
    font-size: 1rem;
    margin-left: 8px;
}

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

.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #455a64;
}

.topbar__logout {
    color: #b0bec5;
    text-decoration: none;
    font-size: 1.1rem;
}

.topbar__logout:hover {
    color: #ef5350;
}

/* Content */
.content {
    padding: 20px;
}

/* Cards */
/* Cards container */
.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Fila especial para las cards de gastos (2 columnas) */
.cards--expenses {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 8px;
}

/* Card color para gastos */
/* Card de gastos (mejor contraste) */
.card--warning {
    background: linear-gradient(135deg, #f9c341, #f7b731);
}

/* Ícono */
.card--warning .card__icon {
    background: rgba(255,255,255,0.35);
}

/* Títulos (mucho mejor contraste) */
.card--warning .card__body h4 {
    color: #3d3d3d !important;
    font-weight: 700;
}

/* Monto principal */
.card--warning .card__value {
    color: #2a2a2a !important;
    font-weight: 800;
}

/* Subtítulos */
.card--warning .card__subtitle {
    color: #4a4a4a !important;
    font-weight: 500;
}

/* Resaltado de resultado */
.card--warning strong {
    font-weight: 700;
}

/* Estilo mejorado para la línea de resultado dentro de cards de gastos */
.card--warning .resultado-texto {
    font-weight: 700 !important;
    color: #2a2a2a !important;
}

.card--warning .resultado-monto {
    font-weight: 800 !important;
    color: #2a2a2a !important;
}

/* ===== Estilo mejorado para GASTOS DEL MES ===== */

.card--warning .resultado-texto,
.card--warning .resultado-monto {
    font-weight: 700 !important;
    color: #2a2a2a !important;
}

/* Si deseas que el monto destaque aún más */
.card--warning .resultado-monto {
    font-weight: 800 !important;
}

.card {
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.card__icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #ffffff;
    border-radius: 50%;              /* círculo perfecto */
    background: rgba(0,0,0,0.15);
}

.card__body h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: #ffffff;
}

.card__value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.card__subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
}

.card::after {
    content: "";
    position: absolute;
    inset: auto -40px -40px auto;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
}

.card--primary {
    background: linear-gradient(135deg, #1976d2, #42a5f5);
}

.card--success {
    background: linear-gradient(135deg, #2e7d32, #66bb6a);
}

.card--info {
    background: linear-gradient(135deg, #0288d1, #29b6f6);
}

.card--danger {
    background: linear-gradient(135deg, #d32f2f, #ef5350);
}

.card--clickable {
    cursor: pointer !important;
    transition: transform .1s ease-in-out;
}

.card--clickable:hover {
    transform: scale(1.02);
}

/* Panel */
.panel {
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 16px 16px 20px;
}

.panel__header {
    margin-bottom: 12px;
}

.panel__header h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: #263238;
}

.panel__subtitle {
    font-size: 0.85rem;
    color: #78909c;
}

/* PANEL HEADER UX */
.panel__header--between {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.panel__title-group h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Columna derecha del header: botón y filtros */
.panel__tools {
    display: flex;
    flex-direction: column;
    align-items: flex-start;  /* ahora todo a la izquierda */
    gap: 8px;
}

.btn-add-product {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 8px;
}

/* FILTER BAR (CHIPS) */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-bar--right {
    justify-content: flex-start; /* alineado a la izquierda */
}

/* Chips de filtro */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #f0f2f5;
    color: #333;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.18s ease-in-out;
    text-decoration: none; /* sin subrayado */
}

.filter-chip i {
    font-size: 13px;
}

.filter-chip:hover {
    background: #e6e9ed;
    cursor: pointer;
}

.filter-chip.active {
    background: #007bff;
    color: #fff;
}

/* Warning chip */
.chip-warning {
    background: #fff4d6;
    color: #7a4a00;
}
.chip-warning.active {
    background: #ffb300;
    color: #fff;
}

/* Danger chip */
.chip-danger {
    background: #ffe3e3;
    color: #8d0000;
}
.chip-danger.active {
    background: #e60000;
    color: #fff;
}

/* Table */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

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

.table thead {
    background-color: #eceff1;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
}

.table th {
    font-weight: 500;
    color: #455a64;
}

.table tbody tr:hover {
    background-color: #fafafa;
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge--success {
    background-color: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
}

.badge--danger {
    background-color: rgba(211, 47, 47, 0.12);
    color: #d32f2f;
}

.badge--info {
    background-color: rgba(2, 136, 209, 0.12);
    color: #0288d1;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #1976d2, #42a5f5);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(25, 118, 210, 0.55);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 7px 13px;
    border: 1px solid #b0bec5;
    background-color: #ffffff;
    color: #607d8b;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid #cfd8dc;
    background-color: #ffffff;
    color: #607d8b;
    text-decoration: none;
    font-size: 0.8rem;
    margin-left: 4px;
}

.btn-sm:hover {
    background-color: #eceff1;
}

.btn-sm.btn-danger {
    border-color: #ef9a9a;
    color: #c62828;
}

.btn-sm.btn-danger:hover {
    background-color: #ffebee;
}

/* Login */
.login-body {
    background: radial-gradient(circle at top left, #1e88e5 0, #0d47a1 35%, #263238 100%);
    color: #eceff1;
    min-height: 100vh;
}

.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background-color: rgba(255,255,255,0.98);
    border-radius: 18px;
    padding: 24px 22px 26px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.35);
    color: #263238;
}

.login-card__header {
    text-align: center;
    margin-bottom: 16px;
}

.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffca28, #ffb300);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    color: #37474f;
    font-size: 1.6rem;
}

.login-card__header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-card__header p {
    font-size: 0.9rem;
    color: #607d8b;
}

.login-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #ffebee;
    color: #c62828;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.login-field {
    margin-bottom: 12px;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: #546e7a;
}

.login-field input,
.login-field select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    padding: 8px 10px;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}

.login-input-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    padding: 6px 10px;
    background-color: #fafafa;
}

.login-input-icon i {
    color: #90a4ae;
    font-size: 0.95rem;
}

.login-input-icon input {
    border: none;
    outline: none;
    font-size: 0.9rem;
    flex: 1;
    background: transparent;
    color: #37474f;
}

.login-input-icon input::placeholder {
    color: #b0bec5;
}

.login-btn {
    width: 100%;
    margin-top: 10px;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #1976d2, #42a5f5);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(25, 118, 210, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(25, 118, 210, 0.55);
}

.user-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    text-decoration: none;
    color: #263238;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.user-card__avatar {
    font-size: 1.8rem;
    color: #90a4ae;
}

.user-card__info {
    display: flex;
    flex-direction: column;
}

.user-card__name {
    font-size: 0.95rem;
    font-weight: 500;
}

.user-card__role {
    font-size: 0.8rem;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.user-card:hover {
    background-color: #e3f2fd;
    box-shadow: 0 6px 16px rgba(25,118,210,0.25);
    transform: translateY(-1px);
    border-color: #90caf9;
}

.user-card--selected {
    margin-bottom: 12px;
    background-color: #e3f2fd;
    border-color: #64b5f6;
}

/* Search panel */
.panel--search {
    margin-top: 12px;
}

.search-bar {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid #cfd8dc;
    background-color: #fafafa;
    box-shadow: 0 3px 10px rgba(0,0,0,0.04);
}

.search-bar i {
    color: #90a4ae;
    font-size: 1rem;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
    color: #37474f;
}

.search-input::placeholder {
    color: #b0bec5;
}

.search-clear {
    color: #b0bec5;
    text-decoration: none;
    font-size: 1rem;
}

.search-clear:hover {
    color: #ef5350;
}

.search-actions {
    margin-top: 10px;
}

/* Form grid for producto_nuevo */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
    margin-bottom: 12px;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Responsive */
@media (max-width: 1024px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.sidebar--open {
        transform: translateX(0);
    }
    .topbar__menu-btn {
        display: inline-flex;
    }
    .content {
        padding: 16px;
    }
    .cards {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Mejoras UX de tabla en ventas (columna descripción) ===== */

.table td.descripcion-col,
.table th.descripcion-col {
    max-width: 300px;         /* límite cómodo en desktop */
    width: 300px;
    white-space: normal;      /* permite salto de línea */
    word-wrap: break-word;    /* corta palabras largas */
    vertical-align: top;      /* texto alineado arriba */
}

/* En pantallas medianas (tablet) le damos un poco más de aire */
@media (max-width: 1024px) {
    .table td.descripcion-col,
    .table th.descripcion-col {
        max-width: 180px;
        width: 180px;
    }
}

/* En móvil dejamos que decida el layout + scroll horizontal */
@media (max-width: 768px) {
    .table td.descripcion-col,
    .table th.descripcion-col {
        max-width: 160px;
        width: 160px;
        font-size: 0.8rem;
    }
}

/* ===== UX para filas clickeables en búsqueda de ventas ===== */

/* Cursor pointer en filas de resultados */
.table tbody tr.result-row {
    cursor: pointer;
}

/* Efecto hover suave */
.table tbody tr.result-row:hover {
    background-color: #e8f1ff; /* leve celeste */
    transition: background-color 0.15s ease-in-out;
}

/* ====== Modal genérico (ventas) ====== */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal--open {
    display: flex;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55); /* fondo oscuro */
}

.modal__dialog {
    position: relative;
    z-index: 2001;
    width: 100%;
    max-width: 420px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.35);
    padding: 16px 18px 18px;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.modal__header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #263238;
}

.modal__header i {
    color: #1976d2;
}

.modal__close {
    border: none;
    background: none;
    font-size: 1.1rem;
    color: #90a4ae;
    cursor: pointer;
}

.modal__close:hover {
    color: #ef5350;
}

.modal__body {
    font-size: 0.9rem;
    color: #37474f;
    margin-bottom: 12px;
}

.modal__product-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.modal__product-stock {
    font-size: 0.85rem;
    color: #607d8b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.modal__product-stock i {
    color: #90a4ae;
}

.modal__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal__field label {
    font-size: 0.85rem;
    color: #546e7a;
}

.modal__field input[type="number"] {
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    width: 120px;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* Responsive modal */
@media (max-width: 480px) {
    .modal__dialog {
        margin: 0 12px;
        padding: 14px 14px 16px;
    }
}

/* Filas clickeables en Ventas del día */
.table tbody tr.venta-row {
    cursor: pointer;
}

.table tbody tr.venta-row:hover {
    background-color: #e8f1ff;
    transition: background-color 0.15s ease-in-out;
}

.card--warning {
    background: linear-gradient(135deg, #ffb300, #ffca28);
}

.card--warning .card__icon {
    background: rgba(255,255,255,0.25);
}

.card--warning .card__body h4,
.card--warning .card__value,
.card--warning .card__subtitle {
    color: #fff;
}

/* Panel más angosto para formularios simples (como servicios) */
.panel--narrow {
    max-width: 720px;
    margin: 0 auto;
}

/* Variante de grid a 2 columnas */
.form-grid--2cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 768px) {
    .panel--narrow {
        max-width: 100%;
    }
    .form-grid--2cols {
        grid-template-columns: 1fr;
    }
}

/* Inputs y textarea dentro de panel (misma estética para TODOS los formularios) */
.panel input[type="text"],
.panel input[type="number"],
.panel input[type="date"],
.panel input[type="datetime-local"],
.panel textarea,
.panel select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    background-color: #ffffff;
}

.panel input[type="text"]:focus,
.panel input[type="number"]:focus,
.panel input[type="date"]:focus,
.panel input[type="datetime-local"]:focus,
.panel textarea:focus,
.panel select:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.12);
}

/* Etiquetas en formularios dentro de panel */
.panel label {
    font-size: 0.9rem;
    color: #455a64;
}

/* ===========================================
   ALERTA VISUAL PARA STOCK BAJO (SIN HOVER)
   =========================================== */

/* 🔥 Estilo del card en alerta (cuando hay stock bajo) */
.card--danger.card--blink {
    animation: stockBlink 1.3s ease-in-out infinite;
    position: relative;
}

/* 🔥 ANIMACIÓN ÚNICA DE ALERTA */
@keyframes stockBlink {
    0% {
        background: linear-gradient(135deg, #e53935, #c62828);
        box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.3);
        transform: scale(1);
    }
    50% {
        background: linear-gradient(135deg, #ff6363, #e53935);
        box-shadow: 0 0 18px 6px rgba(255, 99, 99, 0.9);
        transform: scale(1.04);
    }
    100% {
        background: linear-gradient(135deg, #e53935, #c62828);
        box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.3);
        transform: scale(1);
    }
}