/* -------------------------------------------------------------
 * style.css
 * Estilos CSS para la PWA de Lista de Compras del Restaurante Alberca
 * ------------------------------------------------------------- */

/* variables de diseño */
:root {
    --bg-dark: #131313;
    --bg-darker: #0a0a0a;
    --bg-light-dark: #1e1d1d;
    --surface-container: #20201f;
    --surface-card: rgba(18, 18, 18, 0.85);
    
    --primary-color: #c8c6c5;
    --text-white: #e5e2e1;
    --text-muted: #a3a3a3;
    
    /* Brasa / Fuego */
    --ember-glow: #B34625;
    --ember-light: rgba(179, 70, 37, 0.15);
    --ember-border: rgba(179, 70, 37, 0.4);
    
    --green-online: #2e7d32;
    --orange-offline: #d84315;
    
    --border-translucent: rgba(226, 226, 222, 0.1);
    --border-focus: rgba(179, 70, 37, 0.6);
    
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-sans: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset y Bases */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(to bottom, #000000 0%, #1A1A1A 60%, #0A0A0A 100%) no-repeat fixed;
    color: var(--text-white);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow-x: hidden;
}

/* Helper para Ocultar */
.hidden {
    display: none !important;
}

.Playfair {
    font-family: var(--font-serif);
}

.Hanken {
    font-family: var(--font-sans);
}

/* -------------------------------------------------------------
 * Contenedor de Dispositivo Móvil (Centrado en Pantallas Grandes)
 * ------------------------------------------------------------- */
.app-wrapper {
    width: 100%;
    max-width: 500px; /* Tamaño máximo tipo teléfono */
    background: rgba(10, 10, 10, 0.5);
    border-left: 1px solid rgba(226, 226, 222, 0.05);
    border-right: 1px solid rgba(226, 226, 222, 0.05);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

/* -------------------------------------------------------------
 * Pantalla de Acceso (Password Gate)
 * ------------------------------------------------------------- */
.gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, #1c1b1b 0%, #0a0a0a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.gate-card {
    background: var(--surface-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-translucent);
    border-radius: 16px;
    padding: 40px 30px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(179, 70, 37, 0.1);
    animation: fadeIn 0.5s ease-out;
}

.gate-title {
    font-size: 2.8rem;
    font-weight: 600;
    color: var(--text-white);
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-shadow: 0 0 15px rgba(255, 90, 0, 0.35);
}

.gate-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 4px;
    margin-bottom: 35px;
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 20px;
}

.gate-form input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-translucent);
    color: var(--text-white);
    padding: 14px 14px 14px 44px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    font-family: var(--font-sans);
}

.gate-form input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 8px rgba(179, 70, 37, 0.2);
    background: rgba(0, 0, 0, 0.6);
}

.error-msg {
    color: #ff8a80;
    font-size: 0.85rem;
    text-align: left;
    padding-left: 5px;
    animation: shake 0.3s ease-in-out;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--ember-glow);
    color: var(--text-white);
}

.btn-primary:active {
    transform: scale(0.97);
    background: #963518;
}

.btn-glow {
    box-shadow: 0 0 15px rgba(179, 70, 37, 0.4);
}

.btn-glow:hover {
    box-shadow: 0 0 25px rgba(179, 70, 37, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-translucent);
    color: var(--text-white);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.97);
}

.btn-full {
    width: 100%;
}

/* -------------------------------------------------------------
 * Cabecera de la Aplicación
 * ------------------------------------------------------------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-translucent);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-white);
}

.title-glow {
    text-shadow: 0 0 12px rgba(255, 90, 0, 0.4), 0 0 24px rgba(179, 70, 37, 0.2);
}

/* Indicadores y Botones de Cabecera */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-translucent);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.badge-online .badge-dot {
    background-color: var(--green-online);
    box-shadow: 0 0 8px var(--green-online);
}

.badge-offline .badge-dot {
    background-color: var(--orange-offline);
    box-shadow: 0 0 8px var(--orange-offline);
    animation: pulse 1.5s infinite;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-white);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, color 0.3s;
    margin-left: 5px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn.hidden {
    display: none;
}

/* Giro en rotación para refresco */
.rotating {
    animation: rotate 1s linear infinite;
}

/* -------------------------------------------------------------
 * Selector de Sección del Restaurante
 * ------------------------------------------------------------- */
.section-selector-wrapper {
    padding: 14px 20px;
    background: rgba(20, 20, 20, 0.4);
    border-bottom: 1px solid var(--border-translucent);
}

.selector-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 2px;
}

.selector-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.selector-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-translucent);
    color: var(--text-muted);
    padding: 8px 4px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-sans);
    text-align: center;
}

.selector-btn[data-section="Cocina"].active {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.5);
    color: #81c784;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.15);
    font-weight: 600;
}

.selector-btn[data-section="Bar"].active {
    background: rgba(33, 150, 243, 0.15);
    border-color: rgba(33, 150, 243, 0.5);
    color: #64b5f6;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.15);
    font-weight: 600;
}

.selector-btn[data-section="Sala"].active {
    background: rgba(255, 152, 0, 0.15);
    border-color: rgba(255, 152, 0, 0.5);
    color: #ffb74d;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.15);
    font-weight: 600;
}

.selector-btn[data-section="Admin"].active {
    background: rgba(156, 39, 176, 0.15);
    border-color: rgba(156, 39, 176, 0.5);
    color: #ba68c8;
    box-shadow: 0 0 10px rgba(156, 39, 176, 0.15);
    font-weight: 600;
}

.selector-btn[data-section="Cocina"]:hover {
    border-color: rgba(76, 175, 80, 0.3);
}

.selector-btn[data-section="Bar"]:hover {
    border-color: rgba(33, 150, 243, 0.3);
}

.selector-btn[data-section="Sala"]:hover {
    border-color: rgba(255, 152, 0, 0.3);
}

.selector-btn[data-section="Admin"]:hover {
    border-color: rgba(156, 39, 176, 0.3);
}

/* -------------------------------------------------------------
 * Pestañas / Tab Bar Navigation
 * ------------------------------------------------------------- */
.app-tabs {
    display: flex;
    background: rgba(15, 15, 15, 0.6);
    border-bottom: 1px solid var(--border-translucent);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 14px 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: var(--font-sans);
    position: relative;
}

.tab-icon {
    font-size: 20px;
}

.tab-btn.active {
    color: var(--text-white);
    border-bottom-color: var(--ember-glow);
    background: rgba(179, 70, 37, 0.03);
}

.tab-badge {
    background: var(--ember-glow);
    color: var(--text-white);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    display: inline-block;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 0 5px rgba(179, 70, 37, 0.5);
    transition: transform 0.2s ease;
}

.tab-badge:empty, .tab-badge[data-count="0"] {
    display: none;
}

/* -------------------------------------------------------------
 * Contenedor del Panel
 * ------------------------------------------------------------- */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
}

.tab-panel.active {
    display: flex;
}

.panel-info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-translucent);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.panel-info-banner span.material-symbols-outlined {
    font-size: 18px;
    color: var(--ember-glow);
}

/* Formulario de Adición */
.add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.add-form input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-translucent);
    color: var(--text-white);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    font-family: var(--font-sans);
}

.add-form input:focus {
    border-color: var(--border-focus);
    background: rgba(0, 0, 0, 0.5);
}

.add-btn {
    width: 46px;
    height: 46px;
    background: var(--ember-glow);
    color: var(--text-white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(179, 70, 37, 0.3);
    transition: all 0.3s;
}

.add-btn:active {
    transform: scale(0.93);
    background: #963518;
}

/* -------------------------------------------------------------
 * Listas de Artículos
 * ------------------------------------------------------------- */
.list-section {
    margin-bottom: 25px;
}

.items-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Elemento de lista */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-translucent);
    border-radius: 8px;
    padding: 12px 14px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: slideIn 0.3s ease-out;
}

.list-item:hover {
    border-color: rgba(226, 226, 222, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

/* Checkbox personalizado */
.checkbox-container {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    color: transparent;
}

.custom-checkbox span {
    font-size: 14px;
    font-weight: 700;
}

/* Estado seleccionado */
.list-item.checked .custom-checkbox {
    border-color: var(--ember-glow);
    background: var(--ember-glow);
    color: var(--text-white);
    box-shadow: 0 0 8px rgba(179, 70, 37, 0.4);
}

/* Texto del artículo */
.item-text-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* Permite truncado de texto */
}

.item-text {
    font-size: 0.95rem;
    color: var(--text-white);
    word-break: break-word;
    transition: all 0.3s ease;
}

.list-item.checked .item-text {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Firma / Creador */
.item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-creator {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(226, 226, 222, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--primary-color);
}

.list-item.checked .item-creator {
    opacity: 0.5;
}

/* Botón de Borrado */
.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0.6;
}

.delete-btn span {
    font-size: 20px;
}

.delete-btn:hover {
    color: #ff8a80;
    background: rgba(255, 138, 128, 0.1);
    opacity: 1;
}

.delete-btn:active {
    transform: scale(0.9);
}

/* Sección de completados */
.completed-section {
    border-top: 1px solid var(--border-translucent);
    padding-top: 20px;
    margin-top: 10px;
}

.section-header {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
}

/* Estado Vacío */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    color: rgba(255, 255, 255, 0.07);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 250px;
}

/* Acciones inferiores */
.panel-actions {
    margin-top: auto;
    padding-top: 20px;
}

/* -------------------------------------------------------------
 * Pie de página de la aplicación
 * ------------------------------------------------------------- */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-translucent);
    background: rgba(10, 10, 10, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    letter-spacing: 1px;
}

.logo-text {
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-white);
}

.footer-separator {
    color: var(--ember-glow);
}

/* -------------------------------------------------------------
 * Animaciones Keyframes
 * ------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* -------------------------------------------------------------
 * Estilos para el Panel de Avisos y Formulario
 * ------------------------------------------------------------- */
.add-form-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-translucent);
    border-radius: 12px;
    padding: 14px;
}

.add-form-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.add-form-row input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-translucent);
    color: var(--text-white);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    font-family: var(--font-sans);
}

.add-form-row input:focus {
    border-color: var(--border-focus);
    background: rgba(0, 0, 0, 0.5);
}

.chips-row {
    align-items: center;
    justify-content: space-between;
}

.chips-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.marca-chips {
    display: flex;
    gap: 6px;
}

.marca-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-translucent);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.marca-chip.active {
    background: var(--ember-light);
    border-color: var(--ember-border);
    color: var(--text-white);
    font-weight: 600;
    box-shadow: 0 0 8px rgba(179, 70, 37, 0.15);
}

.aviso-item {
    align-items: flex-start;
}

.aviso-icon-container {
    color: var(--ember-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.aviso-icon {
    font-size: 22px;
}

.aviso-marca-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

/* Colores para las etiquetas de departamento */
.marca-cocina {
    background: rgba(76, 175, 80, 0.1);
    color: #81c784;
    border-color: rgba(76, 175, 80, 0.2);
}

.marca-bar {
    background: rgba(33, 150, 243, 0.1);
    color: #64b5f6;
    border-color: rgba(33, 150, 243, 0.2);
}

.marca-sala {
    background: rgba(255, 152, 0, 0.1);
    color: #ffb74d;
    border-color: rgba(255, 152, 0, 0.2);
}

.marca-admin {
    background: rgba(156, 39, 176, 0.1);
    color: #ba68c8;
    border-color: rgba(156, 39, 176, 0.2);
}

.aviso-date {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Optimizaciones táctiles específicas para PWA */
@media (max-width: 500px) {
    body {
        background: #000000;
    }
    
    .app-wrapper {
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
}
