/* ═══════════════════════════════════════════════
   ИМПОРТ ШРИФТОВ И ИКОНОК
═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* ═══════════════════════════════════════════════
   CSS-ПЕРЕМЕННЫЕ
═══════════════════════════════════════════════ */
:root {
    --primary:        #b22222;
    --primary-dark:   #8b1a1a;
    --primary-light:  #f5e6e6;
    --accent:         #d4a853;
    --bg:             #f5f0e8;
    --bg-card:        #ffffff;
    --text:           #2c2c2c;
    --text-muted:     #888888;
    --border:         #e0d8cc;
    --shadow:         0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover:   0 6px 24px rgba(0,0,0,0.14);
    --radius:         12px;
    --radius-sm:      6px;
    --transition:     0.2s ease;
}

/* ═══════════════════════════════════════════════
   СБРОС И БАЗОВЫЕ СТИЛИ
═══════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg);
    background-image: url('/static/bamboo_bg.png');
    background-attachment: fixed;
    background-size: cover;
    background-blend-mode: multiply;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════
   ОСНОВНОЙ КОНТЕЙНЕР
═══════════════════════════════════════════════ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 250, 244, 0.96);
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════
   ШАПКА
═══════════════════════════════════════════════ */
header {
    background-color: var(--primary);
    background-blend-mode: overlay;
    background-size: auto;
    color: white;
    padding: 0 2rem;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 1.4rem;
    color: var(--accent);
}

nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

nav a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

nav a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
}

nav a.nav-logout {
    color: rgba(255,255,255,0.7);
}

nav a.nav-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* ═══════════════════════════════════════════════
   ОСНОВНОЙ КОНТЕНТ
═══════════════════════════════════════════════ */
main {
    flex: 1;
    padding: 2rem;
}

/* ═══════════════════════════════════════════════
   ПОДВАЛ
═══════════════════════════════════════════════ */
footer {
    background-color: var(--primary);
    color: rgba(255,255,255,0.85);
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════
   ЗАГОЛОВКИ
═══════════════════════════════════════════════ */
h1, h2, h3 {
    color: var(--primary);
    font-weight: 600;
}

h1 { font-size: 1.8rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.5rem; margin-bottom: 1.25rem; }
h3 { font-size: 1.15rem; margin-bottom: 1rem; }

.page-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: 1.5rem;
}

.page-title i {
    color: var(--accent);
    font-size: 1.3rem;
}

/* ═══════════════════════════════════════════════
   КАРТОЧКИ
═══════════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--accent);
}

/* ═══════════════════════════════════════════════
   СЕТКА КАРТОЧЕК
═══════════════════════════════════════════════ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--primary);
    flex-shrink: 0;
}

.stat-card .stat-info .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-card .stat-info .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════════
   КНОПКИ
═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    font-family: inherit;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(178,34,34,0.3);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.btn-danger {
    background: none;
    color: var(--primary);
    border: none;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}

.btn-danger:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    transform: none;
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
}

/* Обратная совместимость со старыми button */
button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: var(--primary);
    color: white;
    font-family: inherit;
    transition: background var(--transition);
}

button:hover {
    background: var(--primary-dark);
}

/* ═══════════════════════════════════════════════
   ФОРМЫ
═══════════════════════════════════════════════ */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(178,34,34,0.1);
}

/* ═══════════════════════════════════════════════
   ТАБЛИЦЫ
═══════════════════════════════════════════════ */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #fdf8f4;
}

/* ═══════════════════════════════════════════════
   ФЛЕШ-СООБЩЕНИЯ
═══════════════════════════════════════════════ */
.flashes {
    list-style: none;
    margin-bottom: 1.25rem;
}

.flashes li {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.9rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flashes li::before {
    content: '\f05a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

/* ═══════════════════════════════════════════════
   БЕЙДЖИ
═══════════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-muted {
    background: #f0f0f0;
    color: var(--text-muted);
}

.badge-accent {
    background: #fef3d8;
    color: #a07820;
}

/* ═══════════════════════════════════════════════
   МОДАЛЬНЫЕ ОКНА
═══════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    padding: 2rem;
    max-width: 520px;
    width: 90%;
    position: relative;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--primary);
    background: none;
}

.modal h3 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal h3 i {
    color: var(--accent);
}

.modal p, .modal ul {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.7;
}

.modal ul {
    padding-left: 1.2rem;
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════════
   ЧИПЫ / ТЕГИ
═══════════════════════════════════════════════ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.7rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════
   УТИЛИТЫ
═══════════════════════════════════════════════ */
.text-muted  { color: var(--text-muted); font-size: 0.85rem; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--primary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-1        { gap: 0.5rem; }
.gap-2        { gap: 1rem; }
.justify-between { justify-content: space-between; }

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ═══════════════════════════════════════════════
   АДАПТИВНОСТЬ
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    header {
        padding: 0 1rem;
        height: auto;
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    main {
        padding: 1rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }
}
