/* layout.css */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700&display=swap');

:root {
    --ink:        #100F0F;
    --text:       #1A1817;
    --red:        #C41A18;
    --red-dark:   #A01512;
    --warm-1:     #F7F5F3;
    --warm-2:     #EFECE8;
    --border:     #D8D4D0;
    --muted:      #3A3533;
    --secondary:  #888480;
    --sidebar-w:  240px;
    --topbar-h:   56px;
    --radius:     8px;
    --radius-lg:  12px;
    --transition: 180ms ease;
}

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

html { font-size: 15px; }

body {
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background: var(--warm-2);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== LAYOUT ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo img {
    height: 32px;
    width: auto;
}

.sidebar-logo-label {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.sidebar-nav a svg,
.sidebar-nav a .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.sidebar-nav a:hover svg,
.sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-nav a.active {
    background: rgba(196,26,24,0.25);
    color: #fff;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--red);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav a.active svg,
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-nav .nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 8px 20px;
}

.sidebar-nav .nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    padding: 12px 20px 4px;
    font-weight: 600;
}

.sidebar-bottom {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

.sidebar-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.4);
    padding: 4px;
    display: flex;
    border-radius: 4px;
    transition: color var(--transition);
    flex-shrink: 0;
}

.sidebar-logout:hover { color: #fff; }

/* ===== TOPBAR (mobile) ===== */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--ink);
    z-index: 99;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.topbar-burger {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    border-radius: 6px;
    flex-shrink: 0;
}

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

.topbar-logo img { height: 26px; }

.topbar-site-link {
    background: rgba(255,255,255,0.08);
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    padding: 7px;
    display: flex;
    border-radius: 8px;
    text-decoration: none;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

.topbar-site-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
}

.page-subtitle {
    font-size: 13px;
    color: var(--secondary);
    margin-top: 2px;
}

.page-body {
    padding: 24px 28px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover { background: var(--warm-1); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.btn-ghost:hover { background: var(--warm-2); color: var(--ink); }

.btn-danger {
    background: #fff;
    color: #b91c1c;
    border-color: #fca5a5;
}

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

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 7px; gap: 0; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition);
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(196,26,24,0.1);
}

.form-control::placeholder { color: var(--secondary); }

.form-select {
    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='%23888480' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-hint {
    font-size: 12px;
    color: var(--secondary);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: #b91c1c;
    margin-top: 4px;
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

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

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--secondary);
    background: var(--warm-1);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--warm-2);
    color: var(--text);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--warm-1); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-admin    { background: #fef2f2; color: #991b1b; }
.badge-journalist { background: #eff6ff; color: #1e40af; }

/* ===== ALERT ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== DRAWER (slide-up panel) ===== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16,15,15,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    z-index: 201;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.32,0.72,0,1);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.drawer.open { transform: translateY(0); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.drawer-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.drawer-close {
    background: var(--warm-2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 18px;
    transition: background var(--transition);
}

.drawer-close:hover { background: var(--border); }

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* На десктопе drawer = modal по центру */
@media (min-width: 768px) {
    .drawer {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        width: 480px;
        max-height: 85vh;
        transform: translate(-50%, -40%);
        border-radius: var(--radius-lg);
        opacity: 0;
        pointer-events: none;   /* ← ключевое: не перехватывает клики когда закрыт */
        visibility: hidden;
        transition: transform 220ms ease, opacity 220ms ease, visibility 220ms;
    }

    .drawer.open {
        transform: translate(-50%, -50%);
        opacity: 1;
        pointer-events: all;
        visibility: visible;
    }
}

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16,15,15,0.6);
    z-index: 98;
}

/* ===== MOBILE ===== */
@media (max-width: 767px) {
    .topbar { display: flex; }

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

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .sidebar-overlay.open { display: block; }

    .main-content {
        margin-left: 0;
        padding-top: var(--topbar-h);
    }

    .page-header {
        padding: 16px;
        position: sticky;
        top: var(--topbar-h);
        z-index: 10;
    }

    .page-body { padding: 16px; }

    .page-title { font-size: 17px; }
}

/* ===== INPUT WITH ICON / TOGGLE ===== */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .form-control {
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 10px;
    color: var(--secondary);
    display: flex;
    pointer-events: none;
    z-index: 1;
}

.input-icon + .form-control { padding-left: 34px; }

.input-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.input-toggle:hover { color: var(--ink); }

/* Padding-right чтобы текст не залезал под глазик */
.input-wrap .form-control:has(~ .input-toggle),
.input-wrap input[type="password"],
.input-wrap input[type="text"] + .input-toggle ~ * {
    padding-right: 36px;
}

.input-wrap .form-control { padding-right: 36px; }

/* ===== UTILITIES ===== */
.flex   { display: flex; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--secondary); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }