/* ========================================
   BACK OFFICE — STYLES
   ======================================== */

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

:root {
    --primary:   #0f3460;
    --primary-h: #1a4a8a;
    --accent:    #e94560;
    --bg:        #f0f2f5;
    --surface:   #ffffff;
    --border:    #e0e4ea;
    --text:      #1e2532;
    --muted:     #6b7280;
    --success:   #10b981;
    --danger:    #ef4444;
    --radius:    10px;
    --shadow:    0 2px 8px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
    --topbar-h:  64px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

/* ── LOGIN ────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 60%, #1a1a2e 100%);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 44px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 22px;
    color: var(--primary);
    margin-top: 12px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
}

.login-footer a:hover { color: var(--primary); }

/* ── HEADER ───────────────────────────────── */
.bo-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.bo-header-left { display: flex; align-items: center; gap: 12px; }
.bo-title       { font-size: 17px; font-weight: 700; color: var(--primary); }
.bo-header-right{ display: flex; align-items: center; gap: 12px; }
.bo-user        { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }

/* ── MAIN ─────────────────────────────────── */
.dashboard-page { padding-top: var(--topbar-h); }

.bo-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* ── TABS ─────────────────────────────────── */
.bo-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all .2s;
    white-space: nowrap;
}

.tab-btn:hover  { background: var(--bg); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #fff; }

/* ── TAB CONTENT ──────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── SECTION HEADER ───────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.subsection-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── FORM ─────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text);
    transition: border-color .2s;
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.checkbox-row  { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.checkbox-label{ display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text); }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

.radio-group  { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-label  { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text); }
.radio-label input[type="radio"] { accent-color: var(--primary); }

.color-input-row { display: flex; align-items: center; gap: 10px; }
.color-input-row input[type="color"] { width: 44px; height: 36px; border: 1.5px solid var(--border); border-radius: 7px; padding: 2px; cursor: pointer; }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── ALERTS ───────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }

/* ── BUTTONS ──────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm       { padding: 6px 12px; font-size: 12px; }
.btn-block    { width: 100%; justify-content: center; }
.btn-icon     { padding: 7px 10px; }

/* ── LIST TABLE ───────────────────────────── */
.list-table {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-row {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    gap: 14px;
    transition: background .15s;
}

.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f8f9fb; }

.list-row-clickable { cursor: pointer; }
.list-row-clickable:hover { background: #f0f4ff; }
.list-row-clickable:hover .list-row-hint { opacity: 1; }

.list-row-hint {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    opacity: 0;
    transition: opacity .15s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.list-row-icon {
    color: var(--muted);
    font-size: 13px;
    flex-shrink: 0;
}

.list-row-title { flex: 1; font-weight: 600; color: var(--text); }
.list-row-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

.list-row-actions { display: flex; gap: 6px; }

.card-icon-chip {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border-radius: 6px;
    color: var(--primary); font-size: 14px; flex-shrink: 0;
}

.list-loading {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

/* ── ICON PICKER ──────────────────────────── */
.icon-picker-row {
    display: flex; align-items: center; gap: 10px;
}
.icon-picker-row input { flex: 1; }
.icon-preview-live {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border-radius: 8px; font-size: 18px; color: var(--primary);
    border: 1.5px solid var(--border);
}
.hint-inline { font-size: 11px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── FORM FIELDS MANAGER ──────────────────── */
.form-fields-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.form-fields-header label {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .5px; color: var(--muted);
}
.form-fields-list { display: flex; flex-direction: column; gap: 8px; }

.field-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); padding: 8px 12px; border-radius: 8px;
    border: 1px solid var(--border);
}

.field-row .field-label {
    flex: 2; padding: 6px 10px; border: 1.5px solid var(--border);
    border-radius: 6px; font-size: 13px;
}
.field-row .field-type {
    flex: 1; padding: 6px 8px; border: 1.5px solid var(--border);
    border-radius: 6px; font-size: 12px; background: var(--surface);
}
.field-row .field-placeholder {
    flex: 2; padding: 6px 10px; border: 1.5px solid var(--border);
    border-radius: 6px; font-size: 13px; color: var(--muted);
}
.field-row input:focus, .field-row select:focus {
    outline: none; border-color: var(--primary);
}

/* ── ICONS FORM ───────────────────────────── */
.icons-form {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.icon-row {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    gap: 14px;
}

.icon-row:last-child { border-bottom: none; }

.icon-preview {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: 8px;
    font-size: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

.icon-name { width: 130px; font-weight: 600; flex-shrink: 0; }

.icon-url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    transition: border-color .2s;
}

.icon-url-input:focus { outline: none; border-color: var(--primary); }

.icon-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}
.icon-status.on { background: var(--success); }

/* ── MEDIA ────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: all .2s;
    margin-bottom: 20px;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: #f0f4ff;
}

.upload-zone i { font-size: 40px; color: var(--border); margin-bottom: 10px; display: block; }
.upload-zone p { color: var(--muted); }
.upload-zone .link { color: var(--primary); cursor: pointer; text-decoration: underline; }

.progress-bar  { background: var(--border); border-radius: 4px; height: 6px; margin-bottom: 16px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; width: 0; transition: width .3s; }

.media-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.media-tab-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-size: 13px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
    transition: all .2s;
}

.media-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.media-item {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all .2s;
}

.media-item:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.media-item.selected { border-color: var(--primary); }

.media-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: #eee;
}

.media-video-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e2532;
    color: #fff;
    font-size: 28px;
}

.media-info {
    padding: 10px;
}

.media-name {
    font-size: 12px;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.media-actions button {
    flex: 1;
    padding: 5px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all .2s;
}

.media-btn-delete { background: #fef2f2; color: var(--danger); }
.media-btn-delete:hover { background: var(--danger); color: #fff; }

.media-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

/* ── MODAL ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.modal-box {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.modal-box.large { width: 100%; max-width: 760px; }
.modal-box.small { width: 100%; max-width: 400px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    padding: 4px;
    border-radius: 6px;
    transition: all .2s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ── TOAST ────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    z-index: 2000;
    transform: translateY(80px);
    opacity: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── QUILL OVERRIDE ───────────────────────── */
.ql-container { font-size: 14px; }
.ql-toolbar.ql-snow { border-radius: 7px 7px 0 0; border-color: var(--border); }
.ql-container.ql-snow { border-radius: 0 0 7px 7px; border-color: var(--border); }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .bo-header-right .bo-user { display: none; }
    .tab-btn span { display: none; }
}
