/* MarathiGold News Dashboard */

:root {
    --bg:        #0f1115;
    --panel:     #171a21;
    --panel-2:   #1e222b;
    --border:    #2a2f3a;
    --text:      #e6e8ec;
    --muted:     #9aa3b2;
    --gold:      #e0aa3e;
    --gold-dim:  #8a6a26;
    --green:     #3fb950;
    --red:       #f85149;
    --blue:      #58a6ff;
    --radius:    10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Devanagari",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
}
pre.code {
    display: block;
    padding: 12px 14px;
    overflow-x: auto;
    white-space: pre;
    color: var(--gold);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------------- top bar ---------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.brand {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.brand em { color: var(--gold); font-style: normal; }
.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 12px var(--gold);
}

.tabs { display: flex; gap: 4px; }
.tab {
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--gold); font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------------- buttons ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: #262b35; border-color: #3a4150; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
    background: var(--gold);
    border-color: var(--gold);
    color: #1b1405;
    font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: #f0bb4d; border-color: #f0bb4d; }

.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #4a2b2b; }
.btn.danger:hover:not(:disabled) { background: #2b1a1a; }
.btn.block { width: 100%; justify-content: center; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.icon-btn {
    background: none; border: 0; color: var(--muted);
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.icon-btn:hover { color: var(--text); }
.ico { font-size: 15px; }

/* ---------------- layout ---------------- */

.view { padding: 20px; max-width: 1240px; margin: 0 auto; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.panel h2 { margin: 0 0 6px; font-size: 16px; }
.panel > p { margin-top: 0; }

/* ---------------- filters ---------------- */

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
}

.stats { margin-left: auto; display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--gold); }

input, select, textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 11px;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    min-width: 0;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold-dim);
}
textarea { width: 100%; resize: vertical; line-height: 1.6; }
#filterQuery { flex: 1; min-width: 180px; }

.row-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-form input[type="text"], .row-form input[type="url"] { flex: 1; min-width: 180px; }

.advanced { margin-top: 14px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.advanced input { width: 100%; margin: 8px 0 4px; }

/* ---------------- article cards ---------------- */

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
    display: flex;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: border-color .12s;
}
.card:hover { border-color: #3a4150; }
.card.is-drafted { border-left: 3px solid var(--green); }
.card.is-rewritten { border-left: 3px solid var(--gold); }
.card.is-error { border-left: 3px solid var(--red); }

.card-thumb {
    width: 108px; height: 74px;
    flex: 0 0 108px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel-2);
}

.card-main { flex: 1; min-width: 0; }
.card-title {
    font-size: 15.5px;
    font-weight: 600;
    margin: 0 0 5px;
    line-height: 1.45;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--gold); text-decoration: none; }

.card-meta {
    display: flex; gap: 10px; flex-wrap: wrap;
    font-size: 12.5px; color: var(--muted); margin-bottom: 6px;
}
.card-meta .src { color: var(--gold); font-weight: 600; }

.card-summary {
    font-size: 13.5px; color: var(--muted);
    margin: 0 0 10px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--muted);
}
.badge.green { color: var(--green); border-color: #1e3d24; background: #101c12; }
.badge.gold  { color: var(--gold);  border-color: #4a3a15; background: #1e1809; }
.badge.red   { color: var(--red);   border-color: #4a2b2b; background: #1e1010; }

/* ---------------- tables ---------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; margin-bottom: 12px; }
.kv dt, .kv .k { color: var(--muted); }

/* ---------------- pager / toast / alerts ---------------- */

.pager { display: flex; gap: 6px; justify-content: center; margin: 22px 0 40px; flex-wrap: wrap; }

.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--panel-2); border: 1px solid var(--border);
    padding: 11px 18px; border-radius: 9px; z-index: 200;
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
    max-width: 90vw;
}
.toast.err { border-color: #5a2b2b; color: #ffb4ae; }
.toast.ok  { border-color: #1e4d28; color: #93e0a1; }

.alert { padding: 10px 13px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.alert.error   { background: #1e1010; border: 1px solid #4a2b2b; color: #ffb4ae; }
.alert.success { background: #101c12; border: 1px solid #1e3d24; color: #93e0a1; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

.spinner {
    width: 15px; height: 15px;
    border: 2px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    display: inline-block;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- modal ---------------- */

.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.72);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 30px 16px; z-index: 100; overflow-y: auto;
}

/* The `display: flex` above outranks the browser's own `[hidden] {display:none}`
   rule, so without this the modal is permanently on screen and the close
   button appears to do nothing. Keep this immediately after .modal. */
.modal[hidden] { display: none; }
.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%; max-width: 860px;
    display: flex; flex-direction: column;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot {
    padding: 13px 18px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea { width: 100%; }

.preview {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    max-height: 340px;
    overflow-y: auto;
    font-size: 14.5px;
    line-height: 1.75;
}
.preview h2 { font-size: 16px; margin: 18px 0 8px; color: var(--gold); }
.preview p { margin: 0 0 12px; }
.preview ul { margin: 0 0 12px; padding-left: 22px; }

/* ---------------- login ---------------- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 30px 28px;
    width: 100%; max-width: 380px;
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { font-size: 20px; margin: 0; }
.login-brand em { color: var(--gold); font-style: normal; }
.login-card label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 5px; }
.login-card button { margin-top: 20px; }

/* ---------------- responsive ---------------- */

@media (max-width: 720px) {
    .topbar { gap: 12px; padding: 10px 14px; }
    .topbar-right { width: 100%; margin-left: 0; }
    .view { padding: 14px; }
    .card { flex-direction: column; }
    .card-thumb { width: 100%; height: 150px; flex: none; }
    .stats { width: 100%; margin-left: 0; }
}
