:root {
  --brand: #03c595;
  --brand-dark: #029a74;
  --bg: #f4fdf5;
  --card-bg: #ffffff;
  --border: #dcece4;
  --text: #2d2c2b;
  --text-muted: #6b7a74;
  --danger: #c0392b;
  --radius: 14px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

/* Browsers normally give [hidden] a default display:none, but any selector
   below that sets display explicitly (e.g. .modal { display: flex }) silently
   overrides that default even while the hidden attribute is still present.
   This one rule guarantees hidden always wins, for every element, now and
   in the future. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Alexandria', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Roboto, Arial, sans-serif;
  background: #fbfefc;
  color: var(--text);
}

.topbar {
  background: var(--bg);
  color: var(--text);
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  color: var(--brand);
  width: 40px;
  height: auto;
  flex-shrink: 0;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-toggle {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: inherit;
}

.lang-toggle:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.auth-card .lang-toggle {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.controls input[type='search'] {
  flex: 1;
  min-width: 220px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}

.controls select {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}

.controls input[type='search']:focus,
.controls select:focus,
.resource-form input:focus,
.resource-form textarea:focus,
.resource-form select:focus,
.auth-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(3, 197, 149, 0.15);
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: 0 10px 24px rgba(3, 197, 149, 0.14);
  transform: translateY(-2px);
  border-color: var(--brand);
}

.card-banner {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-banner-video {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.card-banner-pdf {
  background: linear-gradient(135deg, #7a8b85, var(--text));
}

.play-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.play-button::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent var(--brand);
  margin-inline-start: 4px;
}

.pdf-badge {
  border: 2px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 8px;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.card-body {
  padding: 16px 18px 18px;
}

.card-category {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-category {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 4px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 25, 25, 0.55);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 720px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 16px;
  border: none;
  background: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-muted);
}

.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 10px;
  margin-top: 12px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-card .brand-logo {
  width: 48px;
  margin: 0 auto 12px;
  display: block;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: start;
  margin-top: 20px;
}

.auth-form input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  margin-bottom: 10px;
  font-size: 1rem;
  font-family: inherit;
}

.auth-form button {
  margin-top: 8px;
}

.error-message {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.admin-form-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}

.resource-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resource-form label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 10px;
  color: var(--text-muted);
}

.resource-form input,
.resource-form textarea,
.resource-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.upload-row input[type='file'] {
  flex: 1;
  min-width: 200px;
  font-size: 0.9rem;
}

.upload-status {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.upload-status.is-error {
  color: var(--danger);
}

.upload-status.is-success {
  color: var(--brand);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.admin-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  font-family: inherit;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger-solid {
  background: var(--danger);
}

.btn-danger-solid:hover {
  background: #a3301f;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row > div {
  display: flex;
  flex-direction: column;
}

.status-published {
  color: var(--brand);
  font-weight: 600;
  font-size: 0.85rem;
}

.status-draft {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Custom confirm dialog (replaces native window.confirm, which some embedded
   webviews render unreliably / can hang on). */
.confirm-dialog .modal-content {
  max-width: 380px;
  padding: 24px;
  text-align: center;
}

.confirm-dialog-message {
  margin: 4px 0 20px;
  color: var(--text);
}

.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* Mobile */
@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .controls {
    flex-direction: column;
  }

  .controls input[type='search'],
  .controls select {
    width: 100%;
  }

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

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

  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .modal-content {
    padding: 20px;
    width: 96%;
  }
}
