/* =====================================================================
 * PROYECTO BILLAR ERP - SISTEMA DE ESTILOS MODULAR Y ADAPTATIVO (style.css)
 * ===================================================================== */

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #1e1e2f 0%, #0f172a 100%);
    color: #f8fafc;
    min-height: 100vh;
    padding: 15px;
}

/* LOGIN SCREEN */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    background: linear-gradient(135deg, #0f172a 0%, #1e1e2f 100%);
}

.login-screen.hidden {
    display: none;
}

.login-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 420px;
    width: 90%;
    animation: slideIn 0.4s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #38bdf8;
    font-size: 2.2em;
    margin-bottom: 8px;
}

.login-icon {
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    margin: 0 auto 20px;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

/* BADGES */
.user-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 8px;
}

.user-badge.admin {
    background: #f59e0b;
    color: #1e1e2f;
}

.user-badge.employee {
    background: #10b981;
    color: #ffffff;
}

/* CONTAINER & LAYOUT */
.container {
    max-width: 1450px;
    margin: 0 auto;
    display: none;
}

.container.active {
    display: block;
}

.header {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    padding: 20px 25px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left img.local-logo {
    max-height: 55px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 8px;
}

.header-left h1 {
    color: #38bdf8;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    text-align: right;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.connection-status.connected {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

/* NAVIGATION TABS */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(30, 41, 59, 0.6);
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* TAB CONTENT SECTIONS */
.tab-content {
    display: none !important;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block !important;
}

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

/* GRIDS & CARDS */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.card {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-icon {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.card-title {
    font-size: 1.35em;
    color: #f8fafc;
    font-weight: 700;
}

/* TABLES GRID (MESAS) */
.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.table-item {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 18px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    color: white;
    position: relative;
    overflow: hidden;
}

.table-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
    border-color: #6366f1;
}

.table-item.occupied {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    box-shadow: 0 8px 20px rgba(225, 29, 72, 0.4);
    border: none;
}

.table-item.restricted {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(80%);
}

.table-number {
    font-size: 1.8em;
    font-weight: 800;
    margin-bottom: 2px;
}

.table-rate-tag {
    font-size: 0.78em;
    color: #38bdf8;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 6px;
}

.table-item.occupied .table-rate-tag {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.3);
}

.table-status {
    font-size: 0.85em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-time {
    font-size: 1.15em;
    margin-top: 8px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 8px;
    border-radius: 8px;
}

/* FORMS & INPUTS */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: #cbd5e1;
    font-size: 0.9em;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    font-size: 0.95em;
    color: #f8fafc;
    transition: border-color 0.2s ease;
}

.form-group input[type="checkbox"] {
    width: auto !important;
    height: 18px !important;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

/* BUTTONS */
.btn {
    padding: 11px 22px;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: #334155;
    color: #f8fafc;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.25);
    padding: 8px 16px;
}

/* DATA TABLES */
.custom-table-wrapper {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92em;
}

.custom-table th {
    background: #1e293b;
    color: #94a3b8;
    padding: 14px 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.custom-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

/* STOCK BADGES */
.stock-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.82em;
    font-weight: 700;
}

.stock-badge.ok {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.stock-badge.low {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.stock-badge.out {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

/* STATS CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 18px;
    text-align: center;
}

.stat-value {
    font-size: 1.7em;
    font-weight: 800;
    color: #38bdf8;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85em;
    color: #94a3b8;
}

/* MODALS */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 30px;
    max-width: 750px;
    width: 94%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: slideIn 0.3s ease;
}

.modal-header {
    font-size: 1.6em;
    color: #f8fafc;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ALERTS */
.alert {
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9em;
    line-height: 1.5;
}

.alert-info {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.admin-only:not(.tab-content) {
    display: none;
}

.admin-only.visible:not(.tab-content) {
    display: block;
}

/* TICKET EN PANTALLA */
.ticket-box {
    background: #ffffff;
    color: #000000;
    padding: 25px;
    border-radius: 10px;
    font-family: 'Segoe UI', Arial, sans-serif;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-width: 380px;
    margin: 0 auto;
    line-height: 1.5;
    text-align: left;
}

.ticket-header-logo {
    text-align: center;
    margin-bottom: 12px;
}

.ticket-header-logo img {
    max-height: 75px;
    max-width: 170px;
    object-fit: contain;
    margin-bottom: 6px;
}

.ticket-header-logo h2 {
    font-size: 1.3em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    color: #000;
}

.ticket-box p {
    font-size: 0.92em;
    margin-bottom: 4px;
}

.ticket-total-main {
    font-size: 1.3em;
    font-weight: 800;
    margin-top: 14px;
    margin-bottom: 14px;
}

.ticket-divider {
    border-bottom: 1px dashed #444444;
    margin: 12px 0;
}

.ticket-products-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.ticket-products-list li {
    font-size: 0.93em;
    margin-bottom: 4px;
}

.ticket-footer-legend {
    text-align: center;
    font-size: 0.88em;
    font-style: italic;
    margin-top: 12px;
    color: #333333;
}

/* REPORTE HOJA CARTA EN PANTALLA PREVIA */
.pdf-report-preview {
    background: #ffffff;
    color: #000000;
    padding: 25px;
    border-radius: 8px;
    font-family: Arial, Helvetica, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.4;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

/* ESTILOS EXCLUSIVOS DE IMPRESIÓN SOBERANA (HOJA CARTA SIN TRASLAPOS) */
@media screen {
    #printArea {
        display: none !important;
    }
}

@page {
    size: letter portrait;
    margin: 12mm 15mm 15mm 15mm;
}

@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
        margin: 0 !important;
        font-family: Arial, Helvetica, sans-serif !important;
    }

    body > *:not(#printArea) {
        display: none !important;
    }

    #printArea {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .letter-report {
        width: 100% !important;
        color: #000000 !important;
        font-size: 11pt !important;
        line-height: 1.35 !important;
    }

    .letter-report table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 15px !important;
        page-break-inside: auto !important;
    }

    .letter-report tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }

    .letter-report th {
        background-color: #1e293b !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        padding: 6px 8px !important;
        font-size: 9.5pt !important;
        text-align: left !important;
        border: 1px solid #334155 !important;
    }

    .letter-report td {
        padding: 6px 8px !important;
        font-size: 9.5pt !important;
        border-bottom: 1px solid #cbd5e1 !important;
        color: #000000 !important;
    }

    .letter-summary-grid {
        display: table !important;
        width: 100% !important;
        margin-bottom: 15px !important;
        border: 1px solid #cbd5e1 !important;
        background-color: #f8fafc !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .letter-summary-col {
        display: table-cell !important;
        width: 25% !important;
        padding: 10px !important;
        text-align: center !important;
        border-right: 1px solid #cbd5e1 !important;
    }
}
