/* ============================================================
   Qabil Doctor - Health Assistant App Styles
   Mobile-first design with RTL support
   ============================================================ */

:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f0f9ff;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --transition: 0.25s ease;
  --nav-height: 64px;
  --header-height: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body.rtl {
  direction: rtl;
  font-family: 'Noto Nastaliq Urdu', 'Segoe UI', system-ui, sans-serif;
}

/* ---- App Shell ---- */
.app-container {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
}

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
}

.app-header .logo .icon {
  font-size: 1.6rem;
}

.app-header select {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(10px);
}

.app-header select option {
  color: var(--text);
  background: white;
}

/* ---- Pages ---- */
.page {
  display: none;
  padding: 20px;
  padding-bottom: calc(var(--nav-height) + 30px);
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  height: var(--nav-height);
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: 100;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  position: relative;
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  transition: var(--transition);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ---- Home Page ---- */
.home-hero {
  background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
  border: 1px solid rgba(14, 165, 233, 0.15);
}

.home-hero h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  color: var(--text);
}

.home-hero p {
  color: var(--text-light);
  margin-bottom: 16px;
}

.home-hero .symptom-input-wrap {
  display: flex;
  background: white;
  border-radius: 30px;
  padding: 4px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}

.home-hero .symptom-input-wrap input {
  flex: 1;
  border: none;
  padding: 12px 16px;
  font-size: 0.95rem;
  border-radius: 30px;
  outline: none;
  background: transparent;
  color: var(--text);
}

.home-hero .symptom-input-wrap button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
}

.home-hero .symptom-input-wrap button:hover {
  background: var(--primary-dark);
}

.home-hero .voice-link {
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Quick Grid */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.quick-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

.quick-card:hover, .quick-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.quick-card .card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.quick-card h4 {
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--text);
}

.quick-card p {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ---- Symptom Checker Page ---- */
.body-part-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.body-part-btn {
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  color: var(--text-light);
}

.body-part-btn.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.symptom-textarea {
  width: 100%;
  min-height: 100px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  background: white;
}

.symptom-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.severity-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.severity-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
  height: 6px;
}

.severity-label {
  font-size: 0.8rem;
  color: var(--text-light);
  min-width: 70px;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

/* Result Sections */
.symptom-result {
  display: none;
  margin-top: 20px;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-section {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.result-section h4 {
  margin-bottom: 10px;
  font-size: 1.05rem;
  color: var(--text);
}

.result-section ul {
  padding-left: 20px;
}

body.rtl .result-section ul {
  padding-left: 0;
  padding-right: 20px;
}

.result-section li {
  margin-bottom: 6px;
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.5;
}

.medicine-card {
  background: var(--primary-light);
  border-radius: var(--radius-xs);
  padding: 12px;
  margin-bottom: 8px;
  border-left: 4px solid var(--primary);
}

body.rtl .medicine-card {
  border-left: none;
  border-right: 4px solid var(--primary);
}

.medicine-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.med-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-light);
}

.med-details .precaution {
  color: var(--warning);
  font-style: italic;
}

.severity-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 8px 0;
}

.severity-mild { background: #dcfce7; color: #166534; }
.severity-moderate { background: #fef9c3; color: #854d0e; }
.severity-severe { background: #fee2e2; color: #991b1b; }

.disclaimer {
  background: #fef9c3;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: #854d0e;
  margin-top: 10px;
}

/* ---- Doctor Finder ---- */
.location-search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.location-search input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 30px;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.location-search input:focus {
  border-color: var(--primary);
}

.btn-gps {
  background: var(--primary-light);
  border: none;
  padding: 12px 16px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  white-space: nowrap;
}

.specialty-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 30px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  background: white;
  outline: none;
  cursor: pointer;
}

.btn-search {
  background: linear-gradient(135deg, var(--secondary), #059669);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  margin-bottom: 16px;
}

.doctor-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doctor-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease backwards;
}

.doctor-avatar {
  font-size: 2.5rem;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 50%;
}

.doctor-info {
  flex: 1;
}

.doctor-info h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.doctor-info .clinic {
  color: var(--primary-dark);
  font-weight: 500;
  font-size: 0.85rem;
}

.doctor-info .address {
  color: var(--text-light);
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.doctor-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.doctor-meta .rating { color: #f59e0b; }
.doctor-meta .dist { color: var(--text-light); }

.doctor-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.doctor-actions a, .doctor-actions button {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  border: none;
  transition: var(--transition);
  font-family: inherit;
}

.btn-call {
  background: #dcfce7;
  color: #166534;
}

.btn-directions {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-book {
  background: var(--primary);
  color: white;
}

/* ---- Voice Note Page ---- */
.voice-recorder {
  text-align: center;
  padding: 20px;
}

.record-btn-wrap {
  position: relative;
  display: inline-block;
  margin: 20px 0;
}

.record-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 2.2rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-btn:active {
  transform: scale(0.95);
}

.record-btn.recording {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  animation: pulse 1.5s infinite;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
}

.recording-status {
  font-size: 0.9rem;
  color: var(--text-light);
  margin: 10px 0;
}

.timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 10px 0;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
}

.audio-playback {
  width: 100%;
  margin: 15px 0;
  border-radius: var(--radius-xs);
}

.response-box {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0;
  text-align: left;
  box-shadow: var(--shadow);
  line-height: 1.6;
  font-size: 0.9rem;
}

body.rtl .response-box {
  text-align: right;
}

.btn-play-response {
  background: linear-gradient(135deg, var(--secondary), #059669);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  display: none;
}

.btn-play-response:hover {
  transform: translateY(-1px);
}

.btn-record-new {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 2px solid var(--primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  margin-top: 10px;
}

/* ---- Settings Page ---- */
.settings-section {
  background: white;
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow);
}

.settings-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.settings-section select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
}

.settings-info {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-lighter);
  text-align: center;
}

/* ---- Section Headers ---- */
.page h3 {
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: var(--text);
}

.page .subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ---- Copyright Footer ---- */
.copyright-footer {
  text-align: center;
  padding: 10px 20px;
  padding-bottom: calc(var(--nav-height) + 16px);
  font-size: 0.72rem;
  color: var(--text-lighter);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.copyright-footer p {
  margin: 2px 0;
}
.copyright-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.copyright-footer strong {
  color: var(--primary-dark);
  font-weight: 700;
}

/* ---- No Results ---- */
.no-results {
  text-align: center;
  color: var(--text-light);
  padding: 30px;
  font-size: 0.9rem;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ---- Responsive ---- */
@media (max-width: 380px) {
  .quick-grid { grid-template-columns: 1fr; }
  .doctor-actions { flex-direction: column; }
  .doctor-actions a, .doctor-actions button { text-align: center; }
}

@media (min-width: 500px) {
  .app-container {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ---- Utility ---- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }