:root {
  --bg: #f3f4f4;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #68736f;
  --line: #d9dfdc;
  --accent: #2f9db4;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
}

.admin-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

header p,
h1,
h2 {
  margin: 0;
}

header p {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: 42px;
}

header a,
.jais-sync-head a,
button,
.import-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-menu button {
  min-height: 42px;
  padding: 9px 13px;
  background: #e7ecea;
  color: var(--ink);
}

.admin-menu button.is-active,
.admin-menu button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

#settingsForm {
  display: grid;
  gap: 18px;
}

.admin-panels {
  min-width: 0;
}

.admin-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-panel[hidden] {
  display: none !important;
}

.admin-panel[data-admin-panel="quran"] section,
.admin-panel[data-admin-panel="khutbah"] section,
.admin-panel[data-admin-panel="calendar"] section {
  grid-column: 1 / -1;
}

.admin-login {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  margin: clamp(72px, 16vh, 150px) auto 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-login p {
  margin: 0;
}

.admin-login > div > p:first-child {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 14px;
}

#loginStatus {
  min-height: 1.2em;
  color: var(--muted);
  font-weight: 800;
}

section {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 750;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.upload-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 14px;
}

.sound-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.stacked-actions {
  display: grid;
  gap: 10px;
}

.stacked-actions button {
  width: max-content;
  padding: 10px 14px;
  border-radius: 6px;
}

.website-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 120px auto;
  align-items: end;
  gap: 10px;
}

.sound-row button {
  padding: 10px 14px;
  border-radius: 6px;
}

.collapsible-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.preview {
  width: 130px;
  background: #e6e8e7;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
}

.preview.square {
  aspect-ratio: 1 / 1;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#qrPreview img {
  object-fit: contain;
  padding: 8px;
  background: #fff;
}

.media-list {
  display: grid;
  gap: 10px;
}

.media-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.media-item.is-inactive {
  opacity: 0.58;
}

.media-item-header,
.media-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.media-item-heading {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.media-thumb {
  width: 58px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e6e8e7;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.website-preview,
.website-thumb {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(47, 157, 180, 0.14), rgba(255, 255, 255, 0.48)),
    #e6e8e7;
  color: var(--accent);
  font-weight: 900;
}

.media-item-title {
  min-width: 0;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-fields {
  display: grid;
  grid-template-columns: 1.4fr 0.75fr 0.9fr;
  gap: 10px;
}

.media-item-actions button {
  padding: 8px 10px;
  border-radius: 5px;
}

.media-item-actions label {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
}

.media-item-actions input[type="checkbox"] {
  width: auto;
}

.azan-media-list,
.quran-prayer-list,
.islamic-event-list {
  display: grid;
  gap: 10px;
}

.azan-media-item,
.quran-prayer-item,
.islamic-event-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.azan-media-item > div:first-child,
.islamic-event-item {
  min-width: 0;
}

.azan-media-item strong,
.islamic-event-item strong {
  font-weight: 900;
}

.azan-media-item span,
.islamic-event-item span,
.islamic-event-item small {
  color: var(--muted);
  font-weight: 750;
}

.azan-media-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) repeat(3, auto);
  align-items: end;
  gap: 8px;
}

.azan-media-actions button {
  min-height: 42px;
  padding: 8px 10px;
}

.quran-display-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.test-actions button {
  background: #246f8a;
}

.quran-prayer-item {
  grid-template-columns: minmax(140px, 0.8fr) minmax(150px, 0.8fr) minmax(180px, 1.4fr);
  align-items: end;
}

.calendar-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  align-items: end;
  gap: 10px;
}

@media (max-width: 780px) {
  .media-fields {
    grid-template-columns: 1fr;
  }

  .website-row {
    grid-template-columns: 1fr;
  }

  .azan-media-actions,
  .quran-prayer-item,
  .calendar-actions {
    grid-template-columns: 1fr;
  }
}

.hint {
  margin: 0;
  color: var(--muted);
}

footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.import-button input {
  display: none;
}

#saveStatus {
  color: var(--muted);
  font-weight: 800;
}

.upload-status {
  display: grid;
  flex: 1 1 320px;
  min-width: min(100%, 280px);
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 157, 180, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.upload-progress-head strong,
.upload-progress-head span {
  overflow-wrap: anywhere;
}

.upload-progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(47, 157, 180, 0.14);
}

.upload-progress-bar span {
  display: block;
  width: var(--upload-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f9db4, #177a4f);
  transition: width 180ms ease;
}

.upload-status[data-state="waiting"] .upload-progress-bar span {
  width: 100%;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.62), transparent),
    #2f9db4;
  background-size: 42px 100%, 100% 100%;
  animation: khutbahUploadWaiting 920ms linear infinite;
}

.upload-status[data-state="done"] {
  border-color: rgba(25, 115, 73, 0.22);
  background: rgba(201, 243, 222, 0.54);
}

.upload-status[data-state="error"] {
  border-color: rgba(148, 58, 58, 0.26);
  background: rgba(255, 232, 232, 0.72);
}

.khutbah-control {
  margin-bottom: 18px;
  border-color: rgba(47, 157, 180, 0.32);
  background:
    linear-gradient(135deg, rgba(47, 157, 180, 0.08), rgba(255, 255, 255, 0.88)),
    var(--panel);
}

.khutbah-control-head,
.khutbah-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.khutbah-control-head p {
  margin: 0;
  color: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
}

#khutbahStatus {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(104, 83, 28, 0.18);
  border-radius: 999px;
  background: #f8e9af;
  color: #604915;
  font-weight: 900;
}

#khutbahStatus[data-active="true"] {
  border-color: rgba(25, 115, 73, 0.2);
  background: #c9f3de;
  color: #135b3b;
}

.khutbah-doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 160px;
  gap: 10px;
  align-items: end;
}

.khutbah-upload-status {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(47, 157, 180, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.khutbah-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.khutbah-progress-head strong,
.khutbah-progress-head span {
  overflow-wrap: anywhere;
}

.khutbah-progress-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(47, 157, 180, 0.14);
}

.khutbah-progress-bar span {
  display: block;
  width: var(--khutbah-upload-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f9db4, #177a4f);
  transition: width 180ms ease;
}

.khutbah-upload-status[data-state="waiting"] .khutbah-progress-bar span {
  width: 100%;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.62), transparent),
    #2f9db4;
  background-size: 42px 100%, 100% 100%;
  animation: khutbahUploadWaiting 920ms linear infinite;
}

.khutbah-upload-status[data-state="done"] {
  border-color: rgba(25, 115, 73, 0.22);
  background: rgba(201, 243, 222, 0.54);
}

.khutbah-upload-status[data-state="error"] {
  border-color: rgba(148, 58, 58, 0.26);
  background: rgba(255, 232, 232, 0.72);
}

.khutbah-current {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.khutbah-current strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.khutbah-current span {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.khutbah-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(47, 157, 180, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.khutbah-preview[hidden] {
  display: none !important;
}

.khutbah-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.khutbah-preview-head span {
  white-space: nowrap;
}

.khutbah-preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 380px);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.khutbah-preview-frame,
.khutbah-preview-media,
.khutbah-preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.khutbah-preview-media {
  object-fit: contain;
}

.khutbah-preview-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.khutbah-preview-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.khutbah-main-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.khutbah-main-actions button {
  min-height: 58px;
  border-radius: 10px;
  font-size: 20px;
}

.khutbah-main-actions button:first-child {
  background: #177a4f;
}

.khutbah-main-actions button:last-child {
  background: #943a3a;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.khutbah-jump-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.khutbah-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 10px;
  align-items: end;
}

.khutbah-jump-row button {
  min-height: 45px;
}

.jais-sync {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(47, 157, 180, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.jais-sync-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.jais-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jais-sync-head > div:not(.jais-actions) {
  display: grid;
  gap: 3px;
}

.jais-sync-head strong {
  font-size: 17px;
}

.jais-sync-head span,
.jais-empty {
  color: var(--muted);
  font-weight: 750;
}

.jais-results {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.jais-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.jais-item-title {
  display: grid;
  gap: 2px;
}

.jais-item-title span {
  color: var(--muted);
  font-weight: 800;
}

.jais-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jais-assets button {
  padding: 9px 11px;
  border-radius: 999px;
  background: #246f8a;
  font-size: 14px;
}

.jais-assets a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  color: #1f5f78;
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}

.jais-assets button.is-presentation {
  background: #6d5b9f;
}

@keyframes khutbahUploadWaiting {
  from {
    background-position: -42px 0, 0 0;
  }

  to {
    background-position: calc(100% + 42px) 0, 0 0;
  }
}

@media (max-width: 780px) {
  .admin-panel {
    grid-template-columns: 1fr;
  }

  header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions a {
    flex: 1;
    text-align: center;
  }

  .khutbah-control {
    margin-left: -8px;
    margin-right: -8px;
    padding: 14px;
  }

  .khutbah-control-head,
  .khutbah-current {
    align-items: start;
    flex-direction: column;
  }

  .khutbah-doc-row,
  .khutbah-url-row,
  .khutbah-jump-row {
    grid-template-columns: 1fr;
  }

  .jais-sync-head {
    align-items: stretch;
    flex-direction: column;
  }

  .jais-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .jais-sync-head a,
  .jais-sync-head button,
  .jais-assets a,
  .jais-assets button {
    width: 100%;
    justify-content: center;
  }

  .jais-assets {
    display: grid;
    grid-template-columns: 1fr;
  }

  .khutbah-main-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #khutbahPrevious {
    grid-column: 1;
    grid-row: 1;
  }

  #khutbahNext {
    grid-column: 2;
    grid-row: 1;
  }

  #khutbahStart {
    grid-column: 1;
    grid-row: 2;
  }

  #khutbahEnd {
    grid-column: 2;
    grid-row: 2;
  }

  .khutbah-main-actions button {
    min-height: 68px;
    font-size: 21px;
  }
}
