/* ===== CSS VARIABLES & THEME ===== */
:root {
    /* Colors */
    --primary: #0066f0;
    --primary-dark: #0052c2;
    --primary-light: #e9f0fe;
    --secondary: #6c7a8a;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f9fbfd;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,20,50,0.08);
    --shadow-lg: 0 8px 30px rgba(0,20,50,0.12);
    --shadow-interactive: 0 4px 20px rgba(0,102,240,0.25);
    
    /* Radii */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-full: 9999px;
    
    /* Spacing */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Typography */
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', monospace;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    
    /* Touch targets */
    --touch-min: 44px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --surface-alt: #334155;
        --border: #475569;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --primary-light: #1e3a5f;
    }
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 
            env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== APP CONTAINER ===== */
#app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: relative;
}

@media (min-width: 768px) {
    #app {
        max-width: 520px;
        min-height: 90vh;
        margin: 2vh auto;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        border: 1px solid var(--border);
        overflow: hidden;
    }
}

/* ===== SCREENS ===== */
.screen {
    padding: var(--space-lg) var(--space-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + 70px); /* space for bottom nav */
}

/* ===== TYPOGRAPHY ===== */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

h2 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 1.25rem;
    font-weight: 600;
    padding: var(--space-sm) 0;
    color: var(--text-primary);
}

.section-title i {
    color: var(--primary);
    width: 24px;
    text-align: center;
}

/* ===== LOGO ===== */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
}

.logo i {
    font-size: 2rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
}

.logo h1 span {
    color: var(--primary);
    font-weight: 700;
}

/* ===== FORMS ===== */
form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

input, textarea, select {
    width: 100%;
    padding: var(--space-md);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: var(--touch-min);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Form rows for pass section */
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* ===== BUTTONS ===== */
button, .btn, [role="button"] {
    background: var(--primary);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 1rem;
    min-height: var(--touch-min);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    text-decoration: none;
    width: 100%;
}

button:hover, .btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-interactive);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.btn-secondary:hover {
    background: var(--surface-alt);
    border-color: var(--primary);
}

.btn-small {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.875rem;
    min-height: 36px;
    width: auto;
}

.btn-icon {
    padding: var(--space-xs);
    width: auto;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--primary);
}

.btn-icon:hover {
    background: var(--primary-light);
}

/* ===== CARDS ===== */
.card {
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h3 {
    margin-bottom: var(--space-xs);
}

.card p {
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.card p i {
    color: var(--primary);
    width: 18px;
    text-align: center;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge.waiting, .badge.pending { 
    background: #fef3c7; 
    color: #92400e; 
}
.badge.approved { 
    background: #dcfce7; 
    color: #166534; 
}
.badge.rejected { 
    background: #fee2e2; 
    color: #991b1b; 
}
.badge.guest { 
    background: var(--surface-alt); 
    color: var(--text-secondary); 
}
.badge.employee { 
    background: var(--primary-light); 
    color: var(--primary-dark); 
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-xs) var(--space-sm) calc(var(--space-xs) + env(safe-area-inset-bottom));
    z-index: 100;
    padding-bottom: max(var(--space-xs), env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .bottom-nav {
        max-width: 520px;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-xs);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    transition: color var(--transition-fast);
    flex: 1;
    max-width: 80px;
}

.nav-item i {
    font-size: 1.25rem;
    transition: transform var(--transition-fast);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    font-weight: 600;
}

/* ===== DASHBOARD ===== */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.dashboard-header h2 {
    margin-bottom: var(--space-xs);
}

.dashboard-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: var(--space-xs);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: grid;
    place-items: center;
}

.logout-btn:hover {
    color: var(--danger);
    background: var(--surface-alt);
}

/* ===== SECTION CONTAINER (AJAX) ===== */
.section-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.section-container::-webkit-scrollbar {
    width: 4px;
}

.section-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.loading {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.loading::before {
    content: "";
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== HISTORY ITEMS ===== */
.history-item {
    background: var(--surface);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: box-shadow var(--transition-fast);
}

.history-item:hover {
    box-shadow: var(--shadow-sm);
}

.pass-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
    font-size: 0.9rem;
}

.pass-info span {
    color: var(--text-secondary);
}

.qr-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px dashed var(--border);
}

.qr-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    object-fit: contain;
    background: var(--surface);
}

/* ===== FEEDBACK & REPLIES ===== */
.feedback-item {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.feedback-header {
    padding: var(--space-md);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    align-items: center;
    font-size: 0.875rem;
}

.feedback-header strong {
    color: var(--text-primary);
}

.feedback-header .date {
    color: var(--text-muted);
    margin-left: auto;
}

.feedback-item .theme {
    padding: var(--space-md);
    padding-bottom: 0;
    font-weight: 500;
}

.feedback-item .text {
    padding: 0 var(--space-md) var(--space-md);
    color: var(--text-secondary);
}

.replies {
    margin: 0 var(--space-md) var(--space-md);
    padding: var(--space-md);
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.replies p {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: var(--space-xs);
}

.reply {
    padding: var(--space-sm);
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
    font-size: 0.9rem;
}

.reply:last-child {
    margin-bottom: 0;
}

.reply-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.reply-form {
    padding: 0 var(--space-md) var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.reply-form textarea {
    min-height: 80px;
}

/* ===== ADMIN PANEL ===== */
.admin-screen .screen {
    padding-bottom: var(--space-lg);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.admin-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.admin-header h2 i {
    color: var(--primary);
}

.admin-nav {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    padding: var(--space-sm) 0;
}

.admin-nav a {
    padding: var(--space-xs) var(--space-md);
    background: var(--surface-alt);
    border-radius: var(--radius-full);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--primary);
    color: white;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.admin-table thead {
    background: var(--surface-alt);
}

.admin-table th {
    text-align: left;
    padding: var(--space-md);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.admin-table td {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    color: var(--text-primary);
}

.admin-table tr:hover {
    background: var(--surface-alt);
}

.admin-table select {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.875rem;
    min-height: 36px;
    width: auto;
    max-width: 140px;
}

.status-btn {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
    min-height: 32px;
}

.status-btn.approve {
    background: #dcfce7;
    color: #166534;
}

.status-btn.reject {
    background: #fee2e2;
    color: #991b1b;
}

.status-btn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

/* ===== ALERTS ===== */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    animation: slideIn var(--transition-normal);
}

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

.alert-danger { 
    background: #fef2f2; 
    color: #991b1b; 
    border: 1px solid #fecaca;
}
.alert-success { 
    background: #f0fdf4; 
    color: #166534; 
    border: 1px solid #bbf7d0;
}
.alert-warning { 
    background: #fffbeb; 
    color: #92400e; 
    border: 1px solid #fcd34d;
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-auto { margin-top: auto; }
.hidden { display: none !important; }

/* News date */
.news-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

/* ===== FOCUS STATES FOR ACCESSIBILITY ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Модальное окно для QR */
.qr-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
}
.qr-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.qr-modal .close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

a.phone-link {
    text-decoration: none;
    color: inherit;
    font-weight: normal;
}
a.phone-link:hover {
    text-decoration: underline;
    color: #0066f0; /* или любой акцентный цвет при наведении */
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== DESKTOP ENHANCEMENTS ===== */
@media (min-width: 768px) {
    .screen {
        padding: var(--space-xl);
    }
    
    .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }
    
    /* Subtle hover on nav items */
    .nav-item {
        border-radius: var(--radius-sm);
    }
    
    .nav-item:hover {
        background: var(--surface-alt);
    }
}

/* ===== TABLET LANDSCAPE ===== */
@media (min-width: 1024px) {
    #app {
        max-width: 600px;
    }
}