/* =============================================
   نظام إدارة العيادة - التصميم الاحترافي
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:       #1e40af;
  --primary-light: #3b82f6;
  --primary-dark:  #1e3a8a;
  --accent:        #06b6d4;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --secondary:     #64748b;

  --bg:            #f0f4f8;
  --surface:       #ffffff;
  --surface2:      #f8fafc;
  --border:        #e2e8f0;
  --border-dark:   #cbd5e1;

  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.1);
}

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

html { font-size: 16px; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand .clinic-name {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-brand .doctor-name {
  color: rgba(255,255,255,.7);
  font-size: .8rem;
  margin-top: 4px;
}

.sidebar-brand .brand-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  font-size: 1.3rem; color: #fff;
}

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-label {
  color: rgba(255,255,255,.4);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: all .2s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  font-size: .9rem;
  flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: rgba(255,255,255,.2);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.top-header {
  background: var(--surface);
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.page-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .78rem; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 12px; }

.header-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .95rem;
  transition: all .2s;
  text-decoration: none;
}

.header-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.date-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  display: flex; align-items: center; gap: 10px;
}

.card-title .card-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
}

.card-body { padding: 22px; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-info { flex: 1; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-change { font-size: .75rem; margin-top: 6px; font-weight: 600; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table thead th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: right;
  font-weight: 700;
  font-size: .78rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface2); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-secondary{ background: #f1f5f9; color: #475569; }
.badge-primary  { background: #dbeafe; color: #1e40af; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 8px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  direction: rtl;
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .75rem; color: var(--danger); margin-top: 4px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== SEARCH BAR ===== */
.search-bar {
  position: relative;
  max-width: 380px;
}

.search-bar input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-family: 'Cairo', sans-serif;
  font-size: .875rem;
  background: var(--surface);
  transition: all .2s;
  outline: none;
  direction: rtl;
}

.search-bar input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.search-bar .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: .9rem;
  pointer-events: none;
}

/* ===== PATIENT AVATAR ===== */
.avatar {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}

.avatar-blue   { background: #dbeafe; color: #1e40af; }
.avatar-green  { background: #d1fae5; color: #065f46; }
.avatar-purple { background: #ede9fe; color: #5b21b6; }
.avatar-pink   { background: #fce7f3; color: #9d174d; }
.avatar-orange { background: #ffedd5; color: #9a3412; }

/* ===== FLASH MESSAGES ===== */
.flash {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: .875rem;
  font-weight: 500;
}

.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px) scale(.97);
  transition: transform .25s ease;
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: var(--surface2);
  cursor: pointer; font-size: 1rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

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

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: .35;
}

.empty-state h3 { font-size: 1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: .85rem; }

/* ===== APPOINTMENT TIME SLOT ===== */
.time-slot {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
  transition: all .2s;
  cursor: pointer;
}

.time-slot:hover { border-color: var(--primary-light); background: #f0f7ff; }
.time-slot.completed { opacity: .6; }

.time-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--text-muted);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary-light);
  background: #f0f7ff;
  color: var(--primary);
}

.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }

/* ===== FILE GRID ===== */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.file-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all .2s;
  cursor: pointer;
}

.file-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.file-preview {
  height: 120px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  overflow: hidden;
}

.file-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-info { padding: 10px 12px; }
.file-name { font-size: .78rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 10px 25px rgba(30,64,175,.35);
}

.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.login-logo p  { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== MINI CALENDAR / TODAY ===== */
.today-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.today-date {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== QUICK SEARCH DROPDOWN ===== */
.quick-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0; left: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
}

.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  color: var(--text);
}

.search-result-item:hover { background: var(--surface2); }
.search-result-item:not(:last-child) { border-bottom: 1px solid var(--border); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary); }

/* ===== UTILITIES ===== */
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: .78rem; }
.text-center  { text-align: center; }
.fw-bold      { font-weight: 700; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.mt-16        { margin-top: 16px; }
.p-0          { padding: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}
