/* ============== ПЕРЕМЕННЫЕ ============== */
:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #8b5cf6;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --dark-light: #374151;
    --gray: #6b7280;
    --gray-light: #9ca3af;
    --light: #f3f4f6;
    --white: #ffffff;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);
    
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============== БАЗОВЫЕ СТИЛИ ============== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(145deg, #667eea 0%, #764ba2 50%, #7c3aed 100%);
    color: var(--dark);
    position: relative;
    overflow-x: hidden;
}

body[data-theme="immersive"] {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
}

/* Фоновые элементы */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, #667eea 0%, #764ba2 50%, #7c3aed 100%);
    z-index: -2;
}

body[data-theme="immersive"] .bg-gradient {
    background:
        radial-gradient(circle at 12% 18%, rgba(196, 181, 253, 0.42), transparent 22%),
        radial-gradient(circle at 88% 12%, rgba(191, 219, 254, 0.36), transparent 22%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
}

.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
}

body[data-theme="immersive"] .bg-particles {
    display: none;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

.particle:nth-child(1) { top: 20%; left: 10%; animation-duration: 15s; }
.particle:nth-child(2) { top: 60%; left: 80%; width: 8px; height: 8px; animation-duration: 18s; }
.particle:nth-child(3) { top: 80%; left: 30%; width: 4px; height: 4px; animation-duration: 12s; }
.particle:nth-child(4) { top: 30%; left: 70%; width: 10px; height: 10px; animation-duration: 22s; }
.particle:nth-child(5) { top: 70%; left: 20%; width: 5px; height: 5px; animation-duration: 16s; }
.particle:nth-child(6) { top: 40%; left: 40%; width: 7px; height: 7px; animation-duration: 19s; }

@keyframes float {
    from { transform: translateY(100vh) rotate(0deg); }
    to { transform: translateY(-100vh) rotate(360deg); }
}

/* Главный контейнер */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 54.5vh;
}

body[data-theme="immersive"][data-page="app-home"] {
    background:
        radial-gradient(circle at 16% 0%, rgba(167, 139, 250, 0.18), transparent 30%),
        radial-gradient(circle at 86% 10%, rgba(147, 197, 253, 0.16), transparent 28%),
        linear-gradient(180deg, #f9f7ff 0%, #f5f0ff 58%, #ffffff 100%);
}

body[data-theme="immersive"] .main-container {
    position: relative;
    max-width: none;
    margin: 0 26px 0;
    padding: 18px 26px 34px;
    min-height: calc(100vh - 220px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.52);
    box-shadow: 0 28px 60px rgba(76, 29, 149, 0.10);
    overflow: hidden;
}

body[data-theme="immersive"][data-page="app-home"] .main-container {
    margin: 0 52px;
    padding: 0 28px 34px;
    border: 0;
    box-shadow: 0 28px 70px rgba(76, 29, 149, 0.10);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.60), rgba(248, 244, 255, 0.34)),
        url("../images/dashboard-clean-bg.png") center top / cover no-repeat;
}

body[data-theme="immersive"] .main-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 18%, rgba(196, 181, 253, 0.18), transparent 24%),
        radial-gradient(circle at 88% 12%, rgba(191, 219, 254, 0.16), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
    pointer-events: none;
}

body[data-theme="immersive"] .main-container::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 140px;
    background: linear-gradient(
        180deg,
        rgba(248, 244, 255, 0) 0%,
        rgba(248, 244, 255, 0.45) 45%,
        rgba(248, 244, 255, 0.92) 100%
    );
    pointer-events: none;
    z-index: 0;
}

body[data-theme="immersive"] .main-container > * {
    position: relative;
    z-index: 1;
}

body[data-theme="immersive"][data-page="app-home"] .main-container::after {
    display: none;
}

/* Стеклянная карточка */
.glass-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============== Notifications ============== */
.custom-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 320px;
    max-width: 400px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    display: flex;
    align-items: center;
    overflow: hidden;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.custom-notification.show {
    transform: translateX(0);
}

.custom-notification.hide {
    transform: translateX(120%);
}

.notification-icon {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    font-size: 24px;
}

.notification-content {
    flex: 1;
    padding: 12px 15px;
}

.notification-message {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.notification-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    transition: var(--transition);
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
}

.notification-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    animation: progress 5s linear forwards;
}

@keyframes progress {
    from { width: 100%; }
    to { width: 0%; }
}

@media (max-width: 768px) {
    body[data-theme="immersive"] .main-container {
        margin: 0;
        padding: 0;
        border-radius: 0 0 30px 30px;
    }

    body[data-theme="immersive"][data-page="app-home"] .main-container {
        margin: 0 16px;
        padding: 0;
        border-radius: 0;
        background: none;
    }

    .custom-notification {
        left: 16px;
        right: 16px;
        min-width: auto;
    }
}

/* ============== ФОРМА ВХОДА ============== */
.login-container {
    max-width: 480px;
    margin: 20px auto;
    padding: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-xl);
}

.login-container h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--dark);
}

.login-container p {
    color: var(--gray);
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 20px;
}

.login-header h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--dark);
}

/* ============== ИНПУТЫ ============== */
.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 18px;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--light);
    border-radius: var(--radius-lg);
    font-size: 15px;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
    background: white;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.input-group textarea {
    padding: 16px;
    resize: vertical;
}

/* ============== КНОПКИ ============== */
.btn-glow {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px var(--primary);
}

.btn-glow:hover::before {
    left: 100%;
}

.btn-glow:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.access-key-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.access-key-actions .btn-glow {
    flex: 1;
}

.btn-scan-access-key {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-lg);
    background: rgba(124, 58, 237, 0.12);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-scan-access-key:hover {
    background: rgba(124, 58, 237, 0.18);
    transform: translateY(-2px);
}

.btn-outline {
    padding: 12px 24px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* ============== СООБЩЕНИЯ ============== */
.error-message {
    color: var(--danger);
    margin-top: 15px;
    font-size: 14px;
    display: none;
    background: #fee2e2;
    padding: 12px;
    border-radius: var(--radius);
}

.success-message {
    color: var(--success);
    margin-top: 15px;
    font-size: 14px;
    display: none;
    background: #d1fae5;
    padding: 12px;
    border-radius: var(--radius);
}

.admin-link {
    margin-top: 20px;
}

.admin-link a {
    color: var(--gray);
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.admin-link a:hover {
    color: var(--primary);
}

.access-key-scanner-panel {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid rgba(124, 58, 237, 0.14);
    border-radius: var(--radius-xl);
    background: #f8fafc;
}

.access-key-scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.access-key-scanner-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
}

.access-key-scanner-title i {
    color: var(--primary);
}

.access-key-scanner-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: var(--dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.access-key-scanner-close:hover {
    background: rgba(148, 163, 184, 0.28);
}

.access-key-reader {
    width: 100%;
    min-height: 260px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
}

.access-key-reader video {
    width: 100%;
    min-height: 260px;
    max-height: 260px;
    object-fit: contain;
    background: #000;
}

.access-key-scanner-hint {
    margin-top: 12px;
    color: var(--gray);
    font-size: 13px;
    line-height: 1.5;
}

.access-key-scan-result {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
    word-break: break-word;
}

.access-key-scan-result.info {
    background: #dbeafe;
    color: #1d4ed8;
}

.access-key-scan-result.success {
    background: #dcfce7;
    color: #166534;
}

.access-key-scan-result.error {
    background: #fee2e2;
    color: #991b1b;
}

/* ============== МОДУЛИ ============== */
.modules-container {
    text-align: center;
}

.modules-container h1 {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    display: inline-block;
}

.modules-container h1 .gradient-text {
    background: linear-gradient(135deg, #fff 0%, #f0e9ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

.modules-container h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light), #a78bfa);
    border-radius: var(--radius-full);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.6);
}

p.subtitle {
    color: white;
    font-size: 18px;
    font-weight: 400;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.2);
    display: inline-block;
    padding: 8px 25px;
    border-radius: 40px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 10px;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.module-card {
    text-decoration: none;
    padding: 30px;
    text-align: center;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.module-card:hover:not(.disabled) {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

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

.module-card.disabled:hover {
    transform: none;
}

.module-icon {
    width: 80px;
    height: 80px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.module-icon i {
    font-size: 36px;
    color: var(--primary);
}

.module-card h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--dark);
}

.module-card p {
    color: var(--gray);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.module-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--light);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--success);
}

.module-badge i {
    font-size: 12px;
}

/* ============== ПРЕЛОАДЕР ============== */
#program-preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, #667eea 0%, #764ba2 50%, #7c3aed 100%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#program-preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    animation: pulses 2s infinite;
}

.preloader-brand-mark {
    width: 60px;
    height: 60px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    animation: bounce 1.5s ease infinite;
}

.preloader-logo .brand-mark {
    width: 56px;
    height: 56px;
    filter: brightness(0) invert(1);
}

.preloader-logo .preloader-brand-title {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-top: 12px;
}

.preloader-logo .preloader-brand-slogan {
    display: block;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    font-weight: 600;
}

.preloader-spinner .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-right: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

.preloader-text {
    color: white;
    font-size: 16px;
    margin: 20px 0;
}

.preloader-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px auto 0;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #fff, #a78bfa);
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* ============== АНИМАЦИИ ============== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulses {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* ============== КНОПКА ПРОКРУТКИ ВВЕРХ ============== */
.scroll-top-btn {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.scroll-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-5px);
    background: var(--primary-dark);
}

/* ============== УТИЛИТЫ ============== */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

/* ============== СКРОЛЛБАР ============== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* ============== АДАПТАЦИЯ ============== */
@media (max-width: 768px) {
    .main-container {
        padding: 15px;
        min-height: auto;
    }

    .modules-container h1 {
        font-size: 32px;
    }
    
    .modules-grid {
        grid-template-columns: 1fr;
    }
    
    .preloader-progress {
        width: 250px;
    }
    
    .login-container {
        padding: 30px 20px;
    }
    
    .login-container h1 {
        font-size: 28px;
    }

    .access-key-actions {
        gap: 10px;
    }

    .btn-scan-access-key {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .access-key-reader,
    .access-key-reader video {
        min-height: 220px;
        max-height: 220px;
    }
}

@media (max-width: 480px) {
    .preloader-brand-mark {
        width: 56px;
        height: 56px;
        border-radius: 18px;
    }

    .preloader-logo .brand-mark {
        width: 52px;
        height: 52px;
    }
    
    .preloader-logo .preloader-brand-title {
        font-size: 24px;
    }

    .preloader-logo .preloader-brand-slogan {
        font-size: 13px;
    }
    
    .preloader-progress {
        width: 200px;
    }
    
    .modules-container h1 {
        font-size: 28px;
    }
    
    .subtitle {
        font-size: 16px;
    }
}
