/* =======================================================
   FUENTE
======================================================= */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* =======================================================
   VARIABLES BASE
======================================================= */
:root {
    --color-bg: #f2f4f8;
    --color-text: #1c2333;
    --color-text-soft: #667085;

    --sidebar-bg1: #1a2440;
    --sidebar-bg2: #0d1526;

    --primary: #2f6fed;
    --primary-dark: #1f56c9;
    --primary-light: #eaf1ff;
    --success: #16a34a;
    --success-light: #e8f8ee;
    --danger: #e53935;
    --danger-light: #fdecea;
    --warning: #f59e0b;
    --warning-light: #fff4e0;
    --purple: #8b5cf6;
    --purple-light: #f2ecfe;

    --table-head: #2f6fed;

    --card-bg: #ffffff;
    --modal-bg: #ffffff;
    --input-bg: #ffffff;
    --border-color: #e4e8f0;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 3px rgba(20, 30, 60, 0.06);
    --shadow-md: 0 6px 18px rgba(20, 30, 60, 0.08);
    --shadow-lg: 0 15px 35px rgba(20, 30, 60, 0.12);

    --smooth: 0.2s ease;
}

/* =======================================================
   RESET Y ESTILOS GENERALES
======================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    display: flex;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

h1 { font-size: 1.6em; margin-bottom: 6px; }

p { color: var(--color-text-soft); }

.hidden {
    display: none !important;
}

/* =======================================================
   SCROLLBAR PREMIUM
======================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c3cbdb;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* =======================================================
   LAYOUT PRINCIPAL (SIDEBAR Y CONTENIDO)
======================================================= */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg1), var(--sidebar-bg2));
    color: white;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    transition: var(--smooth);
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar h2 {
    text-align: center;
    margin-bottom: 4px;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #ffffff;
    padding: 0 15px;
}

.sidebar ul {
    list-style: none;
    padding: 0 12px;
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar ul li {
    padding: 13px 16px;
    cursor: pointer;
    border-radius: 10px;
    transition: var(--smooth);
    font-size: 15px;
    font-weight: 500;
    color: #cbd4e8;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
}

.sidebar ul li:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

.sidebar ul li.active {
    background: rgba(47, 111, 237, 0.18);
    color: #ffffff;
    border-left: 3px solid var(--primary);
    font-weight: 700;
}

.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background-color: var(--color-bg);
}

.section {
    display: none;
    animation: fadeIn 0.35s ease;
}

.section.visible {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =======================================================
   BOTÓN MENÚ MÓVIL
======================================================= */
#mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    right: 14px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    z-index: 1100;
    box-shadow: var(--shadow-md);
}

/* =======================================================
   TARJETAS / PANELES GENERALES
======================================================= */
.card, .panel {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow var(--smooth), transform var(--smooth);
}

.card {
    padding: 20px;
    border-top: 4px solid var(--primary);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card h3 {
    font-size: 0.95em;
    color: var(--color-text-soft);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card p { color: inherit; }

.card--purple { border-top-color: var(--purple); }
.card--green  { border-top-color: var(--success); background: var(--success-light); }
.card--orange { border-top-color: var(--warning); background: var(--warning-light); }
.card--red    { border-top-color: var(--danger); }

.panel {
    padding: 22px;
}

/* =======================================================
   FORMULARIOS Y CAJAS
======================================================= */
.form-box {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.form-box h2, .form-box h4 {
    margin-bottom: 18px;
    color: var(--primary);
    border-bottom: 2px solid var(--color-bg);
    padding-bottom: 12px;
}

.form-row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.88em;
    color: var(--color-text-soft);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    font-size: 15px;
    color: var(--color-text);
    transition: var(--smooth);
}

input::placeholder { color: #a5adc0; }

input:hover, select:hover {
    border-color: #c3cbdb;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.13);
}

input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
    transform: scale(1.15);
}

/* Contenedores pequeños de inputs dentro de tablas (cantidad, precio, descuento) */
.mini-input {
    width: 100%;
    padding: 7px 6px;
    text-align: center;
    border: 1.5px solid var(--border-color);
    border-radius: 7px;
    font-size: 14px;
    background: var(--input-bg);
    transition: var(--smooth);
}
.mini-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
    outline: none;
}

.mini-select {
    padding: 7px 4px;
    border: 1.5px solid var(--border-color);
    border-radius: 7px;
    font-size: 13px;
    background: var(--input-bg);
    text-align: center;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color);
    background: #f5f7fb;
    color: var(--color-text);
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--smooth);
}
.qty-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

.discount-cell {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

.discount-applied-tag {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--danger);
    margin-top: 3px;
}

/* =======================================================
   BOTONES
======================================================= */
button {
    cursor: pointer;
    font-family: inherit;
    transition: var(--smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 11px 22px;
    font-size: 15px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(47, 111, 237, 0.28);
}

.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(47, 111, 237, 0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: #eef1f7;
    color: #3b4257;
    border: 1.5px solid var(--border-color);
    padding: 10px 20px;
    font-size: 15px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.btn-secondary:hover { background: #e2e6f0; }

.btn-editar {
    background: var(--warning);
    color: white;
    border: none;
    padding: 7px 13px;
    border-radius: 7px;
    font-size: 0.85em;
    font-weight: 600;
}

.btn-editar:hover { filter: brightness(0.93); }

.btn-eliminar {
    background: var(--danger);
    color: white;
    border: none;
    padding: 7px 13px;
    border-radius: 7px;
    font-size: 0.85em;
    font-weight: 600;
}

.btn-eliminar:hover { filter: brightness(0.93); }

/* =======================================================
   TABLAS RESPONSIVAS
======================================================= */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
}

.data-table thead {
    background: var(--table-head);
    color: white;
}

.data-table th {
    font-weight: 700;
    font-size: 0.85em;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.data-table th, .data-table td {
    padding: 13px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--smooth);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover {
    background-color: var(--primary-light);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
}

.table-responsive .data-table {
    min-width: 600px;
}

/* =======================================================
   MÓDULO DE CAJA (PUNTO DE VENTA) Y SUGERENCIAS
======================================================= */
.pos-search-container {
    position: relative;
    width: 100%;
}

.sugerencias-box {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    box-shadow: var(--shadow-lg);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1050;
}

.sugerencias-box div {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
    cursor: pointer;
}

.sugerencias-box div:hover {
    background: var(--primary-light);
}

.sugerencias-box div:last-child {
    border-bottom: none;
}

/* Caja de resumen de totales del POS */
.pos-summary-box {
    background: #f7f9fc;
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.pos-discount-toggle {
    background: var(--warning-light) !important;
    color: #b45309 !important;
    border: 1px solid #fde3b0 !important;
}

.pos-discount-box {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    background: #fff8e9;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid #fde3b0;
}

.pos-line-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95em;
    color: var(--color-text-soft);
}

.pos-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    border-top: 1px dashed #c3cbdb;
    padding-top: 12px;
}

.pos-total-row p {
    font-size: 1.9em;
    font-weight: 800;
    color: var(--primary);
}

/* =======================================================
   MODALES
======================================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 20, 35, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: white;
    padding: 26px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 420px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box h2 { color: var(--primary); margin-bottom: 14px; }

/* =======================================================
   ESTILOS PARA IMPRIMIR (PDF Y TICKET FÍSICO)
======================================================= */
@media print {
    @page { margin: 0; }
    body { margin: 0; background: white; }
    body * { visibility: hidden; }

    #modal-ticket, #modal-ticket * { visibility: visible; }

    #modal-ticket {
        position: absolute; left: 0; top: 0; width: 100%;
        background: white; padding: 20px;
        display: flex; justify-content: center; align-items: flex-start;
    }

    #modal-ticket > div {
        box-shadow: none !important;
        width: 80mm !important;
        max-width: 100% !important;
        margin: 0 auto; padding: 0; border-radius: 0;
        color: black;
    }

    .btn-secondary, .btn-primary, #btn-imprimir-ticket { display: none !important; }
}

/* =======================================================
   ADAPTACIÓN PARA MÓVILES (MAGIA RESPONSIVE)
======================================================= */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -270px;
        height: 100%;
    }
    .sidebar.sidebar-open {
        left: 0;
    }
    #mobile-menu-btn {
        display: block;
    }
    .content {
        padding: 64px 14px 20px 14px;
    }

    h1 { font-size: 1.3em; }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    #caja > div {
        flex-direction: column;
    }
    #caja > div > div {
        width: 100%;
        min-width: 100%;
    }

    /* Todo lo que se escribe se agranda y se hace más cómodo de tocar en el celular */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="date"],
    select {
        font-size: 16px; /* evita el zoom automático de iPhone */
        padding: 13px 14px;
    }

    .mini-input {
        font-size: 15px;
        padding: 9px 6px;
    }

    .mini-select {
        font-size: 14px;
        padding: 9px 4px;
    }

    .qty-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        font-size: 17px;
    }

    .btn-primary, .btn-secondary {
        padding: 13px 20px;
        font-size: 15px;
    }

    .form-row-grid {
        grid-template-columns: 1fr;
    }

    .modal-box {
        width: 100%;
        padding: 20px;
    }

    .data-table th, .data-table td {
        padding: 11px 12px;
        font-size: 0.92em;
    }
}

@media (max-width: 480px) {
    .content { padding: 60px 10px 16px 10px; }
    .card, .panel, .form-box { padding: 16px; }
    .pos-total-row p { font-size: 1.6em; }
}
