/* ============================================================
   AI Writer Panel — RTL Hebrew design system
   Inspired by RankUp / Ubersuggest: light bg, indigo-violet
   accents, white cards, soft shadows. No build step required.
   ============================================================ */

:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --primary-soft: #f0edff;
    --gradient: linear-gradient(135deg, #6c5ce7 0%, #8e7bff 100%);
    --bg: #f4f5fa;
    --card: #ffffff;
    --border: #e9e9f2;
    --text: #23233a;
    --muted: #7a7a95;
    --green: #16a34a;
    --green-soft: #e6f7ee;
    --red: #dc2626;
    --red-soft: #fdeaea;
    --amber: #d97706;
    --amber-soft: #fdf3e3;
    --blue: #2563eb;
    --blue-soft: #e8f0fe;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(35, 35, 58, .06), 0 6px 18px rgba(35, 35, 58, .05);
    --sidebar-w: 250px;
}

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

html, body {
    font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    direction: rtl;
}

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

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-left: 1px solid var(--border);
    position: fixed;
    top: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-weight: 800;
    font-size: 18px;
}

.sidebar-brand .logo {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--gradient);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    box-shadow: 0 4px 12px rgba(108, 92, 231, .4);
}

.sidebar-section {
    padding: 10px 12px 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .4px;
}

.sidebar a.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #4a4a63;
    font-weight: 500;
    font-size: 14.5px;
    transition: background .15s, color .15s;
}

.sidebar a.nav-item .ico { width: 21px; text-align: center; font-style: normal; opacity: .85; }
.sidebar a.nav-item:hover { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar a.nav-item.active { background: var(--gradient); color: #fff; box-shadow: 0 4px 12px rgba(108, 92, 231, .35); }

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Main ---------- */
.main {
    margin-right: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar h1 { font-size: 20px; font-weight: 800; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.content { padding: 26px 28px 50px; max-width: 1280px; width: 100%; }

/* ---------- Cards & stats ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 22px;
}

.card-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat .stat-ico {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: var(--primary-soft);
}

.stat .stat-num { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat .stat-label { font-size: 13px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

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

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
    text-align: right;
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid #f1f1f7; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #fafaff; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #f0f0f6; color: var(--muted); }
.badge.violet { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=url], select, textarea {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, .15);
}

input[disabled], input[readonly] { background: #f7f7fb; color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform .06s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(108, 92, 231, .35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fbdcdc; }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- Flash / alerts ---------- */
.alert {
    border-radius: 12px;
    padding: 13px 17px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
}
.alert-success { background: var(--green-soft); color: var(--green); border-color: #bfe8d0; }
.alert-danger { background: var(--red-soft); color: var(--red); border-color: #f5c6c6; }
.alert-warning { background: var(--amber-soft); color: var(--amber); border-color: #f3ddae; }
.alert-info { background: var(--blue-soft); color: var(--blue); border-color: #c6dbfb; }

/* ---------- Login page ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(30, 20, 80, .35);
    padding: 38px 34px;
    width: 100%;
    max-width: 420px;
}
.auth-card .auth-logo {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: var(--gradient);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 20px rgba(108, 92, 231, .45);
}
.auth-card h2 { text-align: center; font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }

.otp-input {
    text-align: center;
    font-size: 26px;
    letter-spacing: 10px;
    font-weight: 800;
    direction: ltr;
}

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.empty {
    text-align: center;
    padding: 42px 20px;
    color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }

.progress {
    height: 8px;
    border-radius: 99px;
    background: #efeff5;
    overflow: hidden;
    min-width: 90px;
}
.progress > div { height: 100%; background: var(--gradient); border-radius: 99px; }

.code-box {
    background: #23233a;
    color: #e9e9ff;
    border-radius: 10px;
    padding: 12px 16px;
    font-family: Consolas, monospace;
    direction: ltr;
    text-align: center;
    font-size: 15px;
    letter-spacing: 1px;
    user-select: all;
}

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 7px 13px;
    border-radius: 9px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 13.5px;
    color: var(--text);
}
.pagination .current { background: var(--gradient); color: #fff; border-color: transparent; }

/* ---------- Site Overview — Ahrefs-style dashboard card ---------- */
.ov-domain { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin-inline-start: 4px; }

.ov-grid {
    display: grid;
    grid-template-columns: minmax(240px, auto) minmax(280px, 1fr) minmax(230px, 270px);
    gap: 24px;
    align-items: start;
}
@media (max-width: 1180px) { .ov-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px)  { .ov-grid { grid-template-columns: 1fr; } }

.ov-badges { display: flex; gap: 22px; justify-content: center; }

.donut { position: relative; width: 92px; text-align: center; cursor: help; }
.donut svg { display: block; width: 92px; height: 92px; }
.donut circle { transition: stroke-dasharray .4s ease; }
.donut-num {
    position: absolute; top: 33px; right: 0; left: 0;
    font-size: 22px; font-weight: 800; line-height: 1;
}
.donut-label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-top: 3px; letter-spacing: .5px; }

.met-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: center; }
.met-pill {
    background: #fafaff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 9px 14px;
    min-width: 102px;
    cursor: help;
}
.met-pill-label { font-size: 11.5px; font-weight: 800; color: var(--muted); letter-spacing: .5px; }
.met-pill-num { font-size: 19px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.met-pill-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; min-height: 14px; }

.ov-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ov-count {
    display: flex; align-items: center; gap: 11px;
    background: #fafaff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.ov-count-ico { font-size: 21px; }
.ov-count-num { font-size: 20px; font-weight: 800; line-height: 1.1; }
.ov-count-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.ov-trends { display: flex; flex-direction: column; gap: 14px; }
.spark-label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.spark { width: 100%; height: 46px; display: block; margin-top: 4px; }
.spark-empty {
    height: 46px; margin-top: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; color: var(--muted);
    background: #fafaff; border: 1px dashed var(--border); border-radius: 10px;
    text-align: center; padding: 0 8px;
}

.ov-top {
    margin-top: 18px;
    border-top: 1px solid var(--border);
    padding-top: 13px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.ov-top-title { font-size: 13.5px; font-weight: 800; }
.ov-top-row { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.ov-top-dr {
    min-width: 30px; text-align: center;
    background: var(--primary-soft); color: var(--primary-dark);
    font-weight: 800; font-size: 12.5px;
    border-radius: 8px; padding: 3px 5px;
}

/* ---------- Sites page: compact add form + metric table ---------- */
.sites-head { flex-wrap: wrap; gap: 12px; }

.sites-add { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 260px; max-width: 430px; }
.sites-add input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13.5px;
    background: #fafaff;
}
.sites-add input:focus { outline: none; border-color: var(--primary); background: #fff; }

.sites-tbl th { font-size: 12px; white-space: nowrap; }
.sites-tbl td { white-space: nowrap; }

/* Compact density so the full metrics table fits a laptop screen with no
   horizontal scroll (overriding the roomier table.tbl paddings). */
.sites-tbl th { padding: 9px 8px; font-size: 11.5px; }
.sites-tbl td { padding: 8px; font-size: 13px; }
.sites-tbl .badge { padding: 3px 8px; font-size: 11px; }
.sites-tbl .mini-donut, .sites-tbl .mini-donut svg { width: 36px; height: 36px; }
.sites-tbl .mini-donut b { font-size: 11.5px; }

.mini-donut {
    position: relative;
    display: inline-block;
    width: 40px; height: 40px;
    vertical-align: middle;
    cursor: help;
}
.mini-donut svg { display: block; width: 40px; height: 40px; }
.mini-donut b {
    position: absolute; top: 0; right: 0; left: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 800;
}

/* ---------- Action Center (Stage 1 — Next Actions) ---------- */
.acts-progress { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.acts-progress-cells { display: flex; gap: 26px; }
.acts-progress-cells > div { text-align: center; min-width: 54px; }
.acts-progress-cells b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.acts-progress-cells span { font-size: 12px; color: var(--muted); }
.acts-progress-bar { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 180px; }
.acts-progress-bar b { font-size: 14px; }

.acts-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.acts-tab {
    padding: 7px 13px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; font-size: 13px; font-weight: 500; color: var(--text);
    display: inline-flex; align-items: center; gap: 7px;
}
.acts-tab span {
    background: #f0f0f6; border-radius: 8px; padding: 1px 8px;
    font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.acts-tab.active { background: var(--gradient); color: #fff; border-color: transparent; }
.acts-tab.active span { background: rgba(255,255,255,.25); color: #fff; }

.acts-ai-plan { background: #fafaff; border: 1px dashed var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }

.acts-tbl td { vertical-align: top; }
.acts-inline-form select, .acts-inline-form input[type=date] {
    border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px;
    font-size: 12.5px; background: #fff;
}
.acts-status-btns { display: flex; gap: 6px; align-items: center; }

tr.acts-overdue td { background: var(--red-soft); }
tr.acts-overdue:hover td { background: #fbe3e3; }

.acts-plan summary { cursor: pointer; color: var(--primary-dark); }
.acts-plan-body {
    background: #fafaff; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px; margin-top: 8px; font-size: 13.5px; line-height: 1.7;
    max-height: 320px; overflow-y: auto; white-space: normal;
}

@media (max-width: 860px) {
    .sidebar { display: none; }
    .main { margin-right: 0; }
}
