/* ═══════════════════════════════════════════════════════════
   MLUF Admin CMS — Global Styles
   ══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-w:       240px;
  --sidebar-bg:      #B75C3C;
  --sidebar-hover:   rgba(0,0,0,.15);
  --sidebar-active:  rgba(0,0,0,.25);
  --sidebar-text:    #fff;
  --sidebar-text-sm: rgba(255,255,255,.7);

  --accent:          #d9593c;
  --accent-hover:    #c04a30;
  --accent-light:    rgba(217,89,60,.1);

  --bg:              #f1f5f9;
  --surface:         #ffffff;
  --border:          #e2e8f0;
  --border-strong:   #cbd5e1;

  --text:            #1e293b;
  --text-muted:      #64748b;
  --text-sm:         #94a3b8;

  --success:         #22c55e;
  --success-light:   rgba(34,197,94,.1);
  --warning:         #f59e0b;
  --warning-light:   rgba(245,158,11,.1);
  --danger:          #ef4444;
  --danger-light:    rgba(239,68,68,.1);
  --info:            #3b82f6;
  --info-light:      rgba(59,130,246,.1);

  --radius:          8px;
  --radius-sm:       4px;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:       0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  --font:            'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --topbar-h:        60px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

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

/* ── Sidebar ────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-logo {
  display: block; width: 100%; max-width: 120px; height: auto;
}

.sidebar-section {
  padding: 1rem 0 .5rem;
}
.sidebar-section-label {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: #fff; padding: 0 1.25rem .5rem;
}

.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--sidebar-text);
  font-size: .83rem; font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-link.active {
  background: var(--accent-light);
  color: #fff;
}
.sidebar-link.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #fff;
  border-radius: 0 2px 2px 0;
}
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem;
}
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-username { font-size: .8rem; color: #fff; font-weight: 500; }
.sidebar-role     { font-size: .7rem; color: rgba(255,255,255,.75); }

.sidebar-logout {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .75rem;
  background: rgba(255,255,255,.15);
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: .78rem;
  transition: background .15s;
}
.sidebar-logout:hover { background: rgba(0,0,0,.2); color: #fff; }
.sidebar-logout svg { width: 14px; height: 14px; }

/* ── Main Content ───────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Page Content ───────────────────────────────────────────── */
.admin-content {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.3rem; font-weight: 700; color: var(--text);
}
.page-header p {
  font-size: .83rem; color: var(--text-muted); margin-top: .2rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body  { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .88rem; font-weight: 600;
}
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafafa; border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stats Grid (Dashboard) ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); margin: .2rem 0; line-height: 1; }
.stat-icon  {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.orange  { background: var(--accent-light);   color: var(--accent);  }
.stat-icon.green   { background: var(--success-light);  color: var(--success); }
.stat-icon.blue    { background: var(--info-light);     color: var(--info);    }
.stat-icon.yellow  { background: var(--warning-light);  color: var(--warning); }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: .83rem;
}
th {
  text-align: left; padding: .7rem 1rem;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: #fafafa;
}
td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
}
.badge-green  { background: var(--success-light); color: #15803d; }
.badge-gray   { background: #f1f5f9;              color: var(--text-muted); }
.badge-orange { background: var(--accent-light);  color: var(--accent-hover); }
.badge-blue   { background: var(--info-light);    color: #1d4ed8; }
.badge-dot    { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 500; border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  cursor: pointer; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); }

.btn-ghost {
  background: transparent; color: var(--text-muted); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: .35rem .7rem; font-size: .76rem; }
.btn-icon { padding: .4rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block; margin-bottom: .35rem;
  font-size: .8rem; font-weight: 500; color: var(--text);
}
.form-label span { color: var(--danger); margin-left: .15rem; }

.form-control {
  width: 100%; padding: .55rem .75rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: .84rem; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-control::placeholder { color: var(--text-sm); }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .73rem; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: .73rem; color: var(--danger); margin-top: .3rem; }

.form-check {
  display: flex; align-items: center; gap: .5rem;
  font-size: .83rem; cursor: pointer;
}
.form-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  font-size: .83rem; border-left: 3px solid;
  margin-bottom: 1rem;
}
.alert-danger  { background: var(--danger-light);  color: #b91c1c; border-color: var(--danger); }
.alert-success { background: var(--success-light); color: #15803d; border-color: var(--success); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.alert-info    { background: var(--info-light);    color: #1e40af; border-color: var(--info); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 440px;
}
.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body   { padding: 1.25rem; font-size: .84rem; color: var(--text-muted); line-height: 1.6; }
.modal-footer {
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .6rem;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: .35rem;
  justify-content: center; margin-top: 1.25rem;
}
.page-btn {
  min-width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: .78rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.page-btn:hover:not(:disabled)  { border-color: var(--accent); color: var(--accent); }
.page-btn.active                 { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled               { opacity: .4; cursor: not-allowed; }

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; padding: 3rem; color: var(--text-muted);
  font-size: .84rem;
}

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; opacity: .3; margin-bottom: .75rem; }
.empty-state p   { font-size: .85rem; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh; background: #B75C3C;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 2.25rem 2rem;
}
.login-brand {
  text-align: center; margin-bottom: 2rem;
}
.login-logo {
  width: 100%; max-width: 200px; height: auto;
  display: block; margin: 0 auto .75rem;
}
.login-brand p { font-size: .95rem; color: #000; }
.login-btn {
  width: 100%; padding: .65rem; margin-top: .5rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.login-btn:hover:not(:disabled) { background: var(--accent-hover); }
.login-btn:disabled { opacity: .7; cursor: not-allowed; }

/* ── Misc ───────────────────────────────────────────────────── */
.admin-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-size: .84rem; color: var(--text-muted);
}
.not-found { text-align: center; padding: 4rem; }
.not-found h2 { margin-bottom: 1rem; }

.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .78rem; }
.fw-600      { font-weight: 600; }
.mt-1        { margin-top: .5rem; }
.mt-2        { margin-top: 1rem; }
.gap-sm      { display: flex; gap: .5rem; }

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--danger); color: #fff;
  padding: .75rem 1rem; font-size: .83rem; text-align: center; z-index: 999;
}

/* ── Rich Text Editor (Quill) ────────────────────────────────── */
.rich-editor-wrapper {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.rich-editor-wrapper .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: .45rem .6rem;
}

.rich-editor-wrapper .ql-container.ql-snow {
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: .93rem;
  color: var(--text);
}

.rich-editor-wrapper .ql-editor {
  min-height: 340px;
  padding: 1rem 1.1rem;
  line-height: 1.7;
}

.rich-editor-wrapper .ql-editor.ql-blank::before {
  color: var(--text-sm);
  font-style: normal;
}

.rich-editor-wrapper .ql-snow .ql-stroke {
  stroke: var(--text-muted);
}
.rich-editor-wrapper .ql-snow .ql-fill {
  fill: var(--text-muted);
}
.rich-editor-wrapper .ql-snow.ql-toolbar button:hover .ql-stroke,
.rich-editor-wrapper .ql-snow .ql-toolbar button:hover .ql-stroke {
  stroke: var(--accent);
}
.rich-editor-wrapper .ql-snow.ql-toolbar button.ql-active .ql-stroke,
.rich-editor-wrapper .ql-snow .ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--accent);
}
.rich-editor-wrapper .ql-snow.ql-toolbar button:hover .ql-fill,
.rich-editor-wrapper .ql-snow.ql-toolbar button.ql-active .ql-fill {
  fill: var(--accent);
}
.rich-editor-wrapper .ql-snow .ql-picker-label:hover,
.rich-editor-wrapper .ql-snow .ql-picker-item:hover {
  color: var(--accent);
}
#blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: .5rem; }

/* ── Image Upload Field ──────────────────────────────────────── */
.img-upload-field {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.img-preview-wrap {
  position: relative;
  display: inline-block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 100%;
}

.img-preview {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
}

.img-preview-remove {
  position: absolute;
  top: .35rem;
  right: .35rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.img-preview-remove:hover { background: rgba(0,0,0,.8); }

.img-upload-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.img-upload-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.img-upload-btn.disabled { opacity: .6; pointer-events: none; }

.img-url-divider {
  font-size: .75rem;
  color: var(--text-sm);
  white-space: nowrap;
}

.img-url-input {
  flex: 1;
  min-width: 0;
  font-size: .8rem !important;
  padding: .3rem .55rem !important;
  height: auto !important;
}

/* ── Hero Background Picker ──────────────────────────────────── */
.bg-picker-wrap {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
}

.bg-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 2px;
}

.bg-picker-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.bg-picker-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.color-swatch-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: .35rem .65rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color .15s;
}
.color-swatch-label:hover { border-color: var(--accent); }

.color-swatch-label input[type="color"] {
  width: 20px;
  height: 20px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 3px;
}

.bg-picker-hint {
  font-size: .75rem;
  color: var(--text-sm);
}

.bg-advanced-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.bg-advanced-label {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.bg-advanced-input {
  font-size: .75rem !important;
  font-family: monospace !important;
  padding: .25rem .5rem !important;
  height: auto !important;
  color: var(--text-muted) !important;
}
