/* =========================================
   MEDIPLUS — MOBILE-FIRST RESPONSIVE CSS
   ========================================= */

:root {
  --primary:       #0f766e;
  --primary-light: #14b8a6;
  --primary-dark:  #0d5c55;
  --secondary:     #0ea5e9;
  --bg-color:      #f8fafc;
  --card-bg:       #ffffff;
  --text-dark:     #1e293b;
  --text-muted:    #64748b;
  --danger:        #ef4444;
  --success:       #10b981;
  --border-color:  #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius:        12px;
  --transition:    all 0.25s ease;
  --navbar-h:      60px;
}

/* ===================== BASE ===================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-color);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ===================== NAVBAR ===================== */
.navbar {
  background: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}

.logo img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-btn {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 500;
  border: none;
  cursor: pointer;
  background: var(--primary-light);
  color: white;
  transition: var(--transition);
  font-size: 0.82rem;
  white-space: nowrap;
  min-height: 36px;
  font-family: inherit;
}

.nav-btn:hover  { background: var(--primary); }
.btn-gray       { background: #64748b !important; color: white !important; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: #f0fdfa; }

/* ===================== UTILITIES ===================== */
.hidden       { display: none !important; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); font-size: 0.9rem; }

.container {
  max-width: 1000px;
  margin: 1.25rem auto;
  padding: 0 1rem;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

@media (min-width: 640px) {
  .page-title { font-size: 1.6rem; }
}

/* ===================== BUTTONS ===================== */
.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 48px;
  font-family: inherit;
}

.btn-primary:hover  { box-shadow: var(--shadow-md); filter: brightness(1.05); }
.btn-primary:active { filter: brightness(0.97); }

.btn-danger-outline {
  width: 100%;
  padding: 0.85rem;
  background: white;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 48px;
  font-family: inherit;
}
.btn-danger-outline:hover { background: #fff5f5; }

.btn-sm {
  font-size: 0.82rem;
  padding: 0.4rem 0.85rem;
  min-height: 34px;
  width: auto;
}

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

@media (min-width: 480px) {
  .action-btns {
    flex-direction: row;
    align-items: stretch;
  }
  .action-btns .btn-primary,
  .action-btns .btn-danger-outline {
    width: auto;
    flex: 1;
  }
}

/* ===================== LOCK NOTICE ===================== */
.lock-notice {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ===================== FORMS ===================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px; /* prevent iOS zoom */
  font-family: inherit;
  transition: var(--transition);
  background: white;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-dark);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.15);
}

.form-control:disabled {
  background: #f1f5f9;
  color: var(--text-muted);
  cursor: not-allowed;
}

.link-text { color: var(--primary); font-size: 0.9rem; cursor: pointer; }
.link-text:hover { text-decoration: underline; }

/* ===================== AUTH CARD ===================== */
.auth-card {
  max-width: 460px;
  width: 100%;
  margin: 1.5rem auto;
  background: var(--card-bg);
  padding: 1.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 540px) {
  .auth-card {
    padding: 2.5rem 2rem;
    margin: 3rem auto;
  }
}

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-header h2 {
  font-size: 1.55rem;
  color: var(--text-dark);
}

.auth-header p {
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

/* ===================== DASHBOARD GRID ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr 2fr;
    gap: 1.75rem;
  }
}

/* ===================== CARD ===================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.1rem;
  border-top: 3px solid var(--primary);
}

@media (min-width: 640px) {
  .card { padding: 1.5rem; }
}

.card-title {
  margin-bottom: 1rem;
  color: var(--text-dark);
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .card-title { font-size: 1.2rem; }
}

.info-item {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}
.info-item:last-child { border: none; margin-bottom: 0; padding-bottom: 0; }
.info-label { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 0.2rem; }
.info-val   { font-weight: 600; color: var(--text-dark); font-size: 0.95rem; }

/* ===================== SLOT BUTTONS ===================== */
.slots-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-top: 0.75rem;
}

@media (min-width: 480px) {
  .slots-container {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

.slot-btn {
  background: white;
  border: 2px solid var(--border-color);
  padding: 0.8rem 0.5rem;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 68px;
  font-family: inherit;
}

.slot-btn:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.slot-btn:active:not(:disabled) { transform: translateY(0); }

.slot-btn.selected {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary);
}

.slot-btn.selected .slot-status { color: #ccfbf1; }

.slot-btn:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
  opacity: 0.55;
}

.slot-time   { font-weight: 700; font-size: 0.9rem; }
.slot-status { font-size: 0.72rem; color: var(--text-muted); }

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: flex-end;   /* bottom sheet on mobile */
  z-index: 200;
  transition: opacity 0.3s;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s ease-out;
}

@media (min-width: 600px) {
  .modal-content {
    border-radius: var(--radius);
    animation: scaleIn 0.22s ease-out;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes scaleIn {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.modal-body { padding: 1.25rem; }

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  flex-shrink: 0;
}
.close-btn:hover { background: #fee2e2; color: var(--danger); }

/* ===================== ANIMATIONS ===================== */
.content-fade-in {
  animation: fadeIn 0.35s ease-out forwards;
}

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

/* ===================== SUCCESS BOX ===================== */
.success-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.success-box strong { color: var(--success); }

/* ===================== ADMIN ===================== */
.admin-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.admin-tab-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-tab-group .nav-btn {
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
}

.active-tab {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
}

/* ADMIN GRID */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .admin-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
}

/* Override grid-column span on mobile */
@media (max-width: 899px) {
  .admin-grid > [style*="grid-column"] {
    grid-column: 1 !important;
  }
}

/* ===================== TABLES ===================== */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.report-table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.report-table th,
.report-table td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.report-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-dark);
  position: sticky;
  top: 0;
}

.report-table tr:last-child td { border-bottom: none; }
.report-table tr:hover td { background: #f8fafc; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0284c7;
  white-space: nowrap;
}

.badge.green { background: #dcfce7; color: #166534; }
.badge.red   { background: #fee2e2; color: #991b1b; }

/* ===================== SAFE AREA (iPhone) ===================== */
@supports (padding: env(safe-area-inset-bottom)) {
  body           { padding-bottom: env(safe-area-inset-bottom); }
  .modal-content { padding-bottom: env(safe-area-inset-bottom); }
}
