/* ============================================
   Xtorm - PWA Cliente
   Paleta basada en logo: naranja + negro + blanco
   ============================================ */

:root {
    /* Colores primarios (logo) */
    --color-primary:        #FE4F03;
    --color-primary-light:  #FF6216;
    --color-primary-dark:   #C93A00;
    --color-accent:         #000000;

    /* Superficies */
    --color-bg:             #F7F7F8;
    --color-surface:        #FFFFFF;
    --color-border:         #E5E5E7;
    --color-border-strong:  #D1D1D4;

    /* Texto */
    --color-text:           #0A0A0A;
    --color-text-secondary: #5C5C5F;
    --color-text-muted:     #9A9A9E;
    --color-text-inverse:   #FFFFFF;

    /* Estados */
    --color-success:        #16A34A;
    --color-danger:         #DC2626;
    --color-warning:        #F59E0B;
    --color-info:           #2563EB;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow:    0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

    /* Radios */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   AUTH (login + register)
   ============================================ */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #000000;
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-xl);
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px;
    border-radius: 24px;
}

.auth-logo p {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    color: var(--color-text);
}

/* ============================================
   FORM
   ============================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(254, 79, 3, 0.1);
}

.form-input:disabled {
    background: var(--color-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    box-shadow: 0 4px 12px rgba(254, 79, 3, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    box-shadow: 0 6px 16px rgba(254, 79, 3, 0.4);
}

.btn-primary:disabled {
    background: var(--color-primary);
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(254, 79, 3, 0.05);
}

.btn-dark {
    background: var(--color-accent);
    color: var(--color-text-inverse);
}

.btn-dark:hover:not(:disabled) {
    background: #1a1a1a;
}

.btn-link {
    background: transparent;
    color: var(--color-primary);
    padding: 8px;
    font-size: 14px;
    text-decoration: underline;
    width: auto;
    font-weight: 600;
}

/* ============================================
   MENSAJES
   ============================================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
    font-weight: 500;
}

.alert.visible {
    display: block;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid var(--color-danger);
}

.alert-success {
    background: #DCFCE7;
    color: #166534;
    border-left: 4px solid var(--color-success);
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border-left: 4px solid var(--color-info);
}

/* ============================================
   FOOTER DEL AUTH
   ============================================ */

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ============================================
   PWA: BOTÓN INSTALAR (esquina inferior derecha)
   ============================================ */

.pwa-install-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9999;

    display: flex;
    align-items: center;
    gap: 6px;

    padding: 10px 18px;
    border: none;
    border-radius: 50px;

    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    box-shadow: 0 6px 20px rgba(254, 79, 3, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(254, 79, 3, 0.5);
}

.pwa-install-btn:active {
    transform: scale(0.98);
}

/* ============================================
   PWA: MODAL INSTRUCCIONES iOS/Mac
   ============================================ */

.pwa-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;

    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pwa-modal {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);

    animation: slideUp 0.3s ease;
}

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

.pwa-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
}

.pwa-modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.pwa-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pwa-modal-close:hover {
    background: var(--color-border);
}

.pwa-modal-body {
    padding: 0 20px 24px;
}

.pwa-modal-intro {
    font-size: 15px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.pwa-modal-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.pwa-modal-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.pwa-modal-steps li:last-child {
    border-bottom: none;
}

.modal-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 700;
    border-radius: 50%;
}

.modal-icon {
    display: inline-block;
    color: var(--color-primary);
    font-weight: 700;
    margin: 0 2px;
}

.pwa-modal-note {
    font-size: 13px;
    color: var(--color-text-muted);
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}

/* ============================================
   APP: HEADER
   ============================================ */

.app-body {
    background: var(--color-bg);
    padding-bottom: 24px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 12px 16px;
    background: #000000;
    color: var(--color-text-inverse);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.app-header-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}

.app-header-info {
    flex: 1;
    min-width: 0;
}

.app-header-greeting {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.2;
}

.app-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-inverse);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.app-header-logout {
    flex-shrink: 0;
    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-inverse);

    cursor: pointer;
    transition: background 0.2s;
}

.app-header-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

.app-header-logout:active {
    transform: scale(0.95);
}

/* ============================================
   APP: MAIN
   ============================================ */

.app-main {
    padding: 20px 16px;
    max-width: 640px;
    margin: 0 auto;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
}

/* ============================================
   APP: STATES (loading, empty, error)
   ============================================ */

.state-loading,
.state-empty,
.state-error {
    text-align: center;
    padding: 48px 20px;
    color: var(--color-text-secondary);
}

.state-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.state-empty-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.state-empty h2,
.state-error h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.state-empty p,
.state-error p {
    font-size: 14px;
    color: var(--color-text-secondary);
    max-width: 320px;
    margin: 0 auto 16px;
}

.state-error .btn {
    max-width: 200px;
    margin: 0 auto;
}

/* ============================================
   APP: LISTA DE RESTAURANTES
   ============================================ */

.restaurantes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.restaurante-card {
    display: flex;
    gap: 14px;

    padding: 14px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;

    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

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

.restaurante-card:active {
    transform: scale(0.99);
}

.restaurante-logo {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.restaurante-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.restaurante-logo-placeholder {
    font-size: 32px;
    color: var(--color-text-muted);
}

.restaurante-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.restaurante-nombre {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.restaurante-descripcion {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.restaurante-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.restaurante-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.restaurante-rating {
    color: var(--color-warning);
    font-weight: 600;
}

.restaurante-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.restaurante-status.abierto {
    background: #DCFCE7;
    color: #166534;
}

.restaurante-status.cerrado {
    background: #FEE2E2;
    color: #991B1B;
}

.restaurante-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .auth-card {
        padding: 24px 20px;
    }

    .auth-logo img {
        width: 110px;
        height: 110px;
        border-radius: 20px;
    }

    .page-title {
        font-size: 22px;
    }

    .restaurante-logo {
        width: 64px;
        height: 64px;
    }
}