/* ==========================================================================
   כנען ישראל – מערכת ניהול התוכן
   ========================================================================== */

:root {
    --red:        #c8102e;
    --red-dark:   #9c0c23;
    --green:      #1b7a3d;
    --green-dark: #14602f;
    --gold:       #d4a017;
    --blue:       #1b4b9e;
    --blue-dark:  #143a7a;

    --ink:        #1e2a37;
    --ink-soft:   #46586b;
    --muted:      #7a8896;
    --line:       #e1e7ee;
    --line-soft:  #eff3f7;
    --paper:      #ffffff;
    --bg:         #f2f5f9;
    --sidebar:    #1b2735;
    --sidebar-2:  #24313f;

    --radius:     10px;
    --radius-lg:  14px;
    --shadow:     0 1px 3px rgba(20, 30, 45, .07);
    --shadow-md:  0 6px 20px rgba(20, 30, 45, .10);

    --font:       "Heebo", "Rubik", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
    --sidebar-w:  248px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 25px; margin: 0 0 4px; font-weight: 800; }
h2 { font-size: 19px; margin: 0 0 14px; font-weight: 800; }
h3 { font-size: 16.5px; margin: 0 0 10px; font-weight: 700; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- פריסה */

.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar);
    color: #c3cedb;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    display: flex;
    align-items: center;
    gap: 11px;
}
.admin-brand:hover { text-decoration: none; }
.admin-brand-mark {
    width: 38px; height: 38px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--red), var(--gold) 50%, var(--green));
    color: #fff; font-weight: 900; font-size: 17px;
    flex-shrink: 0;
}
.admin-brand-text { line-height: 1.2; }
.admin-brand-name { color: #fff; font-weight: 800; font-size: 17px; display: block; }
.admin-brand-sub  { color: #8b9bad; font-size: 12px; }

.admin-nav { padding: 12px 10px 24px; flex: 1; }
.admin-nav-group {
    font-size: 11.5px;
    text-transform: none;
    letter-spacing: .04em;
    color: #6f8093;
    font-weight: 700;
    padding: 16px 12px 6px;
}
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #c3cedb;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
    transition: background .14s, color .14s;
}
.admin-nav a:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.admin-nav a.is-active { background: var(--green); color: #fff; }
.admin-nav a .ico { width: 18px; text-align: center; flex-shrink: 0; opacity: .9; }
.admin-nav a .badge {
    margin-inline-start: auto;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 800;
}

.admin-sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, .09);
    font-size: 13px;
}
.admin-sidebar-foot a { color: #9fb0c2; display: block; margin-bottom: 5px; }

/* --------------------------------------------------------- אזור ראשי */

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0 26px;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14.5px; }
.admin-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--blue); color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 14px;
    flex-shrink: 0;
}
.admin-role {
    background: var(--line-soft);
    border-radius: 999px;
    padding: 2px 11px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-soft);
}

.admin-sidebar-toggle {
    display: none;
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit; font-weight: 700;
    cursor: pointer;
}

.admin-content { padding: 26px; flex: 1; }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}
.page-header .subtitle { color: var(--muted); font-size: 15px; margin: 0; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* --------------------------------------------------------- כרטיסים */

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    overflow: hidden;
}
.panel-head {
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-body { padding: 22px; }
.panel-body--flush { padding: 0; }

/* ------------------------------------------------------ לוח מחוונים */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background: var(--green);
}
.kpi--red::before   { background: var(--red); }
.kpi--blue::before  { background: var(--blue); }
.kpi--gold::before  { background: var(--gold); }
.kpi-label { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.kpi-value {
    font-size: 30px;
    font-weight: 900;
    line-height: 1.15;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.kpi-note { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------- טבלאות */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
    min-width: 620px;
}
table.data th,
table.data td {
    padding: 11px 16px;
    text-align: start;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    background: var(--line-soft);
    font-weight: 700;
    font-size: 13.5px;
    color: var(--ink-soft);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.data tbody tr:hover { background: #f9fbfd; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.actions { white-space: nowrap; text-align: end; }
table.data .row-unread { background: #fffdf4; }

.cell-main { font-weight: 700; color: var(--ink); }
.cell-sub  { font-size: 13px; color: var(--muted); }
.cell-ltr  { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* ----------------------------------------------------------- תגיות */

.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}
.tag-green  { background: #e6f4ec; color: #14602f; }
.tag-red    { background: #fdeaed; color: #99101f; }
.tag-blue   { background: #e8f0fb; color: #143a7a; }
.tag-gold   { background: #fdf3dd; color: #7a5a06; }
.tag-gray   { background: #eef1f5; color: #58697a; }

/* ---------------------------------------------------------- כפתורים */

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 8px;
    font: inherit;
    font-weight: 700;
    font-size: 14.5px;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: background .14s, color .14s, border-color .14s;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-blue     { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); color: #fff; }
.btn-ghost    { background: var(--paper); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-sm       { padding: 5px 12px; font-size: 13.5px; border-radius: 7px; }
.btn-block    { display: block; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------- טפסים */

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 20px;
}
.field { margin-bottom: 17px; }
.field--full { grid-column: 1 / -1; }

.field label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 5px;
}
.field .req { color: var(--red); }

.field input[type=text],
.field input[type=email],
.field input[type=tel],
.field input[type=url],
.field input[type=number],
.field input[type=password],
.field input[type=date],
.field input[type=search],
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    background: #fff;
    color: var(--ink);
    transition: border-color .14s, box-shadow .14s;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.field textarea.tall { min-height: 260px; }
.field textarea.code {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13.5px;
    direction: ltr;
    text-align: left;
}

.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(27, 75, 158, .12);
    outline: none;
}
.field input[aria-invalid=true], .field textarea[aria-invalid=true] { border-color: var(--red); }

.field-hint  { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 13px; color: var(--red); font-weight: 600; margin-top: 4px; }

.field-check { display: flex; align-items: flex-start; gap: 9px; }
.field-check input { margin-top: 5px; width: 16px; height: 16px; flex-shrink: 0; }
.field-check label { font-weight: 500; margin: 0; font-size: 14.5px; }

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin: 0 0 20px;
}
fieldset legend { font-weight: 800; font-size: 14.5px; padding: 0 8px; }

.form-footer {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    margin-top: 6px;
    padding-top: 18px;
}

/* -------------------------------------------------------- התראות */

.alert {
    padding: 13px 17px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid transparent;
    font-size: 14.5px;
}
.alert-success { background: #e9f6ee; border-color: #bce0c9; color: #14532d; }
.alert-error   { background: #fdecee; border-color: #f4c2c8; color: #8d1023; }
.alert-info    { background: #e8f0fb; border-color: #c1d5f2; color: #143a7a; }
.alert-warning { background: #fef6e3; border-color: #f3dfa8; color: #7a5a06; }
.alert ul { margin: 7px 0 0; padding-inline-start: 20px; }

/* ------------------------------------------------------- מצב ריק */

.empty {
    text-align: center;
    padding: 46px 24px;
    color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 5px; }

/* --------------------------------------------------- סרגל סינון */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfe;
}
.toolbar .field { margin: 0; }
.toolbar .field label { font-size: 12.5px; }
.toolbar input, .toolbar select { min-width: 150px; }

/* ----------------------------------------------- ספריית מדיה */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.media-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--paper);
    display: flex;
    flex-direction: column;
}
.media-thumb {
    aspect-ratio: 4 / 3;
    background:
        repeating-conic-gradient(#f0f3f7 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-thumb .file-badge {
    font-size: 13px; font-weight: 800; color: var(--muted);
}
.media-meta { padding: 9px 11px; font-size: 12px; color: var(--muted); }
.media-meta .name {
    color: var(--ink); font-weight: 600; font-size: 12.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    direction: ltr;
}
.media-actions {
    display: flex; gap: 5px; padding: 0 9px 10px; margin-top: auto;
}
.media-actions .btn { flex: 1; padding: 4px 6px; font-size: 12px; }

/* ------------------------------------------------- בוחר תמונה */

.image-picker {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.image-preview {
    width: 190px;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        repeating-conic-gradient(#f0f3f7 0% 25%, #fff 0% 50%) 50% / 14px 14px;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
}
.image-preview img { width: 100%; height: 100%; object-fit: contain; }
.image-preview .ph { color: var(--muted); font-size: 13px; }
.image-picker-controls { flex: 1; min-width: 220px; }

/* -------------------------------------------------- בלוקי תוכן */

.block-list { display: grid; gap: 14px; }
.block-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    overflow: hidden;
}
.block-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    background: var(--line-soft);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.block-card-head .grip { color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.block-card-head .title { font-weight: 700; flex: 1; min-width: 120px; }
.block-card-body { padding: 16px; }
.block-card-actions { display: flex; gap: 6px; }

/* ------------------------------------------------------- גרף */

.spark {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 92px;
    padding-top: 6px;
}
.spark i {
    flex: 1;
    background: linear-gradient(180deg, var(--green), #4fae74);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    position: relative;
}
.spark i:hover { background: var(--gold); }

/* ------------------------------------------------------ עימוד */

.pager {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 16px 22px; border-top: 1px solid var(--line);
    justify-content: center;
}
.pager a, .pager span {
    min-width: 36px; text-align: center;
    padding: 6px 11px; border: 1px solid var(--line);
    border-radius: 7px; font-weight: 700; font-size: 14px;
    color: var(--ink-soft); background: var(--paper);
}
.pager a:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.pager .is-current { background: var(--green); border-color: var(--green); color: #fff; }

/* --------------------------------------------------- מסך כניסה */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 26px 16px;
    background:
        linear-gradient(135deg, rgba(27, 39, 53, .96), rgba(27, 75, 158, .92));
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--paper);
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
    overflow: hidden;
}
.login-stripe {
    height: 6px;
    background: linear-gradient(90deg,
        var(--red) 0 25%, var(--gold) 25% 50%, var(--green) 50% 75%, var(--blue) 75% 100%);
}
.login-body { padding: 32px 30px 30px; }
.login-logo {
    width: 58px; height: 58px; border-radius: 14px;
    background: linear-gradient(140deg, var(--red), var(--gold) 50%, var(--green));
    color: #fff; display: grid; place-items: center;
    font-weight: 900; font-size: 24px;
    margin: 0 auto 16px;
}
.login-body h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-body .sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login-foot {
    padding: 15px 30px;
    border-top: 1px solid var(--line);
    background: #fafcfe;
    text-align: center;
    font-size: 13.5px;
}

/* ------------------------------------------------------ רספונסיבי */

@media (max-width: 900px) {
    .admin-sidebar-toggle { display: inline-flex; }

    .admin-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 60;
        transform: translateX(100%);
        transition: transform .22s ease;
        box-shadow: -8px 0 30px rgba(0, 0, 0, .25);
    }
    [dir="ltr"] .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.is-open { transform: translateX(0); }

    .admin-backdrop {
        position: fixed; inset: 0;
        background: rgba(15, 22, 31, .5);
        z-index: 50;
        display: none;
    }
    .admin-backdrop.is-open { display: block; }

    .admin-content { padding: 18px 16px; }
    .admin-topbar { padding: 0 16px; }
}

@media (max-width: 560px) {
    body { font-size: 15px; }
    .panel-body { padding: 16px; }
    .toolbar { padding: 14px 16px; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-actions .btn { flex: 1; }
    .admin-topbar-user .who { display: none; }
}

@media print {
    .admin-sidebar, .admin-topbar, .page-actions, .toolbar, .pager { display: none !important; }
    .admin-content { padding: 0; }
    .panel { border: 0; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
