:root {
  --bg: #f4f2ee;
  --bg-elevated: #fffcf8;
  --ink: #14171c;
  --ink-soft: #5c6570;
  --line: rgba(20, 23, 28, 0.08);
  --line-strong: rgba(20, 23, 28, 0.14);
  --accent: #b08d3e;
  --accent-deep: #8f702c;
  --accent-soft: rgba(176, 141, 62, 0.12);
  --whatsapp: #1f9a54;
  --whatsapp-deep: #187a42;
  --danger: #c4473a;
  --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.04);
  --shadow-md: 0 10px 30px rgba(20, 23, 28, 0.08);
  --radius: 14px;
  --radius-lg: 22px;
  --font-ar: 'IBM Plex Sans Arabic', sans-serif;
  --font-en: 'Instrument Sans', 'IBM Plex Sans Arabic', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ar);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(176, 141, 62, 0.08), transparent 55%),
    linear-gradient(180deg, #f7f5f1 0%, var(--bg) 40%, #efece6 100%);
  color: var(--ink);
  direction: rtl;
  line-height: 1.65;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  text-decoration: none;
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-deep);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea {
  min-height: 90px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: rgba(176, 141, 62, 0.7);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
}

.form-group label .required {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-error { background: var(--danger); }
.toast-success { background: var(--whatsapp-deep); }

.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  width: 250px;
  background: #15181d;
  color: #fff;
  padding: 1.4rem 0;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.admin-sidebar-header {
  padding: 0 1.3rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.8rem;
}

.admin-sidebar-header h2 {
  font-size: 1.05rem;
  color: #e8d5a3;
}

.admin-sidebar-header p {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
}

.admin-nav {
  list-style: none;
}

.admin-nav li button {
  width: 100%;
  text-align: right;
  padding: 0.85rem 1.3rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.admin-nav li button:hover,
.admin-nav li button.active {
  background: rgba(232, 213, 163, 0.08);
  color: #e8d5a3;
}

.admin-main {
  flex: 1;
  margin-right: 250px;
  padding: 1.6rem;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
  gap: 1rem;
}

.admin-topbar h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.admin-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.2rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.8rem 0.7rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

.admin-table th {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.admin-form-grid .full-width {
  grid-column: 1 / -1;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.status-active {
  background: #e5f6ec;
  color: #176b3a;
}

.status-inactive {
  background: #fdeceb;
  color: #9d2f26;
}

.image-preview {
  width: 120px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  background: #eee;
  margin-top: 0.5rem;
  border: 1px solid var(--line);
}

.image-preview img,
.image-preview-wide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-wide {
  width: 100%;
  max-width: 420px;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: #eee;
  margin-top: 0.5rem;
  border: 1px solid var(--line);
}

.toggle-switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cfc8bc;
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  right: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--whatsapp);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(-20px);
}

.complex-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.complex-inline-form input[type="text"],
.complex-inline-form input[type="number"] {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  min-height: 42px;
}

.complex-inline-form input[type="text"] {
  flex: 1;
  min-width: 180px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(700px 400px at 20% 0%, rgba(176, 141, 62, 0.16), transparent 60%),
    #12151a;
}

.login-card {
  background: var(--bg-elevated);
  border-radius: 20px;
  padding: 2rem;
  width: min(100%, 400px);
  box-shadow: var(--shadow-md);
}

.login-card h2 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}

.login-card .subtitle,
.login-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin-bottom: 1.4rem;
}

.login-logo {
  text-align: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: var(--ink);
  color: #e8d5a3;
  display: grid;
  place-items: center;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 1.2rem;
}

.login-note {
  margin-top: 1rem;
  margin-bottom: 0;
  line-height: 1.5;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 16, 0.48);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  padding: 0;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay .modal {
  width: min(100%, 520px);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-elevated);
  border-radius: 24px 24px 0 0;
  transform: translateY(24px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(20, 23, 28, 0.05);
  color: var(--ink-soft);
  font-size: 1.2rem;
}

.modal-body {
  padding: 1.25rem;
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-right: 0;
    padding: 1rem;
  }

  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: flex;
  }
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }

  .modal-overlay .modal {
    border-radius: 20px;
    transform: translateY(12px) scale(0.98);
  }

  .modal-overlay.active .modal {
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
