/* ============================================================
   TG Channel Management System — style.css
   Clean, compact, professional dark-sidebar layout
   ============================================================ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
    --sidebar-width:      220px;
    --sidebar-bg:         #16213e;
    --sidebar-bg-hover:   #1a2a50;
    --sidebar-bg-active:  #0f3460;
    --sidebar-text:       #c8d3ea;
    --sidebar-text-muted: #6b7db3;
    --sidebar-border:     #1e2d52;
    --sidebar-accent:     #0088cc;

    --topbar-height:      52px;
    --topbar-bg:          #ffffff;
    --topbar-border:      #e2e8f0;

    --main-bg:            #f8f9fa;
    --card-bg:            #ffffff;
    --card-shadow:        0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
    --card-radius:        8px;

    --font-size-sm:       0.8125rem;  /* 13px */
    --font-size-base:     0.875rem;   /* 14px */
    --transition:         0.18s ease;
}

/* ─── Reset / base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--font-size-base);
    background: var(--main-bg);
    color: #212529;
}

/* ─── Custom scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #c1cfe0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #97aac6; }

/* ─── Sidebar ────────────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition);
}

/* Header / logo area */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 6px;
}

.sidebar-brand {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.sidebar-brand span {
    font-weight: 400;
    color: var(--sidebar-text);
    margin-left: 1px;
}

/* Nav list */
.sidebar-nav {
    list-style: none;
    margin: 8px 0;
    padding: 0;
    flex: 1;
}

.sidebar-nav li { margin: 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 400;
    white-space: nowrap;
    border-left: 2px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    position: relative;
}

.sidebar-link:hover {
    background: var(--sidebar-bg-hover);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-bg-active);
    color: #ffffff;
    border-left-color: var(--sidebar-accent);
    font-weight: 500;
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--transition);
}

.sidebar-link:hover .nav-icon,
.sidebar-link.active .nav-icon {
    opacity: 1;
}

/* Footer */
.sidebar-footer {
    padding: 10px 16px 14px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.text-sidebar-muted {
    color: var(--sidebar-text-muted);
    font-size: 0.75rem;
}

/* ─── Main wrapper ───────────────────────────────────────────── */
#main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* ─── Topbar ─────────────────────────────────────────────────── */
#topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.btn-topbar-toggle {
    background: none;
    border: none;
    color: #6c757d;
    padding: 4px 6px;
    line-height: 1;
}

.btn-topbar-toggle:hover { color: #212529; background: #f0f2f5; }

.btn-topbar-user {
    background: none;
    border: 1px solid #e2e8f0;
    color: #374151;
    padding: 4px 10px;
    font-size: var(--font-size-sm);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
}

.btn-topbar-user:hover { background: #f8f9fa; border-color: #cbd5e1; }

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--sidebar-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ─── Page content ───────────────────────────────────────────── */
#page-content {
    flex: 1;
    padding: 20px 24px;
    max-width: 100%;
}

/* Page titles */
.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 16px;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #f0f2f5;
    padding: 12px 16px;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: #374151;
}

.card-body {
    padding: 16px;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table {
    font-size: var(--font-size-sm);
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    border-bottom-width: 1px;
    white-space: nowrap;
    padding: 8px 12px;
}

.table td {
    padding: 8px 12px;
    vertical-align: middle;
    border-color: #f0f2f5;
}

.table-hover tbody tr:hover { background: #f8faff; }

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background: #fafbfc;
}

/* ─── Badges / Status colors ─────────────────────────────────── */
/* tg_scored.status */
.badge-new        { background-color: #0dcaf0 !important; color: #000 !important; }
.badge-approved   { background-color: #198754 !important; }
.badge-rejected   { background-color: #dc3545 !important; }
.badge-generated  { background-color: #0d6efd !important; }
.badge-scheduled  { background-color: #ffc107 !important; color: #000 !important; }
.badge-published  { background-color: #198754 !important; }

/* tg_posts.status */
.badge-draft     { background-color: #6c757d !important; }
.badge-ready     { background-color: #0d6efd !important; }
.badge-failed    { background-color: #dc3545 !important; }

/* tg_queue.status */
.badge-pending     { background-color: #ffc107 !important; color: #000 !important; }
.badge-publishing  { background-color: #0dcaf0 !important; color: #000 !important; }
.badge-cancelled   { background-color: #6c757d !important; }

/* Generic status helper */
.status-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Score indicator */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 22px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.score-high   { background: #198754; }
.score-medium { background: #ffc107; color: #000; }
.score-low    { background: #dc3545; }

/* ─── Buttons (compact) ──────────────────────────────────────── */
.btn-sm {
    font-size: 0.8rem;
    padding: 3px 9px;
}

.btn-xs {
    font-size: 0.75rem;
    padding: 2px 7px;
    line-height: 1.4;
    border-radius: 4px;
}

.btn-group-actions .btn { margin-right: 2px; }

/* ─── Form elements ──────────────────────────────────────────── */
.form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.form-control, .form-select {
    font-size: var(--font-size-sm);
}

.form-text {
    font-size: 0.75rem;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
    font-size: var(--font-size-sm);
    padding: 10px 14px;
    border-radius: 6px;
}

/* ─── KPI / Stat cards ───────────────────────────────────────── */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

/* ─── Pipeline flow indicator ────────────────────────────────── */
.pipeline-step {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f0f2f5;
    color: #6b7280;
    font-weight: 500;
}

.pipeline-step.active {
    background: #e0f0ff;
    color: #0d6efd;
}

.pipeline-step.done {
    background: #dcfce7;
    color: #15803d;
}

/* ─── Toast notifications ────────────────────────────────────── */
.toast {
    font-size: var(--font-size-sm);
    min-width: 260px;
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    opacity: 0.35;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: var(--font-size-sm);
    margin: 0;
}

/* ─── Inline action feedback ─────────────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

/* ─── Compact pagination ─────────────────────────────────────── */
.pagination {
    gap: 2px;
}

.page-link {
    font-size: 0.8rem;
    padding: 4px 9px;
}

/* ─── Responsive — collapse sidebar on mobile ────────────────── */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    #sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.25);
    }

    #main-wrapper {
        margin-left: 0;
    }
}

/* Overlay when sidebar open on mobile */
#sidebar.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0 0 0 var(--sidebar-width);
    background: rgba(0,0,0,.35);
    z-index: -1;
}

/* ─── Misc utilities ─────────────────────────────────────────── */
.text-mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.8rem; }
.cursor-pointer { cursor: pointer; }
.border-start-accent { border-left: 3px solid var(--sidebar-accent) !important; }
.nowrap { white-space: nowrap; }

/* Truncate multi-line */
.text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Subtle row highlight for actions */
tr.row-approved td { background: #f0fdf4 !important; }
tr.row-rejected td { background: #fef2f2 !important; }

/* ─── Login page ─────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #16213e 0%, #0f3460 50%, #1a1a2e 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.login-header {
    background: var(--sidebar-bg, #16213e);
    padding: 28px 32px 24px;
    text-align: center;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.login-logo svg {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.login-logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.login-logo-text span {
    font-weight: 400;
    color: #c8d3ea;
    margin-left: 1px;
}

.login-subtitle {
    color: #8a9cc5;
    font-size: 0.85rem;
    margin-top: 4px;
}

.login-body {
    padding: 28px 32px 24px;
}

.login-body .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.login-body .form-control {
    padding: 10px 14px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-body .form-control:focus {
    border-color: #0088cc;
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.15);
}

.btn-login {
    width: 100%;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    background: #0088cc;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-login:hover {
    background: #006da3;
}

.login-footer-text {
    text-align: center;
    margin-top: 20px;
    font-size: 0.75rem;
    color: #9ca3af;
}

@media (max-width: 480px) {
    .login-card {
        max-width: 100%;
    }
    .login-header {
        padding: 22px 20px 18px;
    }
    .login-body {
        padding: 22px 20px 18px;
    }
}

/* === v1.2: шрифт 1rem === */
:root {
  --font-size-sm:   0.9rem;
  --font-size-base: 1rem;
}
body, .table, .form-control, .form-select, .btn, .nav-link, .dropdown-item {
  font-size: var(--font-size-base);
}
.small, small { font-size: 0.875em; }
.badge        { font-size: 0.8em; }
.status-badge { font-size: 0.78rem; }



/* === Menu group labels === */
.nav-group-label {
    padding: 12px 16px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text-muted);
    margin-top: 8px;
}

.nav-group-label:first-child {
    margin-top: 0;
}

