/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

:root {
    --primary-color: #0056b3;
    --primary-hover: #004494;
    --background-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #777777;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3 {
    font-weight: 800;
    color: var(--text-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.btn {
    display: inline-block;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

/* Turnero Specific */
.turnero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.service-btn {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 3rem 1rem;
    font-size: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.service-btn:hover {
    background: var(--primary-color);
    color: white;
}

.big-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.ticket-number {
    font-size: 5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 1rem 0;
    display: block;
}

/* Recepcion Specific */
.dashboard-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

.queue-list {
    max-height: 70vh;
    overflow-y: auto;
}

.queue-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-item.active {
    background-color: #e3f2fd;
    border-left: 4px solid var(--primary-color);
}

.control-panel {
    text-align: center;
    padding: 3rem;
}

.current-turn-display-small {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 2rem;
}

/* Pantalla Specific */
.screen-layout {
    display: grid;
    grid-template-columns: 6fr 4fr;
    flex: 1 1 auto;
    /* Crece para llenar el espacio sobre la publicidad */
    min-height: 0;
    overflow: hidden;
}

/* Área principal: turno actual ocupa toda la altura del screen-layout */
.main-content-area {
    background: #1a1a2e;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* El turno actual llena toda el área */
.main-display {
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
}

.main-display h2 {
    color: rgba(255, 255, 255, 0.8);
    font-size: 3rem;
    margin-top: 1rem;
}

.main-display .big-number {
    font-size: 10rem;
    font-weight: 800;
    line-height: 1;
}

.main-display .service-name {
    font-size: 3rem;
    font-weight: 600;
    margin-top: 0.5rem;
}



/* ---- SIDEBAR (Últimos Llamados) - ahora más ancho y prominente ---- */
.sidebar-list {
    background: #0d1b2a;
    /* Fondo oscuro elegante para resaltar */
    padding: 1.5rem 1.2rem;
    border-left: 4px solid var(--primary-color);
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.sidebar-list>h3 {
    color: rgba(255, 255, 255, 0.9) !important;
    border-bottom-color: rgba(255, 255, 255, 0.2) !important;
    text-align: center;
    font-size: 1.3rem !important;
    letter-spacing: 1px;
    padding-bottom: 0.8rem;
    margin-bottom: 0.5rem !important;
}

.sidebar-item {
    background: rgba(255, 255, 255, 0.07);
    margin-bottom: 0;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    border-left: 6px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.2s ease;
}

.sidebar-item:first-child {
    transform: scale(1.03);
    border-left-color: #e74c3c;
    background: rgba(231, 76, 60, 0.18);
}

.sidebar-item .num {
    font-size: 3.2rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
}

.sidebar-item .srv {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
    font-weight: 600;
}

/* Pr\u00f3ximos en espera: borde dorado y fondo m\u00e1s tenue */
.sidebar-item--pending {
    border-left-color: rgba(255, 215, 0, 0.7);
    background: rgba(255, 255, 255, 0.04) !important;
    opacity: 0.88;
}

.sidebar-item--pending .num {
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-item--pending .srv {
    color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   TV VERTICAL (Portrait) - Orientación Portrait
   Se activa cuando la altura > ancho (ej: TV girado 90°)
   ============================================ */
@media screen and (orientation: portrait) {

    /* Cambiar de columnas a filas: turno arriba, historial abajo */
    .screen-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 62vh 38vh;
        height: 100vh;
        overflow: hidden;
    }

    .main-content-area {
        height: 100%;
        width: 100%;
    }

    /* Sidebar pasa a estar abajo con scroll horizontal de items */
    .sidebar-list {
        border-left: none;
        border-top: 5px solid #eee;
        padding: 1rem 1.5rem;
        overflow-y: hidden;
        overflow-x: hidden;
        /* Layout horizontal para los items en portrait */
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 1rem;
    }

    /* Título del sidebar en portrait */
    .sidebar-list>h3 {
        writing-mode: horizontal-tb;
        text-align: left;
        border-bottom: none;
        border-right: 2px solid #ddd;
        padding-right: 1rem;
        padding-bottom: 0;
        margin-bottom: 0 !important;
        margin-right: 0.5rem;
        flex-shrink: 0;
        font-size: 1.1rem !important;
        min-width: 100px;
    }

    /* Items del historial en fila horizontal */
    .sidebar-item {
        flex-shrink: 0;
        margin-bottom: 0;
        min-width: 130px;
        padding: 0.7rem 1rem;
    }

    .sidebar-item:first-child {
        transform: scale(1.04);
    }

    /* Pr\u00f3ximos en espera en portrait */
    .sidebar-item--pending {
        opacity: 0.85;
        border-left-color: rgba(255, 215, 0, 0.6);
        background: rgba(255, 255, 255, 0.04) !important;
    }

    .sidebar-item .num {
        font-size: 2.2rem;
    }

    .sidebar-item .srv {
        font-size: 1rem;
    }

    /* Turno actual: fuentes más grandes para aprovechar el ancho */
    .main-display .big-number {
        font-size: 18vw;
    }

    .main-display h2 {
        font-size: 5vw;
    }

    .main-display .service-name {
        font-size: 4vw !important;
    }

    /* Nombre del cliente más grande */
    #mainClientName {
        font-size: 6vw !important;
    }

    /* Módulo */
    #mainModule {
        font-size: 8vw !important;
    }
}

/* ============================================
   RESPONSIVE - Tablets (≤900px)
   ============================================ */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .queue-list {
        max-height: 40vh;
    }

    .screen-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 70vh 30vh;
        height: auto;
        overflow: auto;
    }

    .sidebar-list {
        border-left: none;
        border-top: 4px solid #eee;
        overflow-y: auto;
    }

    .main-display .big-number {
        font-size: 7rem;
    }
}

/* ============================================
   RESPONSIVE - Móviles (≤600px)
   ============================================ */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .header {
        margin-bottom: 1.5rem;
        padding: 1rem 0;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    /* Header con botones: apilar en móvil */
    .header>div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 8px;
    }

    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.95rem;
    }

    /* Turnero: inputs y botones al 100% */
    .container input[type="text"],
    .container textarea {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 1rem !important;
    }

    .container button.btn[style*="font-size: 1.2rem"] {
        width: 100%;
    }

    /* Grid de servicios: 1 columna */
    .turnero-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .service-btn {
        padding: 1.5rem 1rem;
        font-size: 1.1rem;
    }

    .big-icon {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    /* Recepción: panel de control con menos padding */
    .control-panel {
        padding: 1.5rem 1rem;
    }

    .ticket-number {
        font-size: 3.5rem;
    }

    /* Cola de turnos: ajustar altura */
    .queue-list {
        max-height: 35vh;
    }

    /* Queue item: apilar contenido y botón verticalmente */
    .queue-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .queue-item .btn {
        width: 100%;
        text-align: center;
    }

    /* Pantalla pública: ocultar sidebar en móvil o reducirla */
    .screen-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 65vh auto;
        height: auto;
        overflow-y: auto;
    }

    .sidebar-list {
        padding: 1rem;
        overflow-y: auto;
        max-height: 35vh;
    }

    .main-display .big-number {
        font-size: 5rem;
    }

    .main-display h2 {
        font-size: 1.8rem;
    }

    .sidebar-item .num {
        font-size: 2rem;
    }

    .sidebar-item .srv {
        font-size: 1rem;
    }

    /* Modal */
    .modal-content {
        padding: 1.5rem;
    }

    /* Admin: ocultar overflow de tablas */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}