/* ============================================================
   Azoury IVF CMS — base styles
   Mobile-first; sidebar collapses to offcanvas under .lg breakpoint.
   ============================================================ */

:root {
    --cms-bg:             #eef2f7;
    --cms-surface:        #ffffff;
    --cms-text:           #1f2937;
    --cms-text-muted:     #6b7280;
    --cms-border:         #e5e7eb;
    --cms-primary:        #0d6efd;
    --cms-primary-dark:   #0a58ca;
    --cms-sidebar-bg:     #0b1f3a;
    --cms-sidebar-bg-2:   #122a4d;
    --cms-sidebar-fg:     #e8edf5;
    --cms-sidebar-muted:  #93a4c1;
    --cms-sidebar-accent: #38bdf8;
    --cms-sidebar-border: #1f3766;
    --cms-sidebar-w:      260px;
    --cms-topbar-h:       64px;
    --cms-radius:         10px;
    --cms-shadow:         0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.cms-body {
    background: var(--cms-bg);
    color: var(--cms-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
}

/* All clickable elements get a pointer cursor (per Charbel's spec) */
button, a, [role="button"], .cms-stat-card, .dropdown-item, .nav-link,
.cms-nav-link, .cms-subnav-link, summary, label[for] {
    cursor: pointer;
}
button:disabled, a.disabled, [aria-disabled="true"] { cursor: not-allowed; }

/* ===== Topbar ============================================== */
.cms-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--cms-topbar-h);
    background: var(--cms-surface);
    border-bottom: 1px solid var(--cms-border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1030;
}
.cms-sidebar-toggle {
    color: var(--cms-text);
    font-size: 1.5rem;
    padding: 0 .5rem;
}
.cms-sidebar-toggle:hover { color: var(--cms-primary); }

.cms-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    margin-left: .25rem;
    text-decoration: none;
    color: inherit;
}
.cms-topbar-logo {
    height: 40px;
    width: auto;
    display: block;
}
.cms-topbar-tag {
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--cms-text-muted);
    padding: .15rem .55rem;
    border: 1px solid var(--cms-border);
    border-radius: 6px;
    background: var(--cms-bg);
}
@media (max-width: 575.98px) {
    .cms-topbar-logo { height: 32px; }
}

.cms-user-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--cms-text);
    text-decoration: none;
}
.cms-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--cms-primary);
    color: #fff;
    font-weight: 600;
}

/* ===== Sidebar ============================================= */
.cms-sidebar-wrap {
    /* Override Bootstrap offcanvas defaults so the dark bg is preserved
       in the offcanvas (mobile) state too. */
    --bs-offcanvas-bg:       var(--cms-sidebar-bg);
    --bs-offcanvas-color:    var(--cms-sidebar-fg);
    --bs-offcanvas-border-color: transparent;
    --bs-offcanvas-border-width: 0;

    background: linear-gradient(180deg, var(--cms-sidebar-bg) 0%, var(--cms-sidebar-bg-2) 100%) !important;
    color: var(--cms-sidebar-fg);
}

@media (min-width: 992px) {
    .cms-sidebar-wrap {
        position: fixed;
        top: var(--cms-topbar-h);
        left: 0;
        bottom: 0;
        width: var(--cms-sidebar-w);
        overflow-y: auto;
        transform: translateX(0) !important;
        visibility: visible !important;
        border-right: 1px solid var(--cms-sidebar-border);
        box-shadow: 4px 0 12px rgba(11, 31, 58, .08);
        transition: transform .25s ease;
    }

    body.cms-sidebar-collapsed .cms-sidebar-wrap {
        transform: translateX(-100%) !important;
    }
}

.cms-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.cms-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1rem 1.25rem .85rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.cms-sidebar-label {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .14em;
    color: var(--cms-sidebar-muted);
    font-weight: 600;
}

.cms-sidebar-nav { padding: .75rem .5rem; flex: 1; }
.cms-sidebar-powered {
    padding: .9rem 1.25rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .07);
    color: var(--cms-sidebar-muted);
    font-size: .78rem;
    letter-spacing: .02em;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.cms-sidebar-powered .cms-powered-label {
    flex-shrink: 0;
    line-height: 1;
}
.cms-sidebar-powered .cms-powered-logo {
    display: inline-flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
    line-height: 0;
    transition: opacity .15s ease;
}
.cms-sidebar-powered .cms-powered-logo:hover { opacity: .85; }
.cms-sidebar-powered .cms-powered-logo svg {
    height: 18px;
    width: auto;
    display: block;
}
.cms-nav-section {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    color: var(--cms-sidebar-muted);
    padding: 1rem .9rem .35rem;
}
.cms-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .95rem;
    border-radius: 8px;
    color: var(--cms-sidebar-fg);
    text-decoration: none;
    font-size: .95rem;
    transition: background .15s, color .15s, box-shadow .15s;
}
.cms-nav-link i { font-size: 1.1rem; width: 20px; text-align: center; color: var(--cms-sidebar-muted); }
.cms-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}
.cms-nav-link:hover i { color: var(--cms-sidebar-accent); }
.cms-nav-link.active {
    background: rgba(56, 189, 248, .12);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--cms-sidebar-accent);
}
.cms-nav-link.active i { color: var(--cms-sidebar-accent); }

.cms-nav-toggle .cms-nav-caret {
    margin-left: auto;
    font-size: .85rem;
    transition: transform .2s;
}
.cms-nav-toggle[aria-expanded="true"] .cms-nav-caret { transform: rotate(180deg); }

.cms-subnav { padding-left: 2.4rem; margin-top: .15rem; }
.cms-subnav-link {
    display: block;
    padding: .4rem .75rem;
    border-radius: 6px;
    color: var(--cms-sidebar-muted);
    text-decoration: none;
    font-size: .9rem;
}
.cms-subnav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.cms-subnav-link.active { color: #fff; background: rgba(13,110,253,.2); }

/* ===== Main content area ==================================== */
.cms-main {
    padding: calc(var(--cms-topbar-h) + 1.5rem) 1rem 2.5rem;
    min-height: 100vh;
}
@media (min-width: 992px) {
    .cms-main {
        margin-left: var(--cms-sidebar-w);
        padding-left: 2rem;
        padding-right: 2rem;
        transition: margin-left .25s ease;
    }
    body.cms-sidebar-collapsed .cms-main {
        margin-left: 0;
    }
}

.cms-page-header { margin-bottom: 1.5rem; }
.cms-page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; }
.cms-page-subtitle { color: var(--cms-text-muted); margin: 0; }

/* ===== Cards ================================================ */
.card {
    border: 1px solid var(--cms-border);
    border-radius: var(--cms-radius);
    box-shadow: var(--cms-shadow);
}

/* ===== Rich Text Editor ===================================== */
.cms-rich-text-source {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}
.cms-rich-text {
    border: 1px solid var(--cms-border);
    border-radius: var(--cms-radius);
    background: #fff;
}
.cms-rich-text.is-invalid {
    border-color: var(--bs-danger);
}
.cms-rich-text-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .55rem;
    border-bottom: 1px solid var(--cms-border);
    background: #f8fafc;
    border-radius: calc(var(--cms-radius) - 1px) calc(var(--cms-radius) - 1px) 0 0;
}
.cms-rich-text-format {
    width: 150px;
    min-height: 34px;
    font-size: .875rem;
}
.cms-rich-text-toolbar .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-color: #d9e2ef;
}
.cms-rich-text-editor {
    min-height: 330px;
    padding: .95rem 1rem;
    outline: 0;
    overflow-y: auto;
    line-height: 1.65;
}
.cms-rich-text-editor:focus {
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .12);
}
.cms-rich-text-editor h2,
.cms-rich-text-editor h3 {
    margin: 1rem 0 .5rem;
    font-weight: 700;
}
.cms-rich-text-editor p,
.cms-rich-text-editor ul,
.cms-rich-text-editor ol {
    margin: 0 0 .85rem;
}
.cms-rich-text-editor ul,
.cms-rich-text-editor ol {
    padding-left: 1.4rem;
}
.cms-rich-text-editor[dir="rtl"] ul,
.cms-rich-text-editor[dir="rtl"] ol {
    padding-left: 0;
    padding-right: 1.4rem;
}
.cms-rich-text.is-invalid .cms-rich-text-invalid {
    display: block;
    padding: .55rem .75rem .75rem;
}

/*  Position-field editor (doctors form): match the public site's
    .ourdoctors-member-position style (1rem / weight 400 / #aaaaaa)
    so what the admin writes is what the visitor reads on the cards.
    The textarea is the immediate previous sibling of the wrapper.

    The default .cms-rich-text-editor adds bottom margins to <p> blocks
    (used for blog content), so we zero those out for the position editor
    and tighten line-height to mirror the inline `<span>` rendering of
    .ourdoctors-member-position on the public site. */
#f_en_position + .cms-rich-text .cms-rich-text-editor,
#f_ar_position + .cms-rich-text .cms-rich-text-editor {
    font-size: 1rem;
    font-weight: 400;
    color: #aaaaaa;
    line-height: 1.5;
    min-height: 160px;
}
#f_en_position + .cms-rich-text .cms-rich-text-editor p,
#f_ar_position + .cms-rich-text .cms-rich-text-editor p,
#f_en_position + .cms-rich-text .cms-rich-text-editor ul,
#f_ar_position + .cms-rich-text .cms-rich-text-editor ul,
#f_en_position + .cms-rich-text .cms-rich-text-editor ol,
#f_ar_position + .cms-rich-text .cms-rich-text-editor ol,
#f_en_position + .cms-rich-text .cms-rich-text-editor li,
#f_ar_position + .cms-rich-text .cms-rich-text-editor li {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    margin: 0;
}
/* Re-introduce a small gap between consecutive paragraphs / list items so
   multi-line content stays readable, but smaller than the blog default. */
#f_en_position + .cms-rich-text .cms-rich-text-editor p + p,
#f_ar_position + .cms-rich-text .cms-rich-text-editor p + p {
    margin-top: .35rem;
}

.cms-stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--cms-surface);
    border: 1px solid var(--cms-border);
    border-radius: var(--cms-radius);
    box-shadow: var(--cms-shadow);
    color: var(--cms-text);
    transition: transform .15s, box-shadow .15s;
}
.cms-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .08);
    color: var(--cms-text);
}
.cms-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px; height: 52px;
    border-radius: 12px;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.cms-stat-label { font-size: .85rem; color: var(--cms-text-muted); }
.cms-stat-value { font-weight: 600; font-size: 1rem; }

/* ===== Auth (login) page ==================================== */
body.auth-body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #0d6efd 50%, #06b6d4 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.auth-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card-wrap { width: 100%; max-width: 440px; }
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
}
.auth-card-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-card-logo {
    height: 70px;
    width: auto;
    display: block;
    margin: 0 auto .5rem;
}
.auth-card-brand h1 {
    font-size: 1rem; font-weight: 700; margin: .5rem 0 .25rem;
    text-transform: uppercase; letter-spacing: .25em; color: var(--cms-text-muted);
}
.auth-card-brand p { color: var(--cms-text-muted); margin: 0; }
.auth-card-footer { margin-top: 1.5rem; text-align: center; color: var(--cms-text-muted); font-size: .85rem; }

/* ===== Form polish ========================================== */
.form-control:focus,
.form-select:focus {
    border-color: var(--cms-primary);
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.18);
}

/* ===== Table toolbar (search + filters) ==================== */
.cms-table-toolbar {
    background: var(--cms-bg);
}
.cms-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cms-text-muted);
    pointer-events: none;
}
.cms-table-search { padding-left: 2.5rem !important; }
.cms-table-count { white-space: nowrap; min-width: 80px; }

/* ===== Tables ============================================== */
.cms-table { font-size: .92rem; }
.cms-table > :not(caption) > * > * {
    padding: .85rem 1rem;
    border-bottom-color: var(--cms-border);
}
.cms-table thead th {
    color: var(--cms-text-muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--cms-bg);
    border-bottom: 1px solid var(--cms-border);
}
.cms-row-deleted td { background: rgba(220, 53, 69, 0.04); }
.cms-row-deleted td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.cms-cell-truncate {
    max-width: 28ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 1200px) {
    .cms-cell-truncate { max-width: 42ch; }
}

/* ===== Image cropper modal ================================= */
.cms-cropper-drop {
    border: 2px dashed var(--cms-border);
    border-radius: var(--cms-radius);
    padding: 2rem 1rem;
    text-align: center;
    background: var(--cms-bg);
}
.cms-cropper-icon {
    font-size: 3rem;
    color: var(--cms-text-muted);
    display: block;
    margin-bottom: .5rem;
}
.cms-cropper-canvas-wrap {
    background: #1f2937;
    border-radius: var(--cms-radius);
    overflow: hidden;
    /* keep modal a sensible height */
    max-height: 60vh;
}
#cmsCropperImage {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    margin: 0 auto;
}

/* Scrollable checkbox list (used by category pickers) */
.cms-checkbox-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--cms-border);
    border-radius: 8px;
    padding: .65rem .85rem;
    background: var(--cms-bg);
}
.cms-checkbox-list .form-check { margin-bottom: .35rem; }
.cms-checkbox-list .form-check:last-child { margin-bottom: 0; }

/* Multi-picker (search + checkbox list + count) */
.cms-multi-picker { display: flex; flex-direction: column; gap: .4rem; }
.cms-multi-picker-search { margin-bottom: .15rem; }
.cms-multi-picker-input { padding-left: 2.25rem !important; }
.cms-multi-picker-search .cms-search-icon { left: .75rem; font-size: .9rem; }
.cms-multi-picker-footer { display: flex; justify-content: flex-end; padding-top: .25rem; }
.cms-mp-row { display: flex; align-items: center; gap: .5rem; }
.cms-mp-thumb {
    width: 64px; height: 36px;
    object-fit: cover; border-radius: 4px;
    border: 1px solid var(--cms-border);
}

/* Drag-handle for sortable list rows */
.cms-drag-handle {
    cursor: grab;
    color: var(--cms-text-muted);
    user-select: none;
}
.cms-drag-handle:active { cursor: grabbing; }
tr.sortable-ghost { opacity: .5; background: rgba(56, 189, 248, .08); }
tr.sortable-chosen td { background: rgba(56, 189, 248, .12); }
.cms-reorder-toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 1090;
    background: var(--cms-text); color: #fff;
    padding: .75rem 1.25rem; border-radius: 8px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, .25);
    transition: opacity .25s, transform .25s;
    opacity: 0; transform: translateY(8px);
    pointer-events: none;
}
.cms-reorder-toast.show { opacity: 1; transform: translateY(0); }

/* YouTube thumbnail preview (admin form + list table) */
.cms-yt-thumb {
    width: 100px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--cms-border);
}
.cms-yt-preview-wrap {
    background: var(--cms-bg);
    border: 1px solid var(--cms-border);
    border-radius: var(--cms-radius);
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.cms-yt-preview-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Cover image preview block on form pages */
.cms-cover-preview {
    border: 1px solid var(--cms-border);
    border-radius: var(--cms-radius);
    overflow: hidden;
    background: var(--cms-bg);
    aspect-ratio: 1000 / 549;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cms-text-muted);
}
.cms-cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cms-cover-empty { font-size: 2rem; color: var(--cms-text-muted); }

/* ===== Tag input (chip editor for hashtags / meta keywords) ====
   Uses .form-control on the wrapper so it picks up Bootstrap's height,
   border and focus styling automatically.                              */
.cms-tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    min-height: calc(1.5em + .75rem + 2px);
    height: auto;
    padding: .35rem .5rem;
    cursor: text;
}
.cms-tag-input:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .25);
}
.cms-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #e7f1ff;
    color: #0a58ca;
    border: 1px solid #b6d4fe;
    border-radius: 999px;
    padding: .15rem .5rem .15rem .65rem;
    font-size: .85rem;
    line-height: 1.3;
    max-width: 100%;
}
.cms-tag-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.cms-tag-remove {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.05rem;
    line-height: 1;
    padding: 0 .15rem;
    border-radius: 50%;
    opacity: .7;
}
.cms-tag-remove:hover { opacity: 1; background: rgba(10, 88, 202, .12); }
.cms-tag-entry {
    flex: 1 0 120px;
    min-width: 120px;
    border: 0;
    outline: 0;
    background: transparent;
    padding: .1rem .15rem;
    font: inherit;
    color: inherit;
}
.cms-tag-input[dir="rtl"] .cms-tag-entry { text-align: right; }

/* Inline character counter that pairs with [data-cms-counter] inputs */
.cms-char-counter {
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

/* ===== Modal scroll lock (Bootstrap already adds modal-open) === */
body.modal-open { overflow: hidden !important; padding-right: 0 !important; }

/* ===== Small responsive tweaks ============================== */
@media (max-width: 575.98px) {
    .cms-page-title { font-size: 1.25rem; }
    .cms-stat-card { padding: 1rem; gap: .75rem; }
    .cms-stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
}
