/* Telegram bot console theme. Loaded after admin.php's legacy styles so the
   existing server-rendered screens can be upgraded without changing queries. */
:root {
    --ink: #162638;
    --muted: #6b7b8e;
    --line: #e4eaf0;
    --canvas: #f3f6f9;
    --panel: #ffffff;
    --nav: #10283b;
    --nav-soft: #193b53;
    --accent: #0c8f91;
    --accent-dark: #087174;
    --good: #18864b;
    --warn: #b7791f;
    --danger: #c23b4a;
    --shadow: 0 8px 26px rgba(21, 44, 66, .07);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

/* Login screen (the unauthenticated branch exits before the main layout). */
body:has(.login-box), body:has(.login) {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: radial-gradient(circle at 15% 10%, #d9eff0 0, transparent 42%), var(--canvas);
}
.login-box, .login {
    width: min(420px, 100%);
    min-width: 0 !important;
    padding: 34px 32px !important;
    text-align: left !important;
    background: rgba(255,255,255,.96) !important;
    border: 1px solid var(--line);
    border-radius: 12px !important;
    box-shadow: 0 18px 48px rgba(21,44,66,.13) !important;
}
.login-box h2, .login h1 { margin: 0 0 22px; color: var(--ink) !important; font-size: 22px; }
.login-box input, .login input { min-height: 44px; margin: 4px 0 12px !important; padding: 10px 12px !important; border-color: #cfd9e2 !important; }
.login-box button, .login button { min-height: 44px; margin-top: 4px; }

.container { min-height: 100vh; background: var(--canvas); }
.sidebar {
    width: 264px;
    flex: 0 0 264px;
    padding: 24px 16px;
    background: var(--nav);
    border-right: 1px solid rgba(255,255,255,.06);
    box-shadow: 8px 0 28px rgba(13, 34, 50, .08);
    position: relative;
    z-index: 20;
}
.sidebar h3 {
    margin: 0 8px 24px;
    padding: 0 0 20px;
    color: #f5fbfd;
    border-bottom: 1px solid rgba(255,255,255,.13);
    font-size: 18px;
    letter-spacing: .01em;
}
.sidebar h3::after {
    content: "CONTROL CENTER";
    display: block;
    margin-top: 5px;
    color: #7fa4b8;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .16em;
}
.sidebar a {
    display: flex;
    align-items: center;
    min-height: 44px;
    gap: 10px;
    margin: 3px 0;
    padding: 10px 12px;
    color: #bcd0dc;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 500;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.sidebar a:hover, .sidebar a.active {
    color: #fff;
    background: var(--nav-soft);
    border-color: rgba(127, 222, 218, .18);
    transform: translateX(2px);
}
.sidebar a[href*="logout"] { margin-top: 24px; color: #e8a5ac; }
.sidebar a[href*="logout"]:hover { color: #fff; background: rgba(194,59,74,.23); border-color: rgba(255,160,170,.2); }

.content {
    min-width: 0;
    padding: 28px clamp(18px, 3vw, 42px) 48px;
}
.content > .bot-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0 0 22px;
    padding: 13px 16px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(21,44,66,.03);
}
.bot-selector label { color: var(--ink); font-weight: 600; }
.bot-selector select, select, input[type="text"], input[type="search"], input[type="password"] {
    min-height: 40px;
    padding: 8px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cfd9e2;
    border-radius: 7px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.bot-selector select { min-width: 220px; margin-left: 0; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(12,143,145,.13); }

.card {
    margin-bottom: 22px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 20px; color: var(--ink); font-size: 20px; letter-spacing: -.01em; }
.card h2 + p { color: var(--muted); }

.stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    min-height: 126px;
    padding: 19px 20px;
    background: linear-gradient(145deg, #0f6f77, #0b9695) !important;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(12, 143, 145, .18);
}
.stat-card:nth-child(2) { background: linear-gradient(145deg, #8c5d2a, #bd842d) !important; box-shadow: 0 8px 20px rgba(183,121,31,.18); }
.stat-card:nth-child(3) { background: linear-gradient(145deg, #2d557c, #3d77a5) !important; box-shadow: 0 8px 20px rgba(45,85,124,.18); }
.stat-card:nth-child(4) { background: linear-gradient(145deg, #9a4352, #c85d68) !important; box-shadow: 0 8px 20px rgba(194,59,74,.18); }
.stat-card h3 { margin-bottom: 5px; color: rgba(255,255,255,.82); font-size: 13px; font-weight: 600; }
.stat-card p { color: #fff; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border: 0; border-radius: 8px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #587084; background: #f6f8fa; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfc; }
code { padding: 3px 6px; color: #345369; background: #edf3f6; border-radius: 5px; font-size: 12px; }
.status, .badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-active, .badge-success { color: #176a3e; background: #e2f5e9; }
.badge.warn, .badge-warning { color: #8e5d16; background: #fff3d7; }
.badge.bad, .badge-danger { color: #9f2f3d; background: #fde8eb; }

button, .button {
    min-height: 38px;
    padding: 8px 14px;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 7px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 4px 12px rgba(8,113,116,.18); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { color: #3b586a; background: #f2f6f8; border-color: #d3dfe6; }
button.secondary:hover, .button.secondary:hover { background: #e6eef2; border-color: #bdccd6; box-shadow: none; }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); }
textarea { min-height: 100px; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd9e2; border-radius: 7px; resize: vertical; font: inherit; }
.reply-form { padding: 11px 0 2px; }
.reply-form textarea { margin: 8px 0; }

.content form[method="get"] { display: flex; gap: 9px; align-items: center; }
.content form[method="get"] input { flex: 1; width: auto !important; }
.content form[method="get"] button { width: auto !important; }

/* New optional building blocks used by the enhanced dashboard. */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 22px; }
.page-header h1 { margin: 0; color: var(--ink); font-size: 26px; line-height: 1.2; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.table-wrap { overflow-x: auto; }
.empty-state { padding: 38px 18px; color: var(--muted); text-align: center; border: 1px dashed #cbd8e1; border-radius: 8px; }
.health-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: var(--good); border-radius: 50%; vertical-align: middle; }
.health-dot.offline { background: var(--danger); }
.toast-stack { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; color: #fff; background: #1c3547; border-left: 3px solid #62d4d0; border-radius: 7px; box-shadow: 0 10px 26px rgba(10,30,45,.24); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: #ef8e98; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 820px) {
    .container { display: block; }
    .sidebar { width: 100%; min-height: auto; padding: 12px 14px; }
    .sidebar-toggle { display: inline-flex; position: absolute; top: 12px; right: 14px; }
    .sidebar h3 { margin: 0 4px 9px; padding-bottom: 11px; font-size: 16px; }
    .sidebar h3::after { display: none; }
    .sidebar a { display: inline-flex; min-height: 36px; margin: 2px; padding: 7px 9px; font-size: 13px; }
    .sidebar a[href*="logout"] { margin-top: 2px; }
    .content { padding: 18px 13px 30px; }
    .card { padding: 17px 14px; }
    .card h2 { font-size: 18px; }
    .bot-selector { align-items: stretch !important; }
    .bot-selector select { width: 100%; min-width: 0; }
    .content form[method="get"] { align-items: stretch; flex-wrap: wrap; }
    .content form[method="get"] input, .content form[method="get"] button { width: 100% !important; }
    table { min-width: 680px; }
    .table-wrap { margin: 0 -14px; padding: 0 14px; }
    .page-header { display: block; }
    .page-header .toolbar { margin-top: 12px; }
}

.sidebar-toggle { display: none; align-items: center; justify-content: center; width: 38px; min-height: 36px; padding: 0; }
@media (max-width: 820px) {
    .sidebar-toggle { display: inline-flex; position: absolute; top: 12px; right: 14px; }
    .sidebar.is-collapsed { display: none; }
    .sidebar.is-open { display: block; }
}

/* The current dashboard uses .shell/.main names; align them with the shared
   theme so it remains visually consistent even when inline page CSS changes. */
.shell { display: flex; min-height: 100vh; background: var(--canvas); }
.shell > .sidebar { width: 264px; flex-basis: 264px; }
.shell .content { min-width: 0; flex: 1; }
.shell .main { max-width: 1500px; }
@media (max-width: 820px) {
    .shell { display: block; }
    .shell > .sidebar { width: 100%; }
    .shell .main { padding: 18px 13px 30px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
