/* =====================================================================
   Huezone CMS — Admin Extra Styles
   Supplements admin.css for screens it doesn't already cover.
   Uses the same CSS variables defined in admin.css :root
   ===================================================================== */

/* ---- Layout helpers ---- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-gap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gap-sm { gap: 6px; } .gap-lg { gap: 18px; }
.ml-auto { margin-left: auto; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 12px; }
.mt-2 { margin-top: 12px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text3); font-size: .8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
@media (max-width: 1024px){ .grid-3,.grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px){ .grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ---- Login / auth screens ---- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background:
        radial-gradient(900px 500px at 80% -10%, rgba(0,168,255,.12), transparent 60%),
        radial-gradient(700px 500px at 0% 110%, rgba(168,85,247,.10), transparent 55%),
        var(--bg1);
}
.auth-card {
    width: 100%; max-width: 410px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 34px 30px;
}
.auth-logo {
    width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 900; font-size: 1.1rem;
    box-shadow: 0 8px 22px rgba(0,168,255,.4);
}
.auth-card h1 { text-align: center; font-size: 1.35rem; margin: 0 0 4px; color: var(--text); }
.auth-card .sub { text-align: center; color: var(--text3); font-size: .85rem; margin-bottom: 24px; }
.auth-meta { text-align: center; margin-top: 18px; font-size: .8rem; color: var(--text3); }
.auth-hint {
    margin-top: 18px; padding: 11px 13px; border-radius: var(--radius-sm);
    background: var(--bg3); border: 1px dashed var(--border-strong);
    font-size: .76rem; color: var(--text2); line-height: 1.5;
}

/* ---- Inline label/value pairs ---- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: .85rem; }
.kv dt { color: var(--text3); }
.kv dd { margin: 0; color: var(--text); }

/* ---- Drag handle / sortable rows ---- */
.sortable-list { list-style: none; margin: 0; padding: 0; }
.sortable-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
}
.drag-handle { cursor: grab; color: var(--text3); padding: 0 4px; }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; }
.sortable-row .row-main { flex: 1; min-width: 0; }
.sortable-row .row-main strong { display: block; color: var(--text); font-size: .88rem; }
.sortable-row .row-main small { color: var(--text3); }
.sub-row { margin-left: 34px; }

/* ---- Color editor ---- */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
.color-field {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px;
}
.color-field label { display:block; font-size:.74rem; font-weight:600; color:var(--text2);
    text-transform: uppercase; letter-spacing:.4px; margin-bottom: 8px; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] {
    width: 42px; height: 38px; padding: 0; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: none; cursor: pointer; flex-shrink: 0;
}
.color-row input[type="text"] { font-family: 'JetBrains Mono', monospace; font-size: .82rem; }

/* ---- Media grid ---- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; }
.media-item {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden; transition: border-color var(--transition);
}
.media-item:hover { border-color: var(--accent); }
.media-thumb {
    height: 120px; display: flex; align-items: center; justify-content: center;
    background: var(--bg1); overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb i { font-size: 2.4rem; color: var(--text4); }
.media-info { padding: 9px 10px; }
.media-info .name { font-size: .74rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info .meta { font-size: .68rem; color: var(--text4); margin-top: 2px; }
.media-actions { display: flex; gap: 4px; padding: 0 10px 10px; }

/* ---- Drop zone ---- */
.dropzone {
    border: 2px dashed var(--border-strong); border-radius: var(--radius);
    padding: 26px; text-align: center; color: var(--text3); background: var(--bg2);
    transition: all var(--transition); cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.dropzone i { font-size: 1.8rem; display:block; margin-bottom: 8px; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px; padding: 0 10px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600;
    background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
}
.pagination a:hover { background: var(--bg4); color: var(--text); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ---- Chart wrapper ---- */
.chart-box { position: relative; height: 300px; }
.chart-box-sm { position: relative; height: 220px; }

/* ---- Misc ---- */
.section-toggle-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg3); margin-bottom: 8px;
}
.section-toggle-row .label { flex: 1; }
.section-toggle-row .label strong { display: block; color: var(--text); font-size: .88rem; }
.section-toggle-row .label small { color: var(--text3); }

.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: 'JetBrains Mono', monospace; font-size: .78rem; }

.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.thumb-cell img { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); }
.thumb-cell .ph { width: 46px; height: 46px; border-radius: 6px; background: var(--bg4); display:flex;align-items:center;justify-content:center;color:var(--text4); }

.help-block { background: var(--bg3); border-left: 3px solid var(--accent); padding: 12px 14px;
    border-radius: var(--radius-sm); font-size: .82rem; color: var(--text2); line-height: 1.55; margin-bottom: 18px; }
.help-block code { background: var(--bg1); }

/* =====================================================================
   Compatibility shims for CRUD pages (leads, products, events, etc.)
   ===================================================================== */
/* Inline label toggle */
label.toggle { position: static; display: inline-flex; align-items: center; gap: 10px;
    width: auto; height: auto; font-size: .85rem; cursor: pointer; user-select: none; color: var(--text2); }
label.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
label.toggle .toggle-track { position: relative; width: 44px; height: 24px; flex-shrink: 0;
    background: var(--bg4); border-radius: 24px; transition: var(--transition); }
label.toggle .toggle-track::before { content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--transition); }
label.toggle input:checked + .toggle-track { background: var(--accent); }
label.toggle input:checked + .toggle-track::before { transform: translateX(20px); }

/* Key/value detail lists */
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-k { color: var(--text3); }
.kv-v { color: var(--text); word-break: break-word; }

/* Direct <img>/<span> thumbnails in tables */
img.thumb-cell { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); background:#fff; }
.thumb-cell.placeholder { width: 46px; height: 46px; border-radius: 6px; background: var(--bg4);
    display: inline-flex; align-items: center; justify-content: center; color: var(--text4); }

/* Pagination active state (matches our markup) */
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination a { padding:6px 11px; border:1px solid var(--border); border-radius:8px; color:var(--text2); text-decoration:none; font-size:.82rem; }

/* Sortable rows with inline children */
.sortable-row { display:flex; align-items:center; gap:10px; padding:8px 10px; background:var(--bg3);
    border:1px solid var(--border); border-radius:8px; margin-bottom:6px; }
.sortable-row .drag-handle { cursor:grab; color:var(--text4); }

/* Appearance live-preview swatch row */
.preview-banner { border-radius: var(--radius); overflow:hidden; border:1px solid var(--border); }

/* Sub-section heading inside a card body */
.section-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text2); margin: 22px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; }

/* Right-aligned action bar at the foot of a form */
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
    padding-top: 16px; border-top: 1px solid var(--border); }
.form-actions.left { justify-content: flex-start; }

/* Folder / role side navigation (media library, roles) */
.folder-nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
.folder-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text2); font-size: .86rem; text-decoration: none; transition: var(--transition); }
.folder-link i { width: 16px; text-align: center; color: var(--text4); }
.folder-link span { margin-left: auto; font-size: .72rem; background: var(--bg4); color: var(--text3);
    padding: 1px 8px; border-radius: 10px; }
.folder-link:hover { background: var(--bg3); color: var(--text); }
.folder-link.active { background: var(--accent-glow); color: var(--accent); }
.folder-link.active i { color: var(--accent); }
.folder-link.active span { background: var(--accent); color: #fff; }

/* Full-width button */
.btn-block { display: flex; width: 100%; justify-content: center; }

/* Profile avatar (large) + small table avatar */
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 1.6rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar.sm { width: 30px; height: 30px; border-radius: 50%; font-size: .8rem; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark)); flex-shrink: 0; }
.user-avatar.sm img { width: 100%; height: 100%; object-fit: cover; }

/* Activity-log row icon */
.log-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center;
    justify-content: center; background: var(--bg4); color: var(--text2); font-size: .78rem; }

/* =====================================================================
   Modal scrolling + responsive behavior  (AUTHORITATIVE — supersedes
   the separate modal-scroll-fix.css; you can delete that file)

   admin-extra.css is loaded LAST in footer.php, so these rules win over
   admin.css without editing it.

   ROOT CAUSE of the "can't scroll / Save button cut off" bug:
   .modal is a flex column with max-height:90vh + overflow:hidden, and
   .modal-body is the flex child meant to scroll. But a flex item's
   default min-height is `auto`, so .modal-body refused to shrink below
   the natural height of its content (the tall rich-text editor + all
   fields). The body therefore grew past 90vh, .modal clipped it with
   overflow:hidden, and the footer/Save button ended up below the clip
   with no scrollbar. The one-line cure is `min-height:0` on .modal-body
   so it can shrink and scroll. Everything else below hardens UX/responsive.
   ===================================================================== */
.modal-overlay {
    align-items: flex-start;            /* anchor tall modals to top, never clip-center */
    padding: 24px 16px;
    overflow-y: auto;                   /* overlay can also scroll as a safety net */
    -webkit-overflow-scrolling: touch;
}
.modal {
    max-height: calc(100vh - 48px);     /* leave room for the overlay padding */
    margin: auto;                       /* center when it fits, top-anchored when tall */
    display: flex;
    flex-direction: column;
    overflow: hidden;                   /* fine now that the body scrolls internally */
}
.modal-header,
.modal-footer {
    flex: 0 0 auto;                     /* never shrink — always visible while body scrolls */
    background: var(--bg2);             /* solid so the scrolling body never shows through */
}
.modal-footer { box-shadow: 0 -8px 18px -12px rgba(0,0,0,.55); }   /* subtle "pinned" lift */
.modal-body {
    flex: 1 1 auto;
    min-height: 0;                      /* ★ THE FIX — lets the flex child shrink & scroll */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;  /* momentum scrolling on iOS / trackpads */
}

/* ---- Responsive modal sizing ---- */
@media (max-width: 1024px) {            /* tablet */
    .modal, .modal-lg, .modal-xl { max-width: 95vw; }
}
@media (max-width: 640px) {             /* mobile — full screen */
    .modal-overlay { padding: 0; }
    .modal, .modal-lg, .modal-xl {
        max-width: 100%;
        width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        border: 0;
    }
}

/* =====================================================================
   Inline form validation (used by the Add/Edit event modals; reusable
   anywhere — just add .has-error to a .form-group and a .field-error note)
   ===================================================================== */
.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select,
.form-group.has-error .tox-tinymce {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .18) !important;
}
.field-error {
    display: block;
    margin-top: 6px;
    font-size: .76rem;
    color: #fca5a5;
}
.field-error i { margin-right: 5px; }
