@import url('/assets/css/fonts.css');

:root {
  --primary: #06402B;
  --primary-light: #0A5D3F;
  --accent: #C5A059;
  --accent-dark: #A8843E;
  --accent-soft: #F6EEDC;
  --white: #FFFFFF;
  --light-bg: #F9FAFB;
  --text: #17231E;
  --muted: #5B6B64;
  --border: #E3E8E5;
  --green-soft: #E7F2EC;
  --success: #0E7A45;
  --warning: #A35F00;
  --warning-soft: #FFF4E0;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 30px;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-title: 'Amiri', 'Poppins', Georgia, 'Times New Roman', serif;
  --shadow: 0 1px 2px rgba(6, 64, 43, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--light-bg);
}
a { color: var(--primary-light); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-family: var(--font-title); font-size: 30px; font-weight: 700; color: var(--primary); }
h2 { font-size: 18px; font-weight: 600; color: var(--primary); }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.arabic { font-family: var(--font-title); direction: rtl; }
[hidden] { display: none !important; }

/* ---------- En-tête ---------- */
.app-header {
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-light) 100%);
  color: var(--white);
}
.app-header .bar {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--white); text-decoration: none; min-width: 0; }
.brand img { width: 46px; height: 46px; border-radius: 50%; background: var(--white); flex: none; }
.brand .name { font-family: var(--font-title); font-size: 22px; font-weight: 700; line-height: 1.1; }
.brand .sub { font-size: 12px; opacity: 0.8; letter-spacing: 0.04em; }
.app-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.app-nav::-webkit-scrollbar { display: none; }
.app-nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  white-space: nowrap;
}
.app-nav a:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }
.app-nav a[aria-current='page'] { background: rgba(197, 160, 89, 0.22); color: var(--white); box-shadow: inset 0 -2px 0 var(--accent); }
.header-side { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.clock { text-align: right; line-height: 1.15; }
.clock .time { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock .tz { font-size: 11px; opacity: 0.75; }
.header-side .btn { min-height: 38px; padding: 6px 12px; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: #9CA3AF; display: inline-block; flex: none; }
.conn-dot.ok { background: #34D399; }
.conn-dot.wait { background: #FBBF24; }
.conn-dot.bad { background: #F87171; }

/* ---------- Mise en page ---------- */
.container { max-width: 1320px; margin: 0 auto; padding: var(--gap) 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
.stack { display: grid; gap: var(--gap); }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head p { margin-top: 2px; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  background: var(--white);
  color: var(--primary);
  border-color: var(--border);
}
.btn:hover { border-color: var(--primary-light); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-gold { background: var(--accent); color: var(--primary); border-color: var(--accent); }
.btn-gold:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--white); }
.btn-green { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-green:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-light { background: rgba(255, 255, 255, 0.12); color: var(--white); border-color: rgba(255, 255, 255, 0.3); }
.btn-light:hover { background: rgba(255, 255, 255, 0.2); border-color: var(--white); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn.active.camera { background: var(--accent); color: var(--primary); border-color: var(--accent); }
.btn .ico { font-size: 1.05em; line-height: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Pastilles & badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--success);
  white-space: nowrap;
}
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.neutral { background: #EEF1F0; color: var(--muted); }
.pill.gold { background: var(--accent-soft); color: #7A5C1E; }
.pill.plain::before { display: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #EEF1F0; color: var(--muted); }
.badge.auto { background: var(--green-soft); color: var(--success); }
.badge.manual { background: var(--accent-soft); color: #7A5C1E; }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.sync { background: #E8EEF9; color: #2D4C8C; }

/* ---------- Alertes ---------- */
.alerts { display: grid; gap: 10px; margin-bottom: 22px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warning-soft); color: #6B3E00; border: 1px solid #F5D9A8; }
.alert.error { background: var(--danger-soft); color: #7A1810; border-color: #F4C2BC; }
.alert.info { background: #EEF4F1; color: var(--primary); border-color: var(--border); }
.alert a { color: inherit; font-weight: 600; }

/* ---------- Formulaires ---------- */
label { font-weight: 500; font-size: 14px; }
.field { display: grid; gap: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
input[type='text'], input[type='password'], input[type='url'], input[type='number'], input[type='time'], input[type='date'], select, textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #CCD5D1;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-light); outline: 3px solid rgba(197, 160, 89, 0.45); outline-offset: 0; }
input.narrow { width: 90px; }
input[type='time'] { width: 120px; }
.form-grid { display: grid; gap: 18px; }
.form-grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; min-height: 36px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary-light); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; min-height: 36px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: #C9D1CD; position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch input:checked + .track { background: var(--primary-light); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.today td { background: #FBF8F1; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Tableau de bord ---------- */
.summary {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 20px 24px;
}
.summary .stat { display: flex; flex-direction: column; }
.summary .stat strong { font-size: 26px; color: var(--primary); line-height: 1.1; }
.summary .global-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }

.today-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.prayer-chip { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--white); }
.prayer-chip .p-name { font-weight: 600; color: var(--primary); display: flex; justify-content: space-between; gap: 6px; }
.prayer-chip .p-ar { font-family: var(--font-title); color: var(--accent-dark); font-size: 17px; }
.prayer-chip .p-time { font-size: 13px; color: var(--muted); }
.prayer-chip .p-cam { font-size: 13px; margin-top: 4px; font-weight: 500; }
.prayer-chip.next { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #FFFCF6; }
.prayer-chip.live { border-color: var(--primary-light); background: var(--green-soft); }
.prayer-chip.past { opacity: 0.6; }

.zones { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.zone-card { display: flex; flex-direction: column; gap: 16px; padding: 0; overflow: hidden; }
.zone-card .zc-head { padding: 18px 22px 0; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.zone-card .zc-title { font-family: var(--font-title); font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.zone-card .zc-sub { font-size: 13px; color: var(--muted); }
.zone-card .zc-body { padding: 0 22px; display: grid; gap: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { font-weight: 600; text-align: right; }
.display-now { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--green-soft); }
.display-now .ico { font-size: 26px; }
.display-now .what { font-size: 18px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.display-now .why { font-size: 13px; color: var(--muted); }
.display-now.camera { background: var(--accent-soft); }
.display-now.announcement { background: #EEF0FA; }
.manual-box { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: #7A1810; font-weight: 600; flex-wrap: wrap; }
.manual-box .countdown { font-variant-numeric: tabular-nums; }
.zone-card .zc-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 22px; }
.zone-card .zc-actions .btn { padding: 8px 6px; min-height: 52px; flex-direction: column; gap: 2px; font-size: 13px; }
.zone-card .zc-actions .btn .ico { font-size: 18px; }
.zone-card .zc-more { border-top: 1px solid var(--border); padding: 14px 22px 18px; display: grid; gap: 12px; background: #FCFDFC; }
.device-list { display: grid; gap: 8px; }
.device { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.device .d-name { font-weight: 600; }
.device .d-meta { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.activity { display: grid; gap: 0; }
.activity .item { display: grid; grid-template-columns: 62px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.activity .item:last-child { border-bottom: 0; }
.activity .t { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.activity .msg .zones { color: var(--muted); font-size: 12.5px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #9CA3AF; vertical-align: middle; }
.status-dot.ok { background: var(--success); }
.status-dot.warning { background: #E8A33D; }
.status-dot.error { background: var(--danger); }
.status-dot.info { background: #7B8F87; }

.dash-layout { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1180px) { .dash-layout { grid-template-columns: 1fr; } }

/* ---------- Fenêtre modale ---------- */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(6, 64, 43, 0.25);
  color: var(--text);
}
dialog::backdrop { background: rgba(6, 30, 20, 0.45); }
dialog .dlg-head { padding: 20px 24px 0; }
dialog .dlg-body { padding: 16px 24px; display: grid; gap: 10px; }
dialog .dlg-foot { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid .btn { min-height: 56px; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 1000; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--primary); color: var(--white); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); font-weight: 500; animation: toast-in 0.2s ease-out; border-left: 4px solid var(--accent); }
.toast.error { background: #7A1810; border-left-color: #F87171; }
.toast.warn { background: #6B3E00; border-left-color: #FBBF24; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Connexion ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(140deg, var(--primary) 0%, var(--primary-light) 100%); }
.login-card { width: min(420px, 100%); background: var(--white); border-radius: 18px; padding: 34px 30px; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25); }
.login-card img { width: 140px; height: 140px; border-radius: 50%; }
.login-card h1 { margin: 14px 0 2px; }
.login-card form { display: grid; gap: 14px; margin-top: 24px; text-align: left; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-error { color: var(--danger); font-size: 14px; min-height: 21px; }

/* ---------- Choix en tuiles ---------- */
.tiles { display: grid; gap: 10px; }
.tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--white); }
.tile:hover { border-color: var(--primary-light); }
.tile input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary-light); flex: none; }
.tile .tile-body { display: grid; gap: 2px; }
.tile .tile-body strong { color: var(--primary); }
.tile .tile-body span { font-size: 13px; color: var(--muted); }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #FFFCF6; }

/* ---------- Divers ---------- */
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.preview-box { background: #0B1F17; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; color: rgba(255, 255, 255, 0.8); position: relative; }
.preview-box video, .preview-box img, .preview-box iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; background: #000; }
.ann-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.ann-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; display: flex; flex-direction: column; }
.ann-card .thumb { aspect-ratio: 16 / 9; background: #0B1F17; display: grid; place-items: center; }
.ann-card .thumb img, .ann-card .thumb video { width: 100%; height: 100%; object-fit: contain; }
.ann-card .body { padding: 14px; display: grid; gap: 10px; }
.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
details.help { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; background: #FCFDFC; }
details.help summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details.help pre { background: #0B1F17; color: #E6F0EA; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .btn { min-height: 40px; }

@media (max-width: 720px) {
  :root { --gap: 20px; }
  .card { padding: 18px; }
  .app-header .bar { gap: 10px; }
  .app-nav { order: 3; flex-basis: 100%; }
  .brand .sub { display: none; }
  .clock .time { font-size: 18px; }
  .summary .global-actions { margin-left: 0; width: 100%; }
  .summary .global-actions .btn { flex: 1; }
  .zone-card .zc-actions { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 26px; }
}
