/* Шрифт Inter (локальный, переменный) */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/InterVariable.woff2') format('woff2');
}

/* Основные стили */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #0891b2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --text-dark: #0f172a;
    --text-light: #64748b;
    --bg-light: #f1f5f9;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 20px -3px rgba(15, 23, 42, 0.09), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
    --shadow-xl: 0 24px 40px -12px rgba(15, 23, 42, 0.18);
    --shadow-primary: 0 8px 20px -6px rgba(37, 99, 235, 0.45);
    --gradient-brand: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
    --border-radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.65;
    color: var(--text-dark);
    background-color: var(--bg-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Шапка сайта */
.site-header {
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0;
}

.header-logo {
    flex-shrink: 0;
}

.header-logo h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-logo a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
}

.header-logo img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

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

.nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -0.6rem;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 3px;
    background: var(--gradient-brand);
}

.nav-link-admin {
    background: linear-gradient(135deg, var(--warning-color) 0%, #ea580c 100%);
    color: white !important;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-weight: 600;
}

.nav-link-admin:hover {
    color: white !important;
    box-shadow: 0 6px 16px -4px rgba(245, 158, 11, 0.5);
    transform: translateY(-1px);
}

.nav-link-admin.active::after {
    display: none;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.user-info-link {
    text-decoration: none;
    transition: var(--transition);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    min-width: 0;
}

.user-info-link:hover {
    background: var(--bg-light);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: var(--text-dark);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-group {
    font-size: 0.8rem;
    color: var(--text-light);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    flex-shrink: 0;
}

.btn-logout, .btn-login, .btn-register {
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
}

.btn-logout {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-logout:hover {
    background: #fee2e2;
    color: var(--danger-color);
    border-color: #fecaca;
}

.btn-login {
    background: var(--primary-color);
    color: white;
}

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

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

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

/* Мобильное меню */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    border-radius: 3px;
    background: var(--text-dark);
    transition: var(--transition);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    box-shadow: var(--shadow-lg);
    border-bottom: 1px solid var(--border-color);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-menu.active {
    max-height: 500px;
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.mobile-nav-link {
    padding: 0.85rem;
    color: var(--text-dark);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}

.mobile-nav-link:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.mobile-nav-link.logout {
    color: var(--danger-color);
    border-bottom: none;
}

.mobile-user-info {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* Основной контент */
.site-main {
    flex: 1;
    padding: 1.25rem 0 2rem;
}

/* Уведомления */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Карточки */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

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

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-dark);
}

.card-description {
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    font-size: 1rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient-brand);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    box-shadow: var(--shadow-primary);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Outline вариант (светлый) */
.btn-secondary {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: #cbd5e1;
}

/* Solid серый вариант */
.btn-secondary-solid {
    background: #475569;
    color: white;
    border: none;
}

.btn-secondary-solid:hover {
    background: #334155;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
    box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.45);
    transform: translateY(-2px);
}

.btn-disabled {
    background: #cbd5e1 !important;
    color: #64748b !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    box-shadow: none !important;
    transform: none !important;
}


/* Markdown таблицы */
.markdown-table, table.markdown-table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.markdown-table th,
.markdown-table td,
table.markdown-table th,
table.markdown-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.markdown-table th,
table.markdown-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
}

.markdown-table tr:nth-child(even),
table.markdown-table tr:nth-child(even) {
    background: #f8fafc;
}

.markdown-table tr:hover,
table.markdown-table tr:hover {
    background: #eff6ff;
}


.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Формы */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-white);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-control.error {
    border-color: var(--danger-color);
}

.form-help {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.form-error {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--danger-color);
}

/* Прогресс-бар */
.progress {
    background: var(--border-color);
    height: 1.5rem;
    border-radius: 999px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-with-label {
    position: relative;
}

.progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
    z-index: 1;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

/* Цвета прогресс-бара в зависимости от процента */
.progress-bar.progress-low {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
}

.progress-bar.progress-medium {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.progress-bar.progress-high {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

/* Модули */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.module-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.module-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-6px);
    border-color: transparent;
}

.module-card.locked {
    opacity: 0.65;
    cursor: not-allowed;
}

.module-card.locked:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.module-header {
    padding: 1.5rem;
    background: var(--gradient-brand);
    color: white;
    position: relative;
    overflow: hidden;
}

.module-header::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.module-number {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.9;
}

.module-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-top: 0.25rem;
}

.module-body {
    padding: 1.5rem;
}

.module-description {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.module-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.progress-details {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-icon.completed {
    background: var(--success-color);
}

.status-icon.in-progress {
    background: var(--warning-color);
}

.status-icon.locked {
    background: var(--border-color);
}

/* Подвал */
.site-footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 2.25rem 0 1.25rem;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-section p {
    color: #94a3b8;
    line-height: 1.8;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    padding-top: 1.5rem;
    border-top: 1px solid #1e293b;
    text-align: center;
    color: #94a3b8;
}

/* Адаптивность */
@media (max-width: 960px) {
    .header-nav {
        display: none;
    }

    .header-user {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .mobile-menu {
        display: block;
    }
}

@media (max-width: 768px) {
    .modules-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* Утилиты */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.w-100 { width: 100%; }
.w-auto { width: auto; }

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

/* ========================================
   Страницы авторизации
   ======================================== */
body.auth-page {
    background: var(--gradient-brand);
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

body.auth-page::before,
body.auth-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

body.auth-page::before {
    width: 480px;
    height: 480px;
    top: -180px;
    right: -120px;
}

body.auth-page::after {
    width: 360px;
    height: 360px;
    bottom: -160px;
    left: -100px;
}

.auth-container {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px -15px rgba(15, 23, 42, 0.4);
    width: 100%;
    max-width: 420px;
    padding: 42px;
    position: relative;
    z-index: 1;
}

.auth-container.wide {
    max-width: 520px;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-header h1 {
    color: var(--text-dark);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-light);
}

.auth-form .form-group {
    margin-bottom: 1.25rem;
}

.auth-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.875rem;
}

.auth-form .form-group input,
.auth-form .form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-white);
    transition: var(--transition);
}

.auth-form .form-group input:focus,
.auth-form .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-form .btn-primary {
    width: 100%;
    padding: 0.9rem;
}

.auth-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.auth-form .form-group.full-width {
    grid-column: 1 / -1;
}

.auth-form .required {
    color: var(--danger-color);
}

.auth-form small {
    display: block;
    margin-top: 0.3rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

.auth-message {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

.auth-message.error {
    background: #fef2f2;
    color: #991b1b;
}

.auth-message.success {
    background: #ecfdf5;
    color: #065f46;
}

.auth-success-block {
    background: #ecfdf5;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.auth-success-block h2 {
    color: #059669;
    font-size: 1.5rem;
    margin-bottom: 0.625rem;
}

.auth-success-block p {
    margin-bottom: 1.25rem;
    color: var(--text-light);
}

.auth-footer {
    margin-top: 1.875rem;
    text-align: center;
}

.auth-footer p {
    color: var(--text-light);
    font-size: 0.875rem;
}

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

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

@media (max-width: 600px) {
    .auth-container {
        padding: 30px 24px;
    }

    .auth-form .form-row {
        grid-template-columns: 1fr;
    }
}
