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

:root {
  --primary: #C94F72;
  --primary-dark: #A03558;
  --primary-light: #FFF0F5;
  --primary-mid: #F5C6D5;
  --sidebar-bg: #1A0810;
  --sidebar-hover: #2D1520;
  --sidebar-active: #C94F72;
  --sidebar-text: #C9A0B0;
  --sidebar-text-active: #fff;
  --sidebar-width: 260px;
  --header-h: 64px;
  --bg: #FFF5F8;
  --surface: #FFFFFF;
  --border: #F0D0DA;
  --border-light: #FFF0F5;
  --text: #1A0810;
  --text-sec: #6B3B50;
  --text-muted: #B07090;
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(201,79,114,.08), 0 1px 2px rgba(201,79,114,.05);
  --shadow-md: 0 4px 12px rgba(201,79,114,.1);
  --shadow-lg: 0 10px 30px rgba(201,79,114,.12);
  --transition: all .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

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

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
  transition: transform .3s ease; overflow-y: auto; overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #3D1A28; border-radius: 2px; }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid #2D1520; }
.brand-logo { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: white; padding: 2px; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-size: 14px; font-weight: 700; color: #F8E8EE; line-height: 1.2; }
.brand-sub { font-size: 10px; color: var(--sidebar-text); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: var(--transition); margin-bottom: 2px; white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #E8D0DA; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 12px; border-top: 1px solid #2D1520; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); margin-bottom: 6px; }
.user-avatar { width: 34px; height: 34px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #F0D0DA; }
.user-role-badge { font-size: 10px; background: #2D1520; color: #F5A0BC; padding: 1px 7px; border-radius: 20px; display: inline-block; margin-top: 1px; }
.btn-logout { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; background: transparent; color: #80505F; font-size: 13px; border-radius: var(--radius-sm); transition: var(--transition); }
.btn-logout:hover { background: #FEF2F2; color: var(--danger); }
.btn-logout svg { width: 16px; height: 16px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 999; }
.sidebar-overlay.active { display: block; }

/* ── MAIN ── */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .3s ease; }

/* ── HEADER ── */
.page-header {
  height: var(--header-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(201,79,114,.06);
}
.menu-toggle { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; background: transparent; border-radius: var(--radius-xs); color: var(--text-sec); transition: var(--transition); }
.menu-toggle:hover { background: var(--bg); }
.menu-toggle svg { width: 20px; height: 20px; }
.page-title { font-size: 17px; font-weight: 700; flex: 1; color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── PAGE BODY ── */
.page-body { flex: 1; padding: 24px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; transition: var(--transition); white-space: nowrap; cursor: pointer; border: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-sec); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: var(--radius-xs); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; cursor: pointer; transition: var(--transition); border: 1px solid var(--border); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.pink { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-count { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-sec); margin-top: 2px; }

/* ── CARD ── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; background: #FDFCFE; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* ── TABLE ── */
.table-toolbar { padding: 12px 16px; background: #FDFCFE; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }
.search-input { width: 100%; padding: 8px 10px 8px 32px; border: 1.5px solid var(--border); border-radius: var(--radius-xs); font-size: 13px; outline: none; transition: var(--transition); background: white; color: var(--text); }
.search-input:focus { border-color: var(--primary); }
.date-input { padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-xs); font-size: 13px; outline: none; transition: var(--transition); background: white; color: var(--text); }
.date-input:focus { border-color: var(--primary); }
.date-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
thead th { padding: 10px 16px; text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-sec); background: #FDFCFE; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-light); color: var(--text); vertical-align: middle; font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-light); }
.table-empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.pagination { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.pagination-info { font-size: 13px; color: var(--text-sec); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-sec); background: white; cursor: pointer; transition: var(--transition); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── BADGE ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-pink { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.req { color: var(--danger); margin-left: 2px; }
.form-control { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; outline: none; transition: var(--transition); background: white; color: var(--text); }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(201,79,114,.1); }
.form-control.error { border-color: var(--danger); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.form-error.show { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1/-1; }
.input-wrap { position: relative; }
.input-wrap .input-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; }
.input-wrap .input-icon:hover { color: var(--primary); }
.input-wrap .form-control { padding-right: 40px; }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1.5px solid var(--primary); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); max-height: 200px; overflow-y: auto; z-index: 500; box-shadow: var(--shadow-md); display: none; }
.autocomplete-item { padding: 10px 12px; cursor: pointer; font-size: 13.5px; transition: var(--transition); }
.autocomplete-item:hover { background: var(--primary-light); }
.autocomplete-item strong { display: block; color: var(--text); font-weight: 600; }
.autocomplete-item span { font-size: 12px; color: var(--text-muted); }

/* ── IMAGE UPLOAD SLOTS ── */
.image-slots-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.image-slot { aspect-ratio: 1; border: 2px dashed var(--border); border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; background: var(--bg); min-height: 90px; }
.image-slot:hover { border-color: var(--primary); background: var(--primary-light); }
.image-slot.filled { border-style: solid; border-color: var(--primary); }
.slot-placeholder { display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; }
.slot-placeholder svg { width: 22px; height: 22px; color: var(--text-muted); }
.slot-placeholder span { font-size: 10px; color: var(--text-muted); font-weight: 500; }
.slot-preview-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot-remove { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(0,0,0,.6); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; font-weight: 700; z-index: 10; border: none; cursor: pointer; }
.slot-remove:hover { background: var(--danger); }
.slot-upload-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: var(--primary-mid); }
.slot-upload-progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .3s; }

/* ── MODAL ── */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(26,8,16,.6); z-index: 2000; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; backdrop-filter: blur(4px); }
.modal-backdrop.active { display: flex; }
.modal { background: white; border-radius: var(--radius); width: 100%; max-width: 600px; box-shadow: var(--shadow-lg); margin: auto; animation: modalIn .25s ease; }
.modal-lg { max-width: 800px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { width: 30px; height: 30px; background: var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-sec); font-size: 18px; transition: var(--transition); cursor: pointer; border: none; }
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── PATIENT PROFILE ── */
.profile-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 24px; display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.profile-avatar { width: 72px; height: 72px; background: linear-gradient(135deg, var(--primary), #E88FAE); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: white; flex-shrink: 0; }
.profile-name { font-size: 22px; font-weight: 700; color: var(--text); }
.profile-meta { display: flex; gap: 20px; margin-top: 8px; flex-wrap: wrap; }
.profile-meta-item { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-sec); }
.profile-meta-item svg { width: 15px; height: 15px; color: var(--primary); }
.treatment-group { margin-bottom: 28px; }
.treatment-group-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.treatment-badge { background: var(--primary-light); color: var(--primary); font-size: 13px; font-weight: 600; padding: 4px 14px; border-radius: 20px; border: 1px solid var(--primary-mid); }
.session-card { background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 14px; }
.session-header { padding: 11px 16px; background: #FDFCFE; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.session-title { font-size: 13.5px; font-weight: 600; color: var(--primary); }
.session-date { font-size: 12px; color: var(--text-muted); }
.session-images { padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.session-img-wrap { position: relative; aspect-ratio: 1; border-radius: var(--radius-xs); overflow: hidden; background: var(--bg); }
.session-img-wrap img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform .2s; }
.session-img-wrap img:hover { transform: scale(1.04); }
.session-img-delete { position: absolute; top: 4px; right: 4px; background: rgba(239,68,68,.9); color: white; border: none; border-radius: 4px; padding: 3px 7px; font-size: 11px; cursor: pointer; display: none; }
.session-img-wrap:hover .session-img-delete { display: block; }
.session-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── LIGHTBOX ── */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 9000; align-items: center; justify-content: center; }
.lightbox.active { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: 20px; right: 24px; color: white; font-size: 34px; cursor: pointer; z-index: 9001; line-height: 1; }

/* ── LOGIN PAGE ── */
.login-page { min-height: 100vh; background: linear-gradient(180deg, #FFFFFF 0%, #FFD6E8 100%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: rgba(255,255,255,.95); border-radius: 20px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(201,79,114,.18); backdrop-filter: blur(10px); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-logo-img { width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: white; padding: 3px; box-shadow: 0 2px 8px rgba(201,79,114,.15); }
.login-logo-img img { width: 100%; height: 100%; object-fit: contain; }
.login-brand-name { font-size: 19px; font-weight: 800; color: var(--primary); }
.login-brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.login-heading { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-desc { font-size: 13.5px; color: var(--text-sec); margin-bottom: 24px; }
.login-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 24px; border: 1px solid var(--border); }
.login-tab { flex: 1; padding: 8px; text-align: center; font-size: 13px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: var(--transition); color: var(--text-muted); }
.login-tab.active { background: white; color: var(--primary); box-shadow: 0 1px 4px rgba(201,79,114,.12); }
.login-panel { display: none; }
.login-panel.active { display: block; }
.btn-login { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.btn-login:hover { background: var(--primary-dark); }
.err-msg { font-size: 12.5px; color: var(--danger); margin-top: 8px; padding: 8px 12px; background: var(--danger-light); border-radius: 6px; display: none; }
.err-msg.show { display: block; }
.occupied-msg { font-size: 13px; color: #92400E; background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px; padding: 12px 14px; margin-bottom: 20px; line-height: 1.6; }
.admin-badge { display: inline-block; background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-mid); border-radius: 6px; padding: 10px 14px; font-size: 12px; margin-top: 16px; line-height: 1.7; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: white; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; min-width: 260px; max-width: 360px; transform: translateX(120%); transition: transform .3s ease; border-left: 4px solid var(--primary); pointer-events: all; }
.toast.show { transform: translateX(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: #0EA5E9; }

/* ── NEW ENTRY PAGE ── */
.entry-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 28px; box-shadow: var(--shadow); }
.entry-card-header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.entry-card-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.entry-card-sub { font-size: 13px; color: var(--text-sec); margin-top: 3px; }
.existing-patient-note { padding: 10px 14px; background: var(--success-light); border: 1px solid #6EE7B7; border-radius: 8px; font-size: 13px; color: #065F46; margin-bottom: 12px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .image-slots-grid { grid-template-columns: repeat(3, 1fr); }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-meta { justify-content: center; }
  .page-header { padding: 0 14px; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .modal-backdrop { padding: 12px; }
  .login-card { padding: 28px 20px; }
  .session-images { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .image-slots-grid { grid-template-columns: repeat(2, 1fr); }
  .header-actions .btn span { display: none; }
}
