/* ============================================
   BULEKOV24.RU - Общий UI-кит
   Единые стили для всех страниц
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --bg-input: #16162a;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --border-color: #2d2d44;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 0 20px rgba(99, 102, 241, 0.3);
    --row-even-bg: rgba(255, 255, 255, 0.05);
    --row-hover-bg: rgba(255, 255, 255, 0.1);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --nav-height: 64px;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 0 30px rgba(59, 130, 246, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 0 20px rgba(99, 102, 241, 0.15);
    --row-even-bg: rgba(0, 0, 0, 0.05);
    --row-hover-bg: rgba(0, 0, 0, 0.05);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

*:focus, *:active, *:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
}

* {
    -webkit-tap-highlight-color: transparent;
    transition: none !important;
}

*:hover, *:focus, *:active, *:focus-visible {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    transition: none !important;
}

.table, .table tr, .table td, .table th {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* --- Animated Background --- */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
    animation: bgFloat 30s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(2%, 3%) rotate(3deg); }
}

/* --- Navbar --- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--nav-height);
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
}

[data-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.85);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.navbar-logo {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.navbar-title {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.navbar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.navbar-link:hover {
    color: var(--text-primary);
    background: transparent;
}

.navbar-link.active {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
}

.navbar-link-icon {
    font-size: 16px;
}

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

.navbar-date {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.theme-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

/* --- Container --- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.container-narrow {
    max-width: 800px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: none !important;
    border-radius: 20px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    outline: none !important;
}

.card:hover, .card:focus, .card:active, .card:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}



.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
}

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    background: var(--bg-secondary);
    padding: 14px 18px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: sticky;
    top: 0;
    z-index: 10;
    outline: none !important;
}

.table th:hover,
.table th:active,
.table th:focus {
    color: var(--text-secondary) !important;
    background: var(--bg-secondary) !important;
    outline: none !important;
}

.table th .sort-icon {
    margin-left: 6px;
    opacity: 0.4;
    font-size: 12px;
}

.table th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent-primary);
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr {
    transition: all 0.2s ease;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

.table tbody tr:nth-child(even),
.table tbody tr:nth-child(odd) {
    background: transparent !important;
}

.table tbody tr:nth-child(even):hover,
.table tbody tr:nth-child(odd):hover {
    background: transparent !important;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.pagination-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

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

.pagination-info {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 12px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 16px);
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 480px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    backdrop-filter: blur(20px);
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-success .toast-icon { color: var(--success); }

.toast.toast-error { border-left: 4px solid var(--error); }
.toast.toast-error .toast-icon { color: var(--error); }

.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-warning .toast-icon { color: var(--warning); }

.toast.toast-info { border-left: 4px solid var(--info); }
.toast.toast-info .toast-icon { color: var(--info); }

/* --- Skeleton Loading --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card-hover) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-title {
    height: 24px;
    width: 40%;
    margin-bottom: 16px;
}

.skeleton-table-row {
    height: 48px;
    margin-bottom: 1px;
}

.skeleton-card {
    height: 200px;
    border-radius: var(--border-radius-lg);
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.badge-muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* --- Progress Bar --- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width var(--transition-normal);
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-change {
    font-size: 12px;
    margin-top: 8px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

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

.empty-state-desc {
    font-size: 14px;
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-spacer {
    flex: 1;
}

.toolbar-search {
    position: relative;
    min-width: 240px;
}

.toolbar-search .form-input {
    padding-left: 36px;
}

.toolbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Charts Container --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
}

.chart-canvas {
    width: 100%;
    height: 240px;
    flex: 1;
}

/* --- Theme Toggle --- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
}

.theme-toggle input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--accent-gradient);
    border-radius: 11px;
    position: relative;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-normal);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.theme-toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-nav {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 12px;
        gap: 4px;
    }

    .navbar-nav.open {
        display: flex;
    }

    .navbar-link {
        padding: 12px 16px;
        width: 100%;
    }

    .container {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-search {
        min-width: 100%;
    }

    .table {
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 8px 12px;
    }

    .toast {
        min-width: unset;
        max-width: calc(100vw - 48px);
    }

    .toast-container {
        right: 12px;
        left: 12px;
    }
}

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

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* --- Print --- */
@media print {
    .navbar,
    .toast-container,
    .toolbar,
    .pagination {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}
