@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

:root {
  --primary: #1b5e20;
  --primary-dark: #145218;
  --primary-light: #e8f5e9;
  --cta: #e65100;
  --bg: #f5f7f5;
  --surface: #fff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --muted: #666;
  --radius: 8px;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 50%, #388e3c 100%);
}

.auth-card {
  position: relative;
  width: fit-content;
  min-width: min(100%, 22rem);
  max-width: 26rem;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem 1.35rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auth-card h1 {
  color: var(--primary);
  font-size: 1.35rem;
  margin: 0;
}

.lang-globe-wrap {
  position: relative;
  flex-shrink: 0;
}

.lang-globe-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid #1565c0;
  background: #e3f2fd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(21, 101, 192, 0.2);
  padding: 0;
}
.lang-globe-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(21, 101, 192, 0.35);
}
.globe-icon { display: block; }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  min-width: 8.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 50;
}
.lang-dropdown button {
  display: block;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  text-align: start;
  cursor: pointer;
  color: var(--text);
}
.lang-dropdown button:hover { background: var(--primary-light); }
.lang-dropdown button.is-active { color: var(--primary); font-weight: 700; }

.auth-card .tabs { margin-bottom: 1rem; }
.auth-card .form-group { margin-bottom: 0.75rem; }
.auth-card .form-group label { font-size: 0.85rem; }
.auth-card .form-group input { padding: 0.55rem 0.75rem; font-size: 0.9rem; }

.otp-inline {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}
.otp-inline .form-group { flex: 1; margin-bottom: 0; }

.register-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 0.75rem;
}
.step-dot {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--muted);
  transition: all 0.2s;
}
.step-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.step-dot.done {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.step-line {
  width: 2rem;
  height: 2px;
  background: var(--border);
}
.step-title {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
}
.step-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.step-actions .btn { flex: 1; }
.register-step .btn-block { margin-bottom: 0.75rem; }
#email-otp-group, #phone-otp-group { margin-top: 0.75rem; }

.demo-hint {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field input { padding-inline-end: 2.75rem; }
.toggle-password {
  position: absolute;
  inset-inline-end: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  border-radius: 4px;
}
.toggle-password:hover { color: var(--primary); }
.toggle-password.is-visible .icon-eye { opacity: 0.5; }

.auth-link-row { text-align: end; margin: -0.25rem 0 0.75rem; }
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.reset-title { color: var(--primary); font-size: 1rem; margin-bottom: 0.35rem; }
.reset-step { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.85rem; }
.reset-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,94,32,0.12);
}
.form-group textarea { min-height: 5rem; resize: vertical; }
.form-row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.color-input { display: flex; align-items: center; gap: 0.75rem; }
.color-input input[type="color"] { width: 3rem; height: 2.5rem; border: none; cursor: pointer; padding: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-cta { background: var(--cta); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-danger { background: #c62828; color: #fff; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand { font-size: 1.25rem; font-weight: 700; margin-bottom: 2rem; padding: 0 0.5rem; }
.sidebar-nav { list-style: none; flex: 1; }
.sidebar-nav li { margin-bottom: 0.25rem; }
.sidebar-nav button, .sidebar-nav a {
  display: block;
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font: inherit;
  text-align: start;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.sidebar-nav button:hover, .sidebar-nav a:hover,
.sidebar-nav button.active { background: rgba(255,255,255,0.15); color: #fff; }

.main-content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }

.page-header { margin-bottom: 1.5rem; }
.page-header h2 { color: var(--primary); font-size: 1.5rem; }
.page-header p { color: var(--muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card h3 { color: var(--primary); margin-bottom: 1rem; font-size: 1.1rem; }

/* Pharmacy list */
.pharmacy-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.pharmacy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.pharmacy-card:hover { box-shadow: 0 4px 16px rgba(27,94,32,0.1); border-color: var(--primary); }
.pharmacy-card h3 { color: var(--primary); margin-bottom: 0.25rem; }
.pharmacy-card .slug { color: var(--muted); font-size: 0.85rem; }
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-published { background: #e8f5e9; color: #2e7d32; }
.badge-draft { background: #fff3e0; color: #e65100; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Blocks */
.block-list { display: flex; flex-direction: column; gap: 0.5rem; }
.block-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
}
.block-item.dragging { opacity: 0.5; }
.block-item .drag-handle { color: var(--muted); cursor: grab; }
.block-item .block-name { flex: 1; font-weight: 600; }
.block-item input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

/* Branch */
.branch-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; }
.branch-item h4 { color: var(--primary); margin-bottom: 0.5rem; }

/* Preview bar */
.preview-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.preview-bar .url { font-size: 0.85rem; color: var(--muted); word-break: break-all; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}
.toast.error { background: #c62828; }
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(1rem); } }

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

/* Logo preview */
.logo-preview { width: 5rem; height: 5rem; border: 2px dashed var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 0.75rem; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .main-content { padding: 1rem; }
}
