/* ========================================
   VLADLEN FM - Design System
   Unified Premium UI Framework
   Personal Resume Style (ovnresume.ru)
   Variables sourced from 01-tokens.css
   ======================================== */

/* Compatibility Aliases */
:root {
    --color-accent: var(--accent);
    --color-accent-soft: var(--accent-secondary);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --color-text: var(--text-primary);
    --color-bg: var(--bg-primary);
    --color-border: var(--border-color);
}

/* ========================================
   LIGHT THEME (default via :root)
   ======================================== */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --accent: #6366f1;
    --accent-light: rgba(99, 102, 241, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
    --sidebar-glass: rgba(255, 255, 255, 0.95);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* ========================================
   DARK THEME OVERRIDES
   ======================================== */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-primary-rgb: 15, 23, 42;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-hover: rgba(51, 65, 85, 0.5);
    --bg-tertiary: #111827;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #94a3b8;

    --border-color: rgba(148, 163, 184, 0.1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7);

    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --bg-glass: rgba(15, 23, 42, 0.8);
}

/* ========================================
   BASE STYLES
   ======================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: var(--font-size-base); scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: var(--line-height-base);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

[data-theme="dark"] body {
    background: radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 0% 100%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
                #0f172a;
}

/* ========================================
   CORE COMPONENTS
   ======================================== */

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-glass);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-premium);

    /* 🔧 FIX: box-sizing предотвращает выход за границы */
    box-sizing: border-box;
    /* 🔧 FIX: overflow-x hidden предотвращает горизонтальный скролл */
    overflow-x: hidden;
}

/* Desktop: sidebar visible */
@media (min-width: 1025px) {
    .sidebar {
        transform: translateX(0);
    }
}

/* Mobile: sidebar hidden off-screen by default */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 2000; /* Above header on mobile */
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 28px 24px !important;
    border-bottom: 1px solid var(--border-color) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    height: auto !important;
    min-height: 100px !important;
    box-sizing: border-box !important;
}

.sidebar-header .logo {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    transform: none !important;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: var(--spacing-md) !important; /* 🔧 FIX: Абсолютно одинаковые отступы везде */
    display: flex;
    flex-direction: column;
    gap: 4px !important; /* 🔧 FIX: Плотное и стабильное меню */

    /* 🔧 FIX: Скрываем скроллбар для эстетики */
    scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    flex-shrink: 0;
    min-height: 72px;
    box-sizing: border-box;
    position: relative;
}

/* 🔧 FIX: Группа переключателей темы */
.theme-controls {
    display: flex;
    gap: 8px;
}

.theme-controls .theme-toggle {
    width: 38px;
    height: 38px;
}

/* 🔧 FIX: Кнопка выхода с разделителем */
.sidebar-footer .logout-btn {
    margin-left: auto;
    position: relative;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer .logout-btn::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.sidebar-footer .logout-btn .icon-btn,
.sidebar-footer .icon-btn:last-child {
    width: 44px;
    height: 44px;
}

/* Logo */
.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 800;
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    letter-spacing: -0.02em;
    text-align: center;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .card {
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.theme-toggle:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Базовая кнопка */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    border: none;
    outline: none;
    text-decoration: none;
    vertical-align: middle;
}
.btn i, .btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: inherit;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* PRIMARY — всегда белый текст */
.btn-primary {
    background: var(--accent);
    color: #ffffff;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* SECONDARY — адаптивный */
.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
[data-theme="dark"] .btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

/* Размеры */
.btn-sm {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 8px;
}
.btn-lg {
    height: 52px;
    padding: 0 28px;
    font-size: 16px;
    border-radius: 12px;
}
.btn:not(.btn-sm):not(.btn-lg) {
    height: 44px;
    padding: 0 20px;
}

/* Icon-only кнопка */
.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

/* Nav Items - WORLD CLASS STABILITY FIX */
.sidebar-nav .nav-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 0 16px !important;
    border-radius: var(--radius-lg) !important;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    flex-shrink: 0 !important;

    /* 🔧 FIX: Smooth transitions for nav items */
    transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: background-color, color !important;
    font-weight: 500 !important;
    transform: none !important;
}

/* See line 792 for unified nav-item:active rule */

.sidebar-nav .nav-item span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    pointer-events: none !important;
}

/* 🔧 FIX: Трюк для резервирования места под жирный шрифт (если вдруг захочется вернуть) */
/* Сейчас мы оставляем 500 везде для максимальной стабильности */
.sidebar-nav .nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%) !important;
    color: var(--accent) !important;
    font-weight: 500 !important; /* Оставляем 500, чтобы текст не "распухал" */
}

/* 🔧 FIX: Индикатор активного пункта выведен из потока (absolute) */
.sidebar-nav .nav-item.active::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 4px !important;
    height: 24px !important;
    background: var(--accent) !important;
    border-radius: 0 4px 4px 0 !important;
    z-index: 2 !important;
}

/* ========================================
   TOAST NOTIFICATIONS - FIXED VERSION
   ======================================== */

/* Container - fixed position, doesn't affect layout */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;

    /* 🔧 FIX: Убрали max-height - контейнер не на всю высоту! */
    max-height: 600px;
    overflow-y: auto;
    padding: 4px;

    /* 🔧 FIX: Скрываем скроллбар */
    scrollbar-width: none;
    -ms-overflow-style: none;

    /* 🔧 FIX: Ограничиваем ширину */
    width: auto;
    max-width: 420px;
}

.toast-container::-webkit-scrollbar {
    display: none;
}

/* Individual toast */
.toast {
    /* 🔧 FIX: Стиль соответствует дизайну сайта (glass effect) */
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);

    padding: 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-start;
    gap: 12px;

    /* 🔧 FIX: Тень как у карточек на сайте */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);

    min-width: 300px;
    max-width: 400px;

    /* 🔧 FIX: pointer-events только на тосте, не на контейнере */
    pointer-events: auto;

    /* 🔧 FIX: Плавная анимация через opacity + transform */
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* 🔧 FIX: Предотвращаем сдвиги */
    box-sizing: border-box;
    flex-shrink: 0;

    /* 🔧 FIX: Курсор pointer для возможности закрыть */
    cursor: default;

    /* 🔧 FIX: Градиентная полоска слева вместо обычной */
    border-left-width: 4px;
    border-left-style: solid;

    /* 🔧 FIX: position: relative для progress bar */
    position: relative;
}

/* 🔧 FIX: Анимация появления */
.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* 🔧 FIX: Анимация исчезновения */
.toast.hiding,
.toast.hide {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

/* Type indicators - colored left border + icon */
.toast.success {
    border-left-color: var(--success);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
}
.toast.error {
    border-left-color: var(--danger);
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.05) 0%, transparent 100%);
}
.toast.warning {
    border-left-color: var(--warning);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.05) 0%, transparent 100%);
}
.toast.info {
    border-left-color: var(--accent);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05) 0%, transparent 100%);
}

/* Icon container */
.toast-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    /* 🔧 FIX: Цвета иконок по типам */
    margin-top: 2px;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--accent); }

/* Message text */
.toast-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;

    /* 🔧 FIX: Перенос текста если длинный */
    word-wrap: break-word;
    line-height: 1.4;
}

/* Close button */
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;

    /* 🔧 FIX: Фиксированный размер */
    width: 24px;
    height: 24px;
    flex-shrink: 0;

    /* 🔧 FIX: Плавный hover */
    transition: all 0.2s ease;
    border-radius: 4px;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Progress bar for auto-close timer */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 0 var(--radius-lg);
    opacity: 0.6;
    animation: progress linear forwards;
    animation-duration: var(--toast-duration, 3s);
}

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

/* Type-specific progress colors */
.toast.success .toast-progress { background: var(--success); }
.toast.error .toast-progress { background: var(--danger); }
.toast.warning .toast-progress { background: var(--warning); }
.toast.info .toast-progress { background: var(--accent); }

/* ========================================
   ANIMATIONS & EFFECTS
   ======================================== */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 🔧 FIX: Уменьшили scale с 1.5 до 1.2 — волны не обрезаются */
@keyframes ripple {
    0% { transform: scale(0.5); opacity: 0; }
    50% { opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 0; }
}

@keyframes blink {
    from { opacity: 0.4; filter: drop-shadow(0 0 2px var(--accent)); }
    to { opacity: 1; filter: drop-shadow(0 0 8px var(--accent)); }
}

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

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

.animate-fade-in {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ========================================
   MAYAK LOGO COMPONENTS
   ======================================== */
.mayak-logo-small {
    width: 80px;
    height: 80px;
    color: var(--accent);
    filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.6)) drop-shadow(0 0 32px rgba(99, 102, 241, 0.3));
    position: relative;
}

.mayak-logo-small .wave {
    transform-origin: center;
    animation: ripple 3s infinite cubic-bezier(0.4, 0, 0.6, 1);
    opacity: 0;
    fill: none;
    stroke: currentColor;
}

.mayak-logo-small .wave-1 { animation-delay: 0s; }
.mayak-logo-small .wave-2 { animation-delay: 1s; }
.mayak-logo-small .wave-3 { animation-delay: 2s; }

.mayak-logo-small .tower { fill: currentColor; }

.mayak-logo-small .beacon {
    animation: blink 1.5s infinite alternate;
}

.mayak-logo-large {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    color: var(--accent);
    animation: float 3s ease-in-out infinite;
}

.mayak-logo-large .wave {
    transform-origin: center;
    animation: ripple 3s infinite cubic-bezier(0.4, 0, 0.6, 1);
    opacity: 0;
    fill: none;
    stroke: currentColor;
}

.mayak-logo-large .wave-1 { animation-delay: 0s; }
.mayak-logo-large .wave-2 { animation-delay: 1s; }
.mayak-logo-large .wave-3 { animation-delay: 2s; }

/* FINAL SIDEBAR LOCK - REFINED FOR MOBILE */
@media (min-width: 1025px) {
    .sidebar {
        width: 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
        flex: 0 0 280px !important;
        box-sizing: border-box !important;
        height: 100vh !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 1000 !important;
        background: var(--sidebar-glass) !important;
        border-right: 1px solid var(--border-color) !important;
        transform: none !important; /* Lock transform for desktop */
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 280px !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        height: 100dvh !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1000 !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }
}

.sidebar-label {
    padding: 6px 12px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    color: var(--text-muted) !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 4px !important;
}

.nav-item {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 16px !important;
    margin: 0 !important;
    border: none !important;
}

/* Tactile feedback for clicks */
.nav-item:active, .btn:active, .icon-btn:active {
    /* transform: scale(0.98) removed — caused sidebar icon jitter */
}
.sidebar-nav .nav-item:active {
    background: rgba(99, 102, 241, 0.08) !important;
}
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-small { font-size: 14px; }
.text-large { font-size: var(--font-size-lg); }

/* ========================================
   TABLES
   ======================================== */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}
.data-table,
.users-table {
    width: 100%;
    min-width: min(600px, 100%);
    border-collapse: collapse;
}
.data-table th,
.users-table th {
    padding: 14px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
[data-theme="dark"] .data-table th,
[data-theme="dark"] .users-table th {
    background: rgba(255, 255, 255, 0.02);
}
.data-table td,
.users-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
    color: var(--text-primary);
}
.data-table tr:last-child td,
.users-table tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:hover,
.users-table tbody tr:hover {
    background: var(--bg-hover);
}

/* ========================================
   ACTION BADGES
   ======================================== */
.action-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}
.action-success { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.action-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.action-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(255, 68, 68, 0.2); }
.action-login { background: rgba(99, 102, 241, 0.1); color: #6366f1; border: 1px solid rgba(99, 102, 241, 0.2); }

/* Badge modifiers */
.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    margin-left: 0;
}
.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    margin-left: 0;
}
.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    margin-left: 0;
}
.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    margin-left: 0;
}

[data-theme="dark"] .badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}
[data-theme="dark"] .badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}
[data-theme="dark"] .badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}
[data-theme="dark"] .badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* ========================================
   ADMIN PAGE HEADER
   ======================================== */
.admin-header {
    margin-bottom: var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-header h1 {
    font-size: clamp(22px, 4vw, 28px);
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
}

.admin-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 4px 0 0;
}

.admin-header-actions {
    display: flex;
    gap: 8px;
}

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

/* ========================================
   CONTENT LAYOUT
   ======================================== */
.content-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.content-wrapper .card {
    max-width: 100%;
    box-sizing: border-box;
}

.card-mt {
    margin-top: 24px;
}

/* ========================================
   FILTERS
   ======================================== */
.filter-section {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 150px;
}

.filter-group-large {
    flex: 2 !important;
}

.filter-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.filter-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

.filter-input, .form-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
    width: 100%;
}

.filter-input.with-icon, .form-input.with-icon {
    padding-left: 40px;
}

.filter-input:focus, .form-input:focus {
    border-color: var(--accent);
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-input::placeholder, .form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

select.filter-input, select.form-input {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select.filter-input.with-icon {
    background-position: right 12px center;
    padding-left: 40px;
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 8px;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state-subtext {
    font-size: 14px;
    opacity: 0.7;
}

/* ========================================
   LOADING
   ======================================== */
.loading-cell {
    text-align: center;
    padding: 48px 24px;
}

.loading-cell .spinner {
    margin: 0 auto 16px;
}

/* ========================================
   TABLE CELL STYLES
   ======================================== */
.th-narrow {
    width: 60px;
}

.th-time {
    width: 160px;
}

.th-action {
    width: 120px;
}

.th-ip {
    width: 130px;
}

.td-time {
    display: flex;
    align-items: center;
    gap: 8px;
}

.td-time i {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.td-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
}

.ip-code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* Utilities */
.hide-mobile {
    display: inherit;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}



/* ========================================
   RESPONSIVE DESIGN (Core Breakpoints)
   ======================================== */

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px; /* Hide sidebar by default on tablets */
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        width: 280px;
    }

/* main-content now in cross-browser-fixes.css */

}

/* ========================================
   MOBILE RESPONSIVE - TOAST NOTIFICATIONS
   ======================================== */
@media (max-width: 640px) {
    .toast-container {
        /* 🔧 FIX: На мобильных - top-center с отступами */
        top: 16px;
        right: 16px;
        left: 16px;

        /* 🔧 FIX: Уведомления на всю доступную ширину */
        max-width: none;
        width: auto;
    }

    .toast {
        /* 🔧 FIX: Минимальная ширина на мобильных */
        min-width: auto;
        width: 100%;

        /* 🔧 FIX: Адаптивные отступы */
        padding: 14px;

        /* 🔧 FIX: Уменьшенная иконка */
        gap: 10px;
    }

    .toast-message {
        font-size: 13px;
        line-height: 1.4;
    }

    .toast-close {
        width: 24px;
        height: 24px;
        font-size: 20px;
    }

    .toast-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: var(--spacing-md);
    }

    .card {
        padding: var(--spacing-md);
        border-radius: var(--radius-xl);
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Mobile sidebar fixes */
    .sidebar {
        width: 280px;
        max-width: 85vw;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    .sidebar-header {
        padding: var(--spacing-md);
        min-height: 64px;
    }

    .sidebar-nav {
        padding: var(--spacing-sm) 0;
        max-height: calc(100dvh - 160px);
        overflow-y: auto;
        min-height: 0;
    }

    .sidebar-footer {
        padding: var(--spacing-md);
        flex-wrap: nowrap;
        justify-content: center;
        gap: var(--spacing-lg);
        min-height: 64px;

        /* 🔧 FIX: Добавляем divider между кнопками темы и выходом */
        position: relative;
    }

    /* 🔧 FIX: Разделительная линия перед кнопкой выхода */
    .sidebar-footer::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 32px;
        background: var(--border-color);
    }

    .sidebar-footer .theme-toggle,
    .sidebar-footer .icon-btn {
        flex: 0 0 auto;
        width: 44px;
        height: 44px;

        /* 🔧 FIX: Фиксированный размер предотвращает скачки */
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-base: 14px;
    }

    .page-title {
        font-size: var(--font-size-lg);
    }
}

/* Sidebar Overlay for mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* Toast mobile responsive [REFINED] */
@media (max-width: 640px) {
    .toast-container {
        /* 🔧 FIX: top-center на мобильных */
        top: 16px;
        bottom: auto;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
        height: auto;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
        width: 100%;

        /* 🔧 FIX: Немного меньше padding на мобилках */
        padding: 12px 14px;
    }
}

/* Stats Grid & Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    min-width: 0;
    overflow: hidden;
}
.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.1);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon i { width: 22px; height: 22px; }
.stat-icon.primary { background: rgba(99,102,241,0.12); color: #6366f1; }
.stat-icon.success { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon.warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-icon.danger  { background: rgba(239,68,68,0.12);  color: #ef4444; }
.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-value {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; gap: 16px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-icon { width: 44px; height: 44px; }
    .stat-value { font-size: 22px; }
}
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Спиннер загрузки */
.animate-spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

@media (max-width: 640px) {
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-box {
        border-radius: 24px 24px 0 0;
        max-width: 100%;
        padding: 28px 20px 40px;
        padding-bottom: max(40px, env(safe-area-inset-bottom));
        animation: modalUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }
}
@keyframes modalUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* Forms */
.form-group { margin-bottom: 16px; text-align: left; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.form-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
textarea.form-input {
    height: auto;
    padding: 12px 14px;
    resize: vertical;
    min-height: 100px;
}

/* Fix for large status text on dashboard */
#status-value {
    font-size: 20px !important;
    word-break: normal;
    display: block;
    margin-top: 4px;
}

#header-status-badge {
    margin-top: 8px;
    display: inline-block;
}

/* 🏁 FINAL OVERRIDES FOR MOBILE & UI POLISH */
@media (max-width: 1024px) {
    .sidebar { z-index: 2100 !important; }
    .sidebar-overlay { z-index: 2050 !important; }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 16px !important;
        min-height: 90px !important;
    }
    .stat-value {
        font-size: 18px !important;
    }
    .main-header {
        padding: 0 16px !important;
    }
}

/* 📱 MOBILE OPTIMIZATIONS FOR DASHBOARD STATUS */
@media (max-width: 480px) {
    #status-value {
        font-size: 15px !important; /* Smaller font for mobile boxes */
        letter-spacing: -0.01em !important;
    }
    .stat-card {
        min-height: 80px !important;
        padding: 12px !important;
    }
    .stat-icon {
        width: 34px !important;
        height: 34px !important;
    }
    .stat-label {
        font-size: 10px !important;
    }
}

/* Ensure header icons have enough room */
.theme-toggle.icon-btn {
    margin-right: 4px;
}



/* Notification Bell */
.bell-btn {
    width: 40px; height: 40px; border-radius: 12px;
    background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3);
    color: #6366f1; display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative; transition: all 0.2s;
}
.bell-btn:hover { background: rgba(99,102,241,0.25); box-shadow: 0 0 12px rgba(99,102,241,0.25); }
.bell-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 4px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    border-radius: 9px; display: flex; align-items: center; justify-content: center;
}
.bell-dropdown {
    position: absolute; top: 56px; right: 16px; width: 320px; max-height: 400px;
    display:flex; flex-direction:column;
    background: rgba(15,23,42,0.95); backdrop-filter: blur(16px);
    border: 1px solid rgba(148,163,184,0.2); border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 2000;
}
.bell-dropdown-header {
    padding: 14px 18px; font-weight: 700; font-size: 15px;
    border-bottom: 1px solid rgba(148,163,184,0.15); flex-shrink:0;
}
.bell-dropdown-list {
    overflow-y:auto; flex:1; min-height:0;
}
.bell-item {
    padding: 12px 18px; border-bottom: 1px solid rgba(148,163,184,0.1);
    display: flex; gap: 10px; align-items: flex-start;
    font-size: 14px; transition: background 0.15s;
}
.bell-item:hover { background: rgba(99,102,241,0.1); }
.bell-item-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.bell-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bell-label { color: #f1f5f9; font-size: 13px; }
.bell-detail { color: #94a3b8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell-time { color: #94a3b8; font-size: 11px; flex-shrink: 0; margin-top: 2px; }
.bell-dropdown-footer {
    display: block; padding: 12px 18px; text-align: center;
    color: var(--accent, #818cf8); font-size: 13px; font-weight: 600;
    text-decoration: none; border-top: 1px solid rgba(148,163,184,0.15); flex-shrink:0;
}
.bell-dropdown-footer:hover { background: rgba(99,102,241,0.1); }
