/* Sulpak AI Course Builder — стили UI */

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f4f7f6;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.5;
}

a { color: #db2d2d; text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: #64748b; }
.small { font-size: 13px; }
.mt { margin-top: 24px; }

/* ---- Topbar ---- */
.topbar {
    background: #db2d2d;
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.brand a { color: white; font-weight: 700; font-size: 16px; }
.topnav { display: flex; gap: 18px; flex: 1; }
.topnav a { color: rgba(255,255,255,0.9); font-weight: 500; }
.topnav a:hover { color: white; text-decoration: none; }
.user-block { display: flex; align-items: center; gap: 12px; }
.user-login { font-weight: 600; }

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

/* ---- Login card ---- */
.login-card {
    max-width: 420px;
    margin: 60px auto;
    background: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.login-card h1 { margin-top: 0; }

/* ---- Forms ---- */
.form-vertical { display: flex; flex-direction: column; gap: 14px; }
.form-vertical label, .course-form label { display: flex; flex-direction: column; gap: 4px; }
.form-vertical label > span, .course-form label > span { font-weight: 600; font-size: 14px; }

input[type="text"], input[type="password"], input[type="number"],
input[type="url"], input[type="email"], input[type="file"],
select, textarea {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #db2d2d;
    box-shadow: 0 0 0 3px rgba(219,45,45,0.15);
}
textarea { resize: vertical; min-height: 80px; }

.full-width { width: 100%; }
.prio { width: 70px; }

/* ---- Buttons ---- */
.btn-primary {
    background: #db2d2d;
    color: white;
    border: none;
    padding: 12px 22px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.btn-primary:hover { background: #b91c1c; }
.btn-primary.big { padding: 16px 28px; font-size: 17px; width: 100%; margin-top: 24px; }
.btn-link {
    background: none;
    color: #db2d2d;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}
.btn-link.danger { color: #94a3b8; }
.btn-link.danger:hover { color: #ef4444; }
.inline { display: inline; }

/* ---- Course form blocks ---- */
.block {
    background: white;
    border-radius: 10px;
    padding: 20px 24px;
    margin: 18px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.block h2 { margin-top: 0; font-size: 18px; }
.block h3 { font-size: 15px; margin-top: 20px; margin-bottom: 8px; }
.block summary {
    font-weight: 700;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
    font-size: 16px;
}
details.block[open] summary { margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.checkrow {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.checkrow input[type="checkbox"] { width: auto; }
.checkrow > span { font-weight: 500 !important; font-size: 14px !important; }

.url-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.radio-pill {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
    cursor: pointer;
}
.radio-pill input { width: auto; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}
.alert.error { background: #fee2e2; color: #991b1b; }

/* ---- Jobs ---- */
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.jobs-table th, .jobs-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.jobs-table th { background: #f8fafc; font-weight: 700; font-size: 13px; text-transform: uppercase; color: #475569; }
.jobs-table tr:last-child td { border-bottom: none; }

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.status-generating, .status-finalizing { background: #fef3c7; color: #92400e; }
.status-awaiting_edit { background: #dbeafe; color: #1e40af; }
.status-done { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: #e5e7eb; color: #374151; }

/* ---- Мои задачи v2 ---- */
.jobs-table td { vertical-align: middle; }
.ta-right { text-align: right !important; }

.jobs-empty {
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
}
.jobs-empty .btn-primary { display: inline-block; margin-top: 12px; text-decoration: none; }

.job-topic .topic-text {
    display: block;
    font-weight: 600;
    color: #1e293b;
}
.job-topic .job-id {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: #b6c0cc;
    font-family: 'Consolas', 'Monaco', monospace;
    user-select: all;
}
.job-date { font-size: 13px; color: #475569; white-space: nowrap; }

.kind-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    background: #eef2f7;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
}

.st-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.st-chip.st-active { background: #dbeafe; color: #1e40af; }
.st-chip.st-warn   { background: #fef3c7; color: #92400e; }
.st-chip.st-ok     { background: #d1fae5; color: #065f46; }
.st-chip.st-err    { background: #fee2e2; color: #991b1b; }
.st-chip.st-muted  { background: #e5e7eb; color: #374151; }
.st-error {
    margin-top: 5px;
    font-size: 12px;
    color: #991b1b;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.act {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
}
.act-primary {
    background: #16a34a;
    color: #fff;
}
.act-primary:hover { background: #15803d; text-decoration: none; }
.act-secondary {
    background: #fff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.act-secondary:hover { background: #eff6ff; text-decoration: none; }
.act-del-form { margin-left: 6px; }
.act-del {
    background: transparent;
    color: #94a3b8;
    border-color: #e2e8f0;
    font-weight: 500;
}
.act-del:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* Адаптив: на узком экране таблица превращается в карточки */
@media (max-width: 720px) {
    .jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
    .jobs-table thead { display: none; }
    .jobs-table tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        margin-bottom: 14px;
        padding: 6px 4px;
    }
    .jobs-table td { border: none !important; padding: 8px 16px; }
    .job-actions { justify-content: flex-start; }
    .st-error { max-width: none; white-space: normal; }
}

/* ---- Админ: Все задачи (компактно) ---- */
.adm-jobs-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 18px; margin-bottom: 14px; }
.adm-jobs-head h2 { margin: 0; }
.adm-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.adm-pill {
    background: #f1f5f9; color: #475569;
    padding: 3px 10px; border-radius: 999px; font-size: 12px;
}
.adm-pill-live { background: #dbeafe; color: #1e40af; }
.st-chip.adm-mini { font-size: 11px; padding: 3px 9px; text-decoration: none; }
.st-chip.adm-mini:hover { filter: brightness(.95); }

.adm-filters {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding: 12px; background: #f8fafc; border-radius: 9px; margin-bottom: 10px;
}
.adm-filters select, .adm-filters .adm-search {
    padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 7px;
    font-size: 13px; background: #fff;
}
.adm-filters .adm-search { flex: 1; min-width: 180px; }
.adm-btn-sm { padding: 7px 16px !important; font-size: 13px !important; }

.adm-cleanup {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
    margin-bottom: 12px; font-size: 13px;
}

.adm-bulkbar {
    display: flex; align-items: center; gap: 16px;
    padding: 8px 4px; border-bottom: 2px solid #e5e7eb; margin-bottom: 2px;
}
.adm-selall { font-size: 13px; color: #475569; cursor: pointer; display: flex; align-items: center; gap: 6px; }

/* плотная таблица */
.adm-jobs th, .adm-jobs td { padding: 7px 10px !important; font-size: 13px; vertical-align: middle; }
.adm-jobs th { font-size: 11px; }
.adm-jobs .adm-cb { width: 28px; text-align: center; }
.adm-jobs .adm-owner { color: #1e293b; font-weight: 600; text-decoration: none; }
.adm-jobs .adm-owner:hover { color: #db2d2d; text-decoration: underline; }
.adm-topic .topic-text { font-weight: 500; }
.adm-topic .job-id {
    display: inline-block; margin-left: 0; margin-top: 2px;
    font-size: 10px; color: #b6c0cc; font-family: 'Consolas','Monaco',monospace;
}
.adm-topic .st-error { display: block; max-width: 360px; }
.adm-jobs .st-chip { font-size: 12px; padding: 3px 10px; }
.adm-jobs .job-date { font-size: 12px; color: #64748b; white-space: nowrap; }
/* ячейка действий остаётся обычной table-cell — иначе ломается
   высота строки и разделители «плывут» */
.adm-jobs td.job-actions {
    display: table-cell;
    white-space: nowrap;
    text-align: right;
    vertical-align: middle;
}
.adm-jobs td.job-actions .act {
    padding: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
    margin-left: 6px;
}
.adm-jobs td.job-actions form { display: inline; }
.adm-hidden-form { display: none; }

.downloads { list-style: none; padding: 0; }
.downloads li { margin: 8px 0; }

/* ---- Admin ---- */
.admin-link {
    background: rgba(255,255,255,0.18);
    padding: 4px 10px;
    border-radius: 6px;
}
.admin-link:hover { background: rgba(255,255,255,0.3); text-decoration: none; }

.admin-wrap { max-width: 1200px; margin: 0 auto; }
.admin-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
}
.admin-tabs .tab {
    padding: 10px 18px;
    color: #64748b;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
}
.admin-tabs .tab:hover { color: #db2d2d; text-decoration: none; }
.admin-tabs .tab.active {
    color: #db2d2d;
    border-bottom-color: #db2d2d;
}

.alert.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
    padding: 16px;
    border-radius: 6px;
}
.password-box { margin: 12px 0; }
.big-password {
    display: inline-block;
    background: white;
    color: #1e293b;
    font-size: 22px;
    font-family: 'Consolas', monospace;
    padding: 10px 16px;
    border-radius: 6px;
    border: 2px dashed #10b981;
    letter-spacing: 1px;
    user-select: all;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.inline-form input[type="text"] { flex: 1; min-width: 200px; max-width: 400px; }
.checkrow.inline { padding: 0; }

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.actions.vertical { flex-direction: column; align-items: flex-start; }
.actions form button { white-space: nowrap; }

.filters {
    display: flex;
    gap: 6px;
    margin: 12px 0;
    flex-wrap: wrap;
}
.filter {
    padding: 4px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    text-decoration: none;
}
.filter:hover { background: #e2e8f0; text-decoration: none; }
.filter.active { background: #db2d2d; color: white; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.card {
    background: white;
    padding: 18px 20px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.card h3 { margin: 0 0 8px 0; font-size: 14px; color: #64748b; font-weight: 600; }
.card .big { font-size: 28px; font-weight: 700; margin: 4px 0; color: #1e293b; }

/* ---- Audit ---- */
.audit-filters {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px;
    background: #f8fafc;
    border-radius: 8px;
}
.audit-filters > div { display: flex; flex-direction: column; gap: 4px; }
.audit-filters input, .audit-filters select { min-width: 180px; }
.audit-label { font-size: 12px; font-weight: 600; color: #475569; }
.audit-table td.nowrap { white-space: nowrap; }

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

/* ---- Settings form ---- */
.settings-form .setting-row {
    padding: 14px 0;
    border-bottom: 1px solid #e5e7eb;
}
.settings-form .setting-row:last-child { border-bottom: none; }
.settings-form .setting-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}
.setting-input {
    max-width: 200px !important;
    display: inline-block !important;
    margin-right: 10px;
}

/* ---- Settings v2: понятные карточки ---- */
.cfg-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 18px;
}
.cfg-card > h3 {
    margin: 0 0 4px 0;
    font-size: 17px;
}
.cfg-card .cfg-desc { margin: 0 0 16px 0; color: #64748b; font-size: 13px; }
.cfg-line {
    font-size: 15px;
    line-height: 2.4;
    margin: 6px 0;
}
.cfg-line input[type="number"] {
    width: 84px;
    padding: 7px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 15px;
    text-align: center;
}
.cfg-line select {
    padding: 7px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 15px;
}
.cfg-sub {
    margin: 10px 0 0 0;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 9px;
}
.cfg-sub.cfg-off { opacity: .45; }
.cfg-note {
    margin: 14px 0 0 0;
    padding: 12px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 9px;
    font-size: 13px;
    color: #92400e;
    line-height: 1.6;
}
.cfg-env {
    margin: 14px 0 0 0;
    font-size: 12px;
    color: #94a3b8;
}
.cfg-env code { color: #64748b; }

/* статус-плашка вкл/выкл */
.cfg-state {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    margin-left: 10px;
    vertical-align: middle;
}
.cfg-state.on  { background: #dcfce7; color: #166534; }
.cfg-state.off { background: #fee2e2; color: #991b1b; }

/* переключатель-тумблер */
.switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 4px 0 6px 0;
}
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background .18s;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 22px; width: 22px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .18s;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: #16a34a; }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch-text { font-weight: 700; font-size: 15px; }
.cfg-save { margin-top: 8px; }

/* ---- Period selector bar ---- */
.period-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 16px;
}
.period-bar select { max-width: 220px; }

/* ---- Log panel ---- */
.log-panel {
    background: #1e1e1e;
    color: #00ff88;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12.5px;
    max-height: 480px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
