/* ELS MARC21 - Main Stylesheet */

/* ─── Embedded fonts (offline, no internet needed) ─── */
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-ExtraBold.ttf') format('truetype'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('../fonts/IBMPlexMono-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('../fonts/IBMPlexMono-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --bg:           #F3F3F3;
  --surface:      #ffffff;
  --surface2:     #f8f9fc;
  --border:       #e2e6ef;
  --brand:        #c10037;
  --brand-dark:   #660033;
  --brand-light:  #fbe7ec;
  --primary:      #c10037;
  --primary-dark: #660033;
  --primary-light:#fbe7ec;
  --secondary:    #1abfa8;
  --accent:       #ff6b35;
  --teal:         #0ea5a0;
  --blue:         #2563eb;
  --text:         #333333;
  --text2:        #5a6175;
  --text3:        #9ba3b8;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --success:      #10b981;
  --info:         #3b82f6;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.14);
  --radius:       14px;
  --radius-sm:    8px;
  --radius-xs:    5px;
  --font:         'Tajawal', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
  --transition:   0.2s ease;
  --header-h:     64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── HEADER ─── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  display: flex; align-items: center;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  width: 100%; max-width: 1440px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-brand {
  display: flex; align-items: center; gap: 12px;
}
.brand-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 16px;
  letter-spacing: -0.5px;
}
.brand-text { line-height: 1.1; }
.brand-title { font-weight: 800; font-size: 16px; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

.header-nav {
  display: flex; align-items: center; gap: 4px;
}
.nav-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  color: var(--text2); background: transparent;
  border: none; cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg); color: var(--primary); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-btn svg { flex-shrink: 0; }
.nav-btn-search { background: rgba(13,148,136,0.08); color: #0d9488; }
.nav-btn-search:hover { background: rgba(13,148,136,0.14); color: #0f766e; }
.nav-btn-search.active { background: rgba(13,148,136,0.16); color: #0f766e; font-weight: 700; }

.header-right {
  display: flex; align-items: center; gap: 12px;
}
.lang-switcher {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 4px;
}
.lang-btn {
  padding: 5px 10px; border-radius: 5px; border: none;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text2); background: transparent;
  transition: all var(--transition);
}
.lang-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.user-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--bg); border-radius: 40px;
  cursor: pointer; transition: background var(--transition);
}
.user-badge:hover { background: var(--border); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text3); }

/* ─── MAIN LAYOUT ─── */
.app-main {
  margin-top: var(--header-h);
  padding: 32px 24px;
  max-width: 1440px;
  margin-left: auto; margin-right: auto;
}
.app-main { margin-top: var(--header-h); }

/* ─── PAGE WRAPPER ─── */
.page-wrap {
  max-width: 1440px; margin: 0 auto;
  padding: calc(var(--header-h) + 32px) 24px 48px;
}

/* ─── DASHBOARD ─── */
.dash-hero {
  text-align: center; padding: 48px 0 40px;
}
.dash-hero h1 {
  font-size: 38px; font-weight: 800; color: var(--text);
  margin-bottom: 10px;
}
.dash-hero p { font-size: 17px; color: var(--text2); }

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.dash-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-top: 4px solid var(--cardc, var(--brand));
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative; overflow: hidden;
}
.dash-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 60%, var(--tint, rgba(193,0,55,0.04)));
  pointer-events: none;
}
.dash-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px -8px rgba(15,23,42,.18);
}
.dash-card.cat  { --cardc: #c10037; --tint: #fbe7ec; }
.dash-card.lre  { --cardc: #f59e0b; --tint: #fff7e0; }
.dash-card.xbo  { --cardc: #7c3aed; --tint: #f4efff; }
.dash-card.srch { --cardc: #0d9488; --tint: #e7f6f4; }
.dash-card.stt  { --cardc: #6366f1; --tint: #eef0ff; }
.dash-card.set  { --cardc: #475569; --tint: #eef1f5; }
.card-count {
  position: absolute; top: 12px; inset-inline-end: 12px;
  font-size: 11px; font-weight: 700;
  color: white; background: var(--cardc, var(--brand));
  border-radius: 20px; padding: 2px 10px;
}
.card-icon {
  width: 50px; height: 50px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 24px;
}
.card-icon.cat  { background: linear-gradient(135deg, #c10037, #660033); }
.card-icon.lre  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.card-icon.xbo  { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.card-icon.srch { background: linear-gradient(135deg, #0d9488, #0f766e); }
.card-icon.set  { background: linear-gradient(135deg, #475569, #1e293b); }
.card-icon img, .card-icon svg { width: 26px; height: 26px; }
.dash-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.dash-card p  { color: var(--text2); font-size: 12.5px; line-height: 1.5; margin-bottom: 12px; }
.card-link {
  font-size: 13px; font-weight: 600; color: var(--cardc, var(--primary));
  display: inline-flex; align-items: center; gap: 6px;
}
.card-link:hover { gap: 10px; }

/* Compact info strip */
.info-strip {
  margin-top: 26px;
  padding: 8px 26px;
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: var(--radius-sm);
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: center; justify-content: space-between;
  font-size: 11.5px; color: #929292;
  line-height: 1.7;
}
.info-strip span { max-width: 380px; }
.info-strip a { color: var(--primary); text-decoration: underline; }
.info-strip b { color: #6f6f6f; }

/* Colored stats cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.stat-card {
  border-radius: var(--radius);
  padding: 18px 20px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-ic {
  font-size: 24px; width: 48px; height: 48px; border-radius: 12px;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-big { font-size: 27px; font-weight: 800; line-height: 1; }
.stat-lb  { font-size: 12px; opacity: .92; margin-top: 5px; }
.stat-brand  { background: linear-gradient(135deg, #c10037, #8d0029); }
.stat-maroon { background: linear-gradient(135deg, #660033, #4a0025); }
.stat-teal   { background: linear-gradient(135deg, #0d9488, #0ea5a0); }
.stat-blue   { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-amber  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-green  { background: linear-gradient(135deg, #10b981, #059669); }

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all var(--transition);
  white-space: nowrap; line-height: 1;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; border: none; }
.btn-primary:hover { background: var(--brand-dark); color: white; transform: translateY(-1px); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-success { background: #d1fae5; color: var(--success); }
.btn-success:hover { background: var(--success); color: white; }
.btn-ghost { background: transparent; color: var(--text2); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }

/* ─── TABLES ─── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: var(--surface2);
  padding: 12px 16px; text-align: start;
  font-weight: 600; color: var(--text2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 24px; }
.card-title { font-size: 16px; font-weight: 700; }

/* ─── FORMS ─── */
.form-group { margin-bottom: 10px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--surface); transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.required-star { color: var(--danger); margin-inline-start: 3px; }

/* ─── MARC EDITOR ─── */
.marc-editor { }
.marc-field-block {
  background: var(--surface);
  border: 2px solid #8b95a8;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-sm);
}
.marc-field-block:hover { border-color: #64718a; }
.marc-field-block:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.marc-field-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer; user-select: none;
  min-height: 44px;
  border-bottom: 1px solid #cbd2e0;
}
.marc-field-block.collapsed .marc-field-header {
  border-radius: var(--radius-sm);
  border-bottom: none;
}
.marc-tag-badge {
  font-family: var(--font-mono); font-size: 15px; font-weight: 800;
  background: var(--primary-light); color: var(--primary);
  padding: 4px 12px; border-radius: 6px; min-width: 52px; text-align: center;
  flex-shrink: 0;
}
.marc-field-name { font-size: 15px; font-weight: 600; color: var(--text2); flex: 1; }
.marc-field-body { padding: 12px 14px 14px; }
.marc-indicators { display: flex; gap: 10px; margin-bottom: 6px; }

/* ─── Indicators toggle ─── */
.indicators-toggle-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; margin-bottom: 4px;
  border: 1px dashed var(--border); border-radius: var(--radius-xs);
  background: transparent; color: var(--text3); font-size: 11px;
  font-family: var(--font-mono); cursor: pointer;
  transition: all var(--transition);
}
.indicators-toggle-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.indicators-wrap { display: none; }
.indicators-wrap.open { display: flex; gap: 8px; margin-bottom: 6px; }

/* ─── Subfield code label ─── */
.subfield-code-label {
  font-family: var(--font-mono); font-size: 14px; font-weight: 800;
  color: var(--teal); background: var(--surface2);
  border: 1.5px solid #9aa5b8; border-radius: var(--radius-xs);
  padding: 7px 8px; min-width: 38px; text-align: center;
  flex-shrink: 0; display: flex; align-items: center; gap: 4px;
}

/* ─── Control fields collapsible card ─── */
.card-header-toggle {
  cursor: pointer; user-select: none;
}
.card-header-toggle:hover { background: var(--surface2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.card-collapse-icon {
  font-size: 14px; color: var(--text3); transition: transform var(--transition);
}
.card.collapsed .card-collapse-icon { transform: rotate(-90deg); }
.card.collapsed .card-body-collapsible { display: none; }
.card.collapsed { border-radius: var(--radius); }
.card.collapsed .card-header { border-bottom: none; border-radius: var(--radius); }

/* ─── Dashboard footer ─── */
.dash-footer {
  margin-top: 48px; padding: 20px 24px;
  border-top: 1px solid var(--border);
  text-align: center; color: var(--text3);
  font-size: 12px; line-height: 1.9;
}
.ind-input {
  width: 52px; padding: 6px 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: 14px; text-align: center;
  background: var(--surface2); outline: none;
  transition: border-color var(--transition);
}
.ind-input:focus { border-color: var(--primary); }
.ind-label { font-size: 12px; color: var(--text3); margin-bottom: 3px; }

.subfield-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 7px;
}
.subfield-code-wrap {
  position: relative; display: flex; align-items: center;
}
.subfield-dollar {
  position: absolute; inset-inline-start: 10px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  color: var(--primary);
}
.subfield-code {
  width: 42px; padding: 7px 5px 7px 20px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: 13px; text-align: center;
  background: var(--surface2); outline: none;
  transition: border-color var(--transition);
}
.subfield-code:focus { border-color: var(--primary); }
.subfield-value {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--surface); outline: none;
  transition: border-color var(--transition);
}
.subfield-value:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.subfield-name {
  font-family: var(--font); font-size: 11px; color: var(--text2);
  margin-inline-start: 6px; font-style: normal; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.btn-del-sub {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: #fee2e2; color: var(--danger);
  cursor: pointer; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.btn-del-sub:hover { background: var(--danger); color: white; }

.btn-add-sub {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px; padding: 3px 10px;
  border: 1px dashed var(--primary);
  border-radius: var(--radius-xs);
  color: var(--primary); background: transparent;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.btn-add-sub:hover { background: var(--primary-light); }

.marc-field-actions {
  display: flex; align-items: center; gap: 4px;
}
.btn-collapse {
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all var(--transition);
}
.btn-collapse:hover { background: var(--bg); color: var(--text); }
.marc-field-block.collapsed .marc-field-body { display: none; }
.marc-field-block.collapsed .collapse-icon { transform: rotate(-90deg); }

/* ─── SEARCH ─── */
.search-bar {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.search-main {
  display: flex; gap: 10px; align-items: center; margin-bottom: 14px;
}
.search-input-wrap {
  position: relative; flex: 1;
}
.search-icon-pos {
  position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text3);
}
.search-input {
  width: 100%; padding: 11px 14px 11px 42px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--surface2); outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--primary); background: var(--surface); }
.search-filters { display: flex; gap: 10px; flex-wrap: wrap; }

/* Scope filter tabs (geo: all / catalog / external) */
.scope-filter { margin-top: 14px; }
.scope-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.scope-tab {
  cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text2); font-size: 13px; font-weight: 600;
  transition: all 0.15s;
}
.scope-tab:hover { border-color: var(--primary); color: var(--primary); }
.scope-tab.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; box-shadow: 0 2px 8px var(--shadow);
}

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #d1fae5; color: var(--success); }
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: var(--blue); }
.badge-gray    { background: var(--bg); color: var(--text2); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 640px; max-height: 90vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform 0.25s ease;
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--bg); color: var(--text2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; }

/* ─── ALERTS ─── */
.alert {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 14px; display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ─── SIDEBAR / TABS ─── */
.d-none { display: none !important; }
.settings-layout {
  display: grid; grid-template-columns: 230px 1fr; gap: 24px;
}
.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  height: fit-content; position: sticky; top: calc(var(--header-h) + 20px);
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: all var(--transition);
  border: none; background: transparent; width: 100%; text-align: start;
}
.settings-nav-item:hover { background: var(--bg); color: var(--text); }
.settings-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.settings-nav-item svg { flex-shrink: 0; }
.settings-content { }

/* ─── PAGINATION ─── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; margin-top: 24px;
}
.page-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; color: var(--text2); transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { background: var(--bg); color: var(--text); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-link {
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 13px; font-weight: 600;
  text-decoration: none; transition: all var(--transition);
}
.page-link:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-info { font-size: 13px; color: var(--text-muted); padding: 0 8px; }

/* ─── LIBRARY RECORDS (سجلات المكتبة) ─── */
.reg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.reg-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-bottom: 4px solid var(--brand-light);
  border-left: 3px solid transparent;
  transition: all 0.22s ease; position: relative;
}
.reg-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-left-color: var(--primary); }
.reg-ic {
  width: 52px; height: 52px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.reg-info { flex: 1; min-width: 0; }
.reg-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.reg-count { font-size: 13px; color: var(--primary); font-weight: 700; }
.reg-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.reg-go { font-size: 18px; color: var(--text-muted); transition: all .2s; }
.reg-card:hover .reg-go { color: var(--primary); transform: translateX(-4px); }

/* ─── EXTERNAL BOOKS (كتب خارجية) ─── */
.ext-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
}
.ext-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); position: relative;
  transition: all 0.22s ease;
}
.ext-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.ext-cover {
  height: 180px; position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.ext-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ext-files {
  position: absolute; top: 8px; inset-inline-end: 8px;
  background: rgba(0,0,0,.55); color: white;
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
}
.ext-body { padding: 14px 16px; }
.ext-title {
  font-weight: 700; font-size: 14px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 4px;
}
.ext-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ext-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ext-actions {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* ─── TOAST ─── */
#toast-container {
  position: fixed; bottom: 24px; inset-inline-end: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 260px; padding: 14px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease;
  cursor: pointer;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }
.toast.success { background: var(--success); color: white; }
.toast.error   { background: var(--danger); color: white; }
.toast.info    { background: var(--blue); color: white; }
.toast.warning { background: var(--warning); color: white; }

/* ─── CONTROL FIELD ─── */
.ctrl-field-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.ctrl-tag { font-family: var(--font-mono); font-weight: 600; color: var(--primary); min-width: 40px; }
.ctrl-name { font-size: 13px; color: var(--text2); min-width: 180px; }
.ctrl-value {
  flex: 1; padding: 7px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: 13px; outline: none;
  background: var(--surface); transition: border-color var(--transition);
}
.ctrl-value:focus { border-color: var(--primary); }

/* ─── RECORD VIEW ─── */
.record-view-field {
  margin-bottom: 14px; padding: 14px 16px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border-inline-start: 3px solid var(--primary-light);
}
.record-view-field:hover { border-inline-start-color: var(--primary); }
.rvf-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rvf-tag { font-family: var(--font-mono); font-weight: 700; color: var(--primary); }
.rvf-name { font-size: 13px; font-weight: 600; color: var(--text2); }
.rvf-indicators { font-family: var(--font-mono); font-size: 12px; color: var(--text3); }
.rvf-subfield { display: flex; gap: 10px; margin-bottom: 4px; }
.rvf-code { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--teal); min-width: 24px; }
.rvf-value { font-size: 14px; color: var(--text); }

/* ─── UTILITY ─── */
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.gap-2{gap:8px}.gap-3{gap:16px}
.d-flex{display:flex}.align-center{align-items:center}.justify-between{justify-content:space-between}
.text-muted{color:var(--text2)}.text-small{font-size:13px}.text-mono{font-family:var(--font-mono)}
.w-100{width:100%}.text-center{text-align:center}
.divider{border:none;border-top:1px solid var(--border);margin:20px 0}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .dash-cards { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
  .header-nav { display: none; }
}
@media (max-width: 600px) {
  .page-wrap { padding-inline: 14px; }
  .dash-stats { flex-direction: column; }
  .stat-item { border-inline-end: none; border-bottom: 1px solid var(--border); }
}
