.cta-group.grid-4 { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
@media (max-width: 1200px) { .cta-group.grid-4 { grid-template-columns: repeat(3, minmax(220px, 1fr)); } }
@media (max-width: 900px) { .cta-group.grid-4 { grid-template-columns: repeat(2, minmax(220px, 1fr)); } }
.section-title { font-weight: 800; color:#0f2b3a; margin-bottom: 8px; text-align: right; }
:root {
	--color-primary: #0b6b4a;
	--color-primary-contrast: #ffffff;
	--color-secondary: #26a69a;
	--color-bg: #f7fbfc;
	--color-text: #0f2b3a;
	--color-muted: #5b7180;
	--radius: 14px;
	--shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.06);
	--shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html { font-size: 16px; }
body {
	margin: 0;
	font-family: 'Cairo', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	background-color: var(--color-bg);
	color: var(--color-text);
	line-height: 1.8;
}

.dashboard-container {
	max-width: 1200px;
	margin: 50px auto;
	padding: 20px;
}

.container {
	width: min(1100px, 92%);
	margin-inline: auto;
}

.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: rgba(255, 255, 255, 0.88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid rgba(15, 43, 58, 0.06);
	border-radius: 10px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	
	
}

.header-content {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 0;
}

.brand .site-title {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 700;
}

.brand .site-subtitle {
	margin: 2px 0 0 0;
	color: var(--color-muted);
	font-weight: 600;
	font-size: 0.95rem;
}

.hero {
	padding: 64px 0 72px;
	text-align: center;
}

/* Stats page */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
/* helper to force 5 columns on large screens */
@media (min-width: 1280px){ .grid-5 { grid-template-columns: repeat(5, 1fr) !important; } }
.stat-card { background: #fff; border:1px solid rgba(15,43,58,0.08); border-radius: 14px; padding: 16px; text-align: center; box-shadow: var(--shadow-sm); min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.stat-title { margin: 0 0 8px; font-size: 0.95rem; color: var(--color-muted); font-weight: 800; }
.stat-value { margin: 0; font-size: 2rem; font-weight: 900; color: var(--color-text); }
.rev-lines{ display:grid; gap:4px; margin-top:6px; }
.rev-line{ display:block; width:100%; text-align:center; font-weight:800; }
.rev-ok{ color:#0b6b4a; }
.rev-cancel{ color:#b3261e; }
.rev-pending{ color:#b88700; }
.tabs { display:flex; gap: 6px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { border:1px solid rgba(15,43,58,0.12); background: #fff; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 800; color: var(--color-text); }
.tab-btn.active { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }
.tab-panel { display: none; text-align: right; }
.tab-panel.active { display: block; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; margin-top: 8px; }
.filters input { padding: 10px 12px; border: 1px solid rgba(15,43,58,0.15); border-radius: 10px; font-family: inherit; height: 42px; width: 100%; }
.filters .btn { height: 42px; }
.filters label { display: grid; gap: 6px; text-align: right; }
.filters select { padding: 10px 12px; border: 1px solid rgba(15,43,58,0.15); border-radius: 10px; height: 42px; font-weight: 700; background: #fff; width: 100%; }
.filters #startLabel, .filters #endLabel { display: none; }

/* Ensure datepicker is anchored visually near inputs (browsers may render differently). We avoid forcing absolute position; rely on focus */
.tab-panel .table-wrap { text-align: initial; }

/* Filters container framing to separate it from the stats above */
.filters-frame { 
	background: #fff; 
	border: 1px solid rgba(15,43,58,0.08); 
	border-radius: 14px; 
	box-shadow: var(--shadow-sm); 
	padding: 12px; 
	margin-top: 12px;
}

/* Appointments page responsive */
@media (max-width: 780px) {
	.filters { grid-template-columns: 1fr; }
	.filters label { width: 100%; }
	.filters select, .filters input { width: 100%; }
	.filters .timeline-summary { justify-content: flex-start; }
}
@media (max-width: 480px) {
	.timeline-summary { justify-content: center; }
}

/* Generic framed block (for overview sections like patients per clinic) */
.section-frame {
	background: #fff;
	border: 1px solid rgba(15,43,58,0.08);
	border-radius: 14px;
	box-shadow: var(--shadow-sm);
	padding: 12px;
}

@media (max-width: 980px) { .filters { grid-template-columns: 1fr 1fr; } .filters select, .filters input { width: 100%; } }
@media (max-width: 600px) { .filters { grid-template-columns: 1fr; } }

.cta-group { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 18px; align-items: stretch; }
.cta-group.centered { justify-items: center; }

.btn {
	display: inline-block;
	padding: 12px 20px;
	border-radius: var(--radius);
	text-decoration: none;
	font-weight: 700;
	transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
	box-shadow: var(--shadow-sm);
	will-change: transform;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn-primary:focus-visible { outline: 3px solid color-mix(in lab, var(--color-primary), white 60%); outline-offset: 2px; }

.btn-secondary { background: color-mix(in lab, var(--color-secondary), white 75%); color: var(--color-text); }
.btn-secondary:hover { background: color-mix(in lab, var(--color-secondary), white 68%); }

/* Link-like button (text only clickable) */
.link-btn{ background: transparent; border: 0; color: var(--color-primary); padding: 0; margin: 0; cursor: pointer; text-decoration: none; font-weight: 800; font-size: 13px; }
.link-btn:hover{ text-decoration: underline; }

.site-footer {
	padding: 26px 0 40px;
	text-align: center;
	color: var(--color-muted);
	border-top: 1px solid rgba(15, 43, 58, 0.06);
}

/* RTL helpers */
:where(h1,h2,h3,h4,h5,h6,p,a,small) { direction: rtl; }

/* Responsive tweaks */
@media (max-width: 960px) {
	.dashboard-container { margin: 24px auto; padding: 16px; }
	.header-content { flex-wrap: wrap; justify-content: center; text-align: center; }
	.header-content > a { justify-content: center; width: 100%; }
	.header-actions { width: 100%; justify-content: center; margin-inline-start: 0; }
	.brand { text-align: center; width: 100%; }
	.page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
@media (max-width: 600px) {
	.header-content { padding: 10px 0; }
	.hero { padding: 40px 0 44px; }
	.btn { width: 100%; text-align: center; }
	.logo { width: 80px; height: 80px; }
	.brand .site-title { font-size: 1.2rem; }
	.page-header { align-items: stretch; }
	.page-header .btn { width: 100%; }
}

/* Icon buttons vertical layout */
.btn-icon-vertical { display: inline-flex; align-items: center; justify-content: center; gap: 10px; flex-direction: column; width: 220px; height: 180px; }
@media (min-width: 480px) {
	.btn-icon-vertical { flex-direction: column; padding: 16px 20px; }
}
.btn-label { font-size: 1.25rem; font-weight: 800; }
.btn-icon { width: 56px; height: 56px; }
.btn-icon svg { width: 44px; height: 44px; }

/* Home page grid - responsive buttons */
.cta-group .btn { height: auto; }
.cta-group .btn-icon-vertical { width: 100%; height: 160px; }
@media (max-width: 1024px) { .cta-group { grid-template-columns: repeat(2, minmax(200px,1fr)); } }
@media (max-width: 640px) { .cta-group { grid-template-columns: 1fr; } .cta-group .btn-icon-vertical { height: 140px; } }
/* 3-col helper */
.grid-3 { grid-template-columns: repeat(3, minmax(220px, 1fr)) !important; }

/* per-tile colors */
.tile--book { background:#0f3f31; color:#fff; }
.tile--patients { background:#0f3f31; color:#fff; }
.tile--clinics { background:#dcf2ee; }
.tile--appointments { background:#dcf2ee; }
.tile--stats { background:#e9f2ff; }
.tile--employees { background:#eaf7f0; }
.tile--book .btn-label, .tile--patients .btn-label { color:#fff; }
.tile--book svg, .tile--patients svg { stroke:#fff; }

/* Home sections */
.home-section { margin: 8px 0 18px; }
.home-section-title { text-align:right; margin: 0 0 10px; font-weight:900; font-size:1.4rem; color:#0f2b3a; }

/* Clinics page */
.page-title { margin: 0 0 20px; font-weight: 800; font-size: 1.6rem; }
.clinics { display: grid; gap: 24px; }
.clinic-card { background: #fff; border: 1px solid rgba(15,43,58,0.06); border-radius: 12px; padding: 16px; box-shadow: var(--shadow-sm); }
.clinic-name { margin: 0 0 8px; font-size: 1.2rem; }
.clinic-address { margin: 0 0 8px; color: var(--color-muted); }
.clinic-phone a { color: var(--color-primary); text-decoration: none; font-weight: 700; }
.clinic-phone a:hover { text-decoration: underline; }
.clinic-map { margin-top: 12px; overflow: hidden; border-radius: 10px; }
.clinic-map iframe { width: 100%; height: 260px; border: 0; }
@media (min-width: 800px) {
	.clinics { grid-template-columns: 1fr 1fr; }
}

/* Header actions */
.header-actions { margin-inline-start: auto; display:flex; align-items:center; gap:10px; }
.btn-sm { padding: 8px 12px; font-size: 0.95rem; }
.btn-ghost { background: transparent; color: var(--color-primary); border: 1px solid color-mix(in lab, var(--color-primary), white 60%); }
.btn-ghost:hover { background: color-mix(in lab, var(--color-primary), white 85%); }
.btn-icon--sm { width: 20px; height: 20px; }
.btn-icon--sm svg { width: 18px; height: 18px; }

/* Tiny back button */
.btn-back { 
    background: var(--color-primary); 
    border: none; 
    color: var(--color-primary-contrast); 
    display: inline-flex; 
    align-items: center; 
    gap: 10px; 
    padding: 8px 14px; 
    min-height: 38px;
    cursor: pointer; 
    text-decoration: none; 
    border-radius: 999px; 
    font-weight: 800; 
    font-size: 14px;
    line-height: 1; 
    flex-direction: row;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.btn-back:hover { background: color-mix(in lab, var(--color-primary), white 10%); color: var(--color-primary-contrast); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.btn-back .chevron { display: inline-block; width: 18px; height: 18px; background-color: currentColor; }
.btn-back .chevron svg { display: none; }
.btn-back .chevron{ 
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"><path d="M19 12H6" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 5l-7 7 7 7" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat center / contain; 
            mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"><path d="M19 12H6" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 5l-7 7 7 7" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat center / contain; 
}

/* Header user avatar + dropdown */
.user-menu { position: relative; }
.user-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg,#0b6b4a,#0e8a64); display:grid; place-items:center; color:#fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); cursor: pointer; border:2px solid rgba(255,255,255,.9); }
.user-avatar svg { width: 24px; height: 24px; }
.user-menu-dropdown { position:absolute; top:48px; inset-inline-end:0; min-width:180px; background:#fff; border:1px solid rgba(15,43,58,.1); border-radius:12px; box-shadow: var(--shadow-md); padding:8px; display:none; z-index:1000; }
.user-menu-dropdown svg { width:18px; height:18px; }
.user-menu-dropdown .logout-ic { transform: scaleX(-1); }
.user-menu-dropdown a { display:flex; align-items:center; justify-content:center; gap:8px; padding:8px 10px; border-radius:8px; color:var(--color-text); text-decoration:none; font-weight:700; width:100%; text-align:center; }
.user-menu-dropdown a:hover { background: rgba(15,43,58,.04); }
.user-menu.open .user-menu-dropdown { display:block; }

.icon { display: inline-flex; vertical-align: -2px; margin-inline-start: 6px; color: var(--color-muted); }
.icon--lg { width: 24px; height: 24px; display: inline-grid; place-items: center; margin-inline-start: 8px; color: var(--color-primary); }
.icon svg { width: 18px; height: 18px; }
.icon--lg svg { width: 22px; height: 22px; }

.page-header { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 14px; }

/* Modal */
.modal[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.40); }
.modal-card { position: relative; background: #fff; width: min(600px, 92%); margin: 0 auto; border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid rgba(15,43,58,0.08); }
.modal-title { margin: 0; font-size: 1.1rem; font-weight: 800; }
.modal-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--color-muted); }
.modal-close:hover { color: var(--color-text); }
.form-grid { display: grid; gap: 12px; padding: 14px 16px; }
.form-grid label { display: grid; gap: 6px; font-weight: 700; }
.form-grid input, .form-grid select, .form-grid textarea { 
	padding: 10px 12px; 
	border: 1px solid rgba(15,43,58,0.15); 
	border-radius: 10px; 
	font-family: inherit; 
	height: 48px;
	display: flex;
	align-items: center;
}

.form-grid textarea {
	height: auto;
	min-height: 120px;
	resize: vertical;
	line-height: 1.5;
}
.modal-actions { 
	display: flex; 
	gap: 10px; 
	justify-content: flex-end; 
	margin-top: 6px; 
	padding-top: 20px;
	border-top: 2px solid rgba(15,43,58,0.1);
}

/* Patient search results */
.patient-card { background:#fff; border:1px solid rgba(15,43,58,0.06); border-radius:12px; padding:14px; box-shadow: var(--shadow-sm); }
.patient-header { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.badge-code { background: color-mix(in lab, var(--color-primary), white 75%); color: var(--color-primary); padding: 4px 8px; border-radius: 999px; font-weight: 800; font-size: .9rem; }
.patient-name { font-weight: 800; font-size: 1.1rem; }
.patient-meta { display:flex; flex-wrap: wrap; gap:12px; color: var(--color-muted); }
.patient-meta .meta-item { display:inline-flex; align-items:center; gap:6px; }

/* Search bar */
.search-bar { display: flex; gap: 10px; }
.search-bar input { flex: 1; padding: 12px 14px; border: 1px solid rgba(15,43,58,0.15); border-radius: 12px; font-family: inherit; }

/* Results area spacing and layout */
.patients-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; justify-items: center; margin-top: 24px; }

/* Patient card with code rail (compact) */
.patient-card { display: grid; grid-template-columns: 90px 1fr; align-items: stretch; background:#fff; border:1px solid rgba(15,43,58,0.06); border-radius:14px; overflow: hidden; box-shadow: var(--shadow-sm); width: 360px; }
.patient-code-rail { background: color-mix(in lab, var(--color-primary), black 6%); color: var(--color-primary-contrast); display:grid; place-items:center; font-weight: 900; letter-spacing: .5px; }
.patient-code-rail .code { background: rgba(255,255,255,.18); padding: 6px 10px; border-radius: 10px; }
.patient-content { padding: 14px; display: block; }
.patient-fields p { margin: 0 0 6px 0; }
.field-label { color: var(--color-muted); font-weight: 800; margin-inline-start: 6px; }

/* Keep previous styles used elsewhere */
/* legacy patient-row styles were for cards view; ensure table rows keep layout */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(15,43,58,0.04); }

.badges { display:flex; gap:6px; margin-inline-start: auto; }
.patient-card .patient-header { display:flex; align-items:center; gap:10px; justify-content: flex-start; }
.patient-card .patient-meta { margin-top: 6px; }

.table-wrap { margin-top: 18px; overflow-x: auto; }
.patients-table { width: 100%; border-collapse: collapse; background:#fff; border:1px solid rgba(15,43,58,0.08); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.patients-table th, .patients-table td { padding: 12px 10px; text-align: center; vertical-align: middle; border-bottom: 1px solid rgba(15,43,58,0.06); }
.patients-table thead th { background: color-mix(in lab, var(--color-bg), white 30%); font-weight: 800; color: var(--color-text); }
.patients-table tr:last-child td { border-bottom: 0; }
.patients-table a { color: var(--color-primary); text-decoration: none; }
@media (max-width: 600px) {
  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }
  .patients-table th, .patients-table td { padding: 10px 6px; font-size: 13px; }
}

/* Make visit date cell left-to-right while preserving alignment */
.ltr-date { direction: ltr; text-align: center; }

/* Duplicate phone warning */
.duplicate-warning {
	background: #fff3cd;
	color: #856404;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	margin-top: 4px;
	border: 1px solid #ffeaa7;
	text-align: center;
	display: inline-block;
}

/* Professional error message */
.error-message {
	background: linear-gradient(135deg, #fee, #fdd);
	border: 1px solid #f5c6cb;
	border-radius: 8px;
	margin: 15px 20px;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: center; /* center the message */
	box-shadow: 0 2px 8px rgba(220, 53, 69, 0.15);
	animation: slideDown 0.3s ease-out;
	flex-wrap: nowrap;
	direction: rtl;
	gap: 8px;
	position: relative; /* anchor the close button */
	text-align: center;
}

.error-content {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 1 auto; /* don't stretch across bar */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

.error-icon {
	font-size: 18px;
	color: #dc3545;
}

.error-text {
	color: #721c24;
	font-weight: 500;
	font-size: 14px;
	line-height: 1.4;
}

.error-close {
	background: none;
	border: none;
	color: #dc3545;
	font-size: 20px;
	font-weight: bold;
	cursor: pointer;
	padding: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: all 0.2s ease;
	position: absolute; /* keep on the left on the same line */
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Professional success message */
.success-message {
	background: linear-gradient(135deg, #d4edda, #c3e6cb);
	border: 1px solid #c3e6cb;
	border-radius: 8px;
	margin: 15px 20px;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15);
	animation: slideDown 0.3s ease-out;
	flex-wrap: nowrap;
}

.success-content {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.success-icon {
	font-size: 18px;
	color: #28a745;
}

.success-text {
	color: #155724;
	font-weight: 500;
	font-size: 14px;
	line-height: 1.4;
}

.success-close {
	background: none;
	border: none;
	color: #28a745;
	font-size: 20px;
	font-weight: bold;
	cursor: pointer;
	padding: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: all 0.2s ease;
	flex-shrink: 0;
	margin-left: 10px;
}

.success-close:hover {
	background: rgba(40, 167, 69, 0.1);
	transform: scale(1.1);
}

/* Two-column form layout for patient modal */
.form-grid.twocol { display: grid; gap: 12px; }
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* three columns layout for visit row */
.form-row.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 680px) { .form-row.two { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .form-row.three { grid-template-columns: 1fr; } }
.form-row.two label { display: grid; gap: 6px; }
.form-row.two textarea { height: 48px; min-height: 48px; }

/* Keep inline date controls from affecting sibling column height */
.form-row.two label { align-content: start; }
.form-row.two label .date-input-group { display: none; }
.form-row.two label .date-input-group.active { display: flex; }

/* Patient profile - professional medical design */
.patient-info-card {
	background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
	border-radius: 16px;
	border: 1px solid rgba(15,43,58,0.12);
	box-shadow: 0 4px 20px rgba(15,43,58,0.08), 0 1px 3px rgba(15,43,58,0.1);
	padding: 24px;
	margin-bottom: 24px;
	position: relative;
	overflow: hidden;
}

.patient-info-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(90deg, var(--color-primary, #0f2b3a), color-mix(in lab, var(--color-primary, #0f2b3a), white 30%));
}

/* Appointment banner */
.appointment-banner {
    background: linear-gradient(135deg, #fff7e6, #fff1cc);
    border: 1px solid #ffe8a1;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
    text-align: center;
}
.appointment-banner.small { padding: 8px 10px; margin: 8px 0 0; }
.appointment-banner .appt-row { display:flex; gap:6px; justify-content:center; align-items:center; flex-wrap:wrap; }
.appointment-banner .appt-title { font-weight: 800; color: #8a6d3b; font-size: 13px; }
.appointment-banner .appt-when { background:#fff; border:1px solid rgba(0,0,0,0.06); border-radius:10px; padding:2px 8px; font-weight:700; font-size: 12px; }
.appointment-banner .countdown { display:flex; gap:4px; justify-content:center; direction: rtl; }
.appointment-banner .countdown .unit { background:#fff; border:1px solid rgba(0,0,0,0.06); border-radius: 10px; padding:2px 6px; min-width:48px; }
.appointment-banner .countdown .num { display:block; font-size:13px; font-weight:900; color:#8a6d3b; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.appointment-banner .countdown .lbl { font-size:10px; color:#8a6d3b; }
.appointment-banner .remaining-text { margin-top: 4px; font-weight: 700; color:#8a6d3b; font-size: 12px; }

.add-visit-section,
.medical-timeline {
	background: #fff;
	border-radius: 12px;
	border: 1px solid rgba(15,43,58,0.08);
	box-shadow: var(--shadow-sm);
	padding: 18px;
	margin-bottom: 18px;
}

.patient-header { display:flex; align-items:center; gap: 20px; }
.patient-header.centered { justify-content: center; gap: 28px; }
.patient-avatar {
	width: 80px; height: 80px; border-radius: 50%;
	background: linear-gradient(135deg, var(--color-primary, #0f2b3a), color-mix(in lab, var(--color-primary, #0f2b3a), white 20%));
	color:#fff;
	display:flex; align-items:center; justify-content:center;
	font-weight: 900; font-size: 16px;
	box-shadow: 0 4px 12px rgba(15,43,58,0.2);
	border: 3px solid rgba(255,255,255,0.9);
}
.patient-details h2 { 
	margin: 0 0 8px 0; 
	font-size: 26px; 
	color: var(--color-text, #233); 
	font-weight: 700;
	letter-spacing: -0.5px;
}
.patient-code { 
	color: var(--color-primary, #0f2b3a); 
	font-weight: 700; 
	margin: 0 0 12px 0; 
	font-size: 14px;
	background: rgba(15,43,58,0.08);
	padding: 4px 12px;
	border-radius: 20px;
	display: inline-block;
}
.patient-meta { 
	display:flex; 
	gap: 8px; 
	flex-wrap: wrap; 
	color: #59636b; 
	justify-content: center;
}
.patient-meta span { 
	background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
	padding: 6px 12px; 
	border-radius: 20px; 
	font-size: 13px; 
	font-weight: 700;
	border: 1px solid rgba(15,43,58,0.08);
	box-shadow: 0 1px 3px rgba(15,43,58,0.05);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
}

/* Visit form - professional medical styling */
.visit-form { display:grid; gap: 20px; }
.visit-fields { 
	display:grid; 
	gap: 16px; 
	padding-bottom: 20px;
	border-bottom: 2px solid rgba(15,43,58,0.1);
	margin-bottom: 20px;
}
.attachments-section { 
	display:grid; 
	gap: 16px; 
	padding-bottom: 20px;
	border-bottom: 2px solid rgba(15,43,58,0.1);
	margin-bottom: 20px;
}

.add-visit-section h3,
.medical-timeline h3 {
	font-size: 16px;
	font-weight: 700;
	color: var(--color-text, #233);
	margin: 0 0 6px 0;
}

.attachment-categories { 
	display:flex; 
	gap:12px; 
	flex-wrap: wrap; 
	margin-bottom: 8px;
	justify-content: center;
}
.chip { 
	background: linear-gradient(135deg, #f8fafc, #e2e8f0);
	border-radius: 25px; 
	padding: 8px 16px; 
	cursor:pointer; 
	user-select:none; 
	border: 2px solid rgba(15,43,58,0.15); 
	font-weight: 600;
	font-size: 14px;
	transition: all 0.2s ease;
	box-shadow: 0 2px 4px rgba(15,43,58,0.05);
}
.chip:hover { 
	background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(15,43,58,0.1);
}
.chip.active { 
	background: linear-gradient(135deg, var(--color-primary, #0f2b3a), color-mix(in lab, var(--color-primary, #0f2b3a), white 20%)); 
	color: #fff; 
	border-color: var(--color-primary, #0f2b3a);
	box-shadow: 0 4px 12px rgba(15,43,58,0.2);
}
.attachment-category input { margin-inline-end: 6px; }

.attachments-list { 
	display:grid; 
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
	gap: 16px; 
}
.file-upload-area { 
	border: 2px dashed rgba(15,43,58,0.2); 
	border-radius: 12px; 
	padding: 24px; 
	text-align: center; 
	cursor: pointer; 
	transition: all 0.3s ease;
	background: linear-gradient(135deg, #fafbfc, #f1f5f9);
	position: relative;
	overflow: hidden;
}
.file-upload-area::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(135deg, rgba(15,43,58,0.02), rgba(15,43,58,0.05));
	opacity: 0;
	transition: opacity 0.3s ease;
}
.file-upload-area:hover { 
	background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
	border-color: var(--color-primary, #0f2b3a);
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(15,43,58,0.1);
}
.file-upload-area:hover::before {
	opacity: 1;
}
.upload-placeholder span { 
	font-weight: 700; 
	color: var(--color-text, #233); 
	font-size: 16px;
	display: block;
	margin-bottom: 8px;
}
.upload-placeholder p { 
	margin: 0; 
	color: #6b7580; 
	font-size: 14px;
	line-height: 1.5;
}

/* Selected files display */
.selected-files {
	text-align: center;
	background: #f8f9fa;
	border: 2px solid rgba(15,43,58,0.15);
	border-radius: 12px;
	padding: 12px;
	margin-top: 8px;
    overflow: visible;
}

.selected-files-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid rgba(15,43,58,0.1);
}

.category-badge { background: rgba(15,43,58,0.08); color: var(--color-text, #233); padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }

.selected-files-header span {
	font-weight: 700;
	color: var(--color-primary, #0f2b3a);
	font-size: 14px;
}

/* .clear-files removed per request */

.files-list {
	display: grid;
	gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    padding: 6px 2px;
}
@media (max-width: 768px) {
    .files-list { max-height: 220px; }
}

.file-item {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	padding: 8px 12px 8px 48px; /* extra left padding to separate size from X button */
	border-radius: 8px;
	border: 1px solid #e9ecef;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
	position: relative;
}

.file-name {
	font-weight: 600;
	color: #333;
	font-size: 13px;
	text-align: center;
	flex: 1;
}

.file-size {
	color: #6c757d;
	font-size: 12px;
	margin: 0 14px 0 8px;
}

.remove-file {
	background: #dc3545;
	color: white;
	border: none;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	font-size: 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	position: absolute;
	left: 8px;
	top: 50%;
	transform: translateY(-50%);
    z-index: 2;
}

.remove-file:hover {
	background: #c82333;
}

/* Prevent file upload area click when clicking remove button */
.file-item {
	pointer-events: auto;
}

.file-item .remove-file {
	pointer-events: auto;
	z-index: 10;
}

/* Drag over effect */
.file-upload-area.drag-over {
	background: linear-gradient(135deg, #e3f2fd, #bbdefb);
	border-color: var(--color-primary, #0f2b3a);
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(15,43,58,0.15);
}

/* Timeline - professional medical design */
.timeline-container { display:block; }
.medical-timeline { max-height: none; }
.medical-timeline .timeline-container { max-height: 7.2 * 56px; }
.timeline-scroll { max-height: 625px; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--color-primary) rgba(15,43,58,0.06); }
.timeline-scroll::-webkit-scrollbar { width: 8px; }
.timeline-scroll::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 8px; }
.timeline-scroll::-webkit-scrollbar-thumb:hover { background: color-mix(in lab, var(--color-primary), black 12%); }
.timeline-scroll::-webkit-scrollbar-track { background: rgba(15,43,58,0.06); border-radius: 8px; }
.timeline-empty, .timeline-error { 
	text-align:center; 
	color:#6b7580; 
	padding: 32px 0; 
	font-size: 16px;
	font-weight: 500;
}
.timeline-item { 
	display:flex; 
	gap:16px; 
	margin-bottom: 20px; 
	position: relative;
	padding-left: 20px;
}
.timeline-item::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: linear-gradient(180deg, var(--color-primary, #0f2b3a), color-mix(in lab, var(--color-primary, #0f2b3a), white 40%));
	border-radius: 2px;
}
.timeline-date { 
	background: linear-gradient(135deg, var(--color-primary, #0f2b3a), color-mix(in lab, var(--color-primary, #0f2b3a), white 8%)); 
	color:#fff; 
	padding:8px 16px; 
	border-radius: 20px; 
	font-size: 13px; 
	font-weight: 600;
	height: fit-content; 
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(15,43,58,0.18);
}
.timeline-content { 
	flex:1; 
	background: linear-gradient(135deg, #ffffff, #f8fafc); 
	border-radius:12px; 
	padding:16px; 
	border: 1px solid rgba(15,43,58,0.08);
	box-shadow: 0 2px 8px rgba(15,43,58,0.05);
}
.visit-type { 
	font-weight: 700; 
	color: var(--color-primary, #0f2b3a); 
	margin-bottom: 8px; 
	font-size: 16px;
	display: inline-block;
	background: rgba(15,43,58,0.08);
	padding: 4px 12px;
	border-radius: 15px;
}
.visit-diagnosis { 
	color:#384149; 
	line-height: 1.6; 
	margin-bottom: 12px; 
	font-size: 15px;
}
.rtl-text { direction: rtl; text-align: right; }
.ltr-text { direction: ltr; text-align: left; }
.visit-meta { display:flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 12px; color:#2b3a42; justify-content: center; }
.diagnosis-box { background: linear-gradient(135deg, #f8fafc, #eef3f7); border:1px solid rgba(15,43,58,0.1); border-radius: 12px; padding: 12px 14px; color:#2b3a42; box-shadow: 0 1px 3px rgba(15,43,58,0.08); text-align: right; }
.diagnosis-box .label { display:block; font-weight:800; color:#0f2b3a; margin-bottom:6px; }
.diagnosis-box.ltr-text, .visit-diagnosis.ltr-text { direction: ltr; text-align: left; }
.diagnosis-box.rtl-text, .visit-diagnosis.rtl-text { direction: rtl; text-align: right; }
.attachments-section-block .section-title { font-weight: 800; color:#0f2b3a; margin-bottom: 8px; text-align: right; }

/* Lightbox */
#imageLightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; align-items: center; justify-content: center; z-index: 200; }
#imageLightbox.show { display: flex; }
#imageLightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
#imageLightbox .close { position: absolute; top: 16px; left: 16px; color: #fff; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.25); border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; font-size: 20px; cursor: pointer; }
.visit-meta { display:flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 10px; color:#2b3a42; }
.visit-meta .meta-item { background: rgba(15,43,58,0.05); padding: 6px 10px; border-radius: 10px; font-size: 13px; }
.attachments-section-block { margin-top: 10px; }
.attachments-section-block .section-title { font-weight: 700; color:#0f2b3a; margin-bottom: 8px; }

/* Patient page two columns */
.patient-columns { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 992px) {
    .patient-columns { grid-template-columns: 1fr 265px; align-items: start; }
	.add-visit-section, .medical-timeline { height: 100%; }
}

/* Visit form actions – center button and remove divider */
#visitForm .modal-actions { justify-content: center; margin-top: 10px; padding-top: 0; border-top: 0; }
.attachments-list {
	display: grid;
	gap: 8px;
	margin-top: 8px;
}
.attachment-item { 
	display:flex; 
	align-items:center; 
	gap:12px; 
	padding:10px 12px; 
	background: linear-gradient(135deg, #f8fafc, #f1f5f9); 
	border: 1px solid rgba(15,43,58,0.1); 
	border-radius:8px;
	transition: all 0.2s ease;
}
.attachment-item:hover {
	background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
	transform: translateX(2px);
}
.attachment-category {
	font-size: 12px;
	font-weight: 600;
	color: var(--color-primary, #0f2b3a);
	background: rgba(15,43,58,0.1);
	padding: 2px 8px;
	border-radius: 12px;
}
.attachment-link { 
	color: var(--color-primary, #0f2b3a); 
	text-decoration:none; 
	font-weight: 500;
}
.attachment-link:hover { 
	text-decoration: underline; 
	color: color-mix(in lab, var(--color-primary, #0f2b3a), black 20%);
}

/* Country flag preview next to select */
.country-select-wrap { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.country-flag { width: 26px; height: 18px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(15,43,58,0.1); object-fit: cover; }

/* Toast message */
.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(-10px); top: 20px; min-width: 260px; max-width: 80vw; padding: 12px 16px; border-radius: 10px; color: #155724; background: #d4edda; border: 1px solid #c3e6cb; box-shadow: 0 8px 20px rgba(0,0,0,0.12); display: flex; align-items: center; gap: 10px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 9999; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast .toast-text { font-weight: 700; }
.toast .toast-close { margin-inline-start: auto; border: none; background: transparent; font-size: 18px; cursor: pointer; color: inherit; }

/* Timeline accordion enhancements */
.timeline-item { display:block; }
.timeline-summary { display:flex; gap:10px; justify-content:center; margin: 2px 0 8px; padding-bottom: 10px; border-bottom: 2px solid rgba(15,43,58,0.1); }
.timeline-container .timeline-item:first-child { margin-top: 8px; }
.summary-chip { background: rgba(15,43,58,0.06); color:#0f2b3a; border:1px solid rgba(15,43,58,0.1); border-radius: 999px; padding: 6px 10px; font-weight:800; font-size: 13px; }
.timeline-item .timeline-header { width:100%; display:flex; align-items:center; justify-content: space-between; gap:12px; background: transparent; border:0; cursor:pointer; padding:16px; }
.timeline-item .timeline-header:hover { background: rgba(15,43,58,0.03); }
.timeline-item .timeline-header .chev { transition: transform .2s ease; }
.timeline-item.open .timeline-header .chev { transform: rotate(180deg); }
.timeline-item .timeline-content { padding: 0 16px 16px; }
.visit-type-badge { background: rgba(15,43,58,0.08); color: var(--color-primary, #0f2b3a); font-weight: 700; border-radius: 999px; padding: 6px 10px; font-size: 13px; }
.timeline-date.ltr { direction: ltr; }

/* Make selects show placeholder by default (disabled) */
select:required:invalid { color: var(--color-muted); }
option[disabled][value=""] { display: none; }

/* Style for selects consistent with inputs */
.form-grid select { 
	padding: 10px 12px; 
	border: 1px solid rgba(15,43,58,0.15); 
	border-radius: 10px; 
	font-family: inherit; 
	background: white;
	width: 100%;
	font-weight: 500;
	color: #333;
	font-size: 15px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
	transition: all 0.2s ease;
	height: 48px;
	display: flex;
	align-items: center;
}

.form-grid select:hover,
.form-grid textarea:hover {
	border-color: rgba(15,43,58,0.3);
	box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.form-grid select:focus,
.form-grid textarea:focus {
	outline: none;
	border-color: var(--color-primary, #0f2b3a);
	box-shadow: 0 0 0 3px rgba(15,43,58,0.1);
}

/* Make select options more visible */
.form-grid select option {
	font-weight: 500;
	color: #333;
	padding: 10px 16px;
	font-size: 15px;
}

/* Style for selected value in selects */
.form-grid select:not([value=""]) {
	color: #000;
	font-weight: 600;
	background: #f8f9fa;
}

/* Placeholder text styling for all selects */
.form-grid select option[disabled] {
	color: #6c757d;
	font-weight: 400;
	font-style: italic;
}
.country-input-group {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
}
.country-flag { 
	width: 26px; 
	height: 18px; 
	border-radius: 3px; 
	box-shadow: 0 0 0 1px rgba(15,43,58,0.1); 
	object-fit: cover;
	flex-shrink: 0;
}

/* Country search input */
#countrySearch {
	padding: 10px 12px;
	border: 1px solid rgba(15,43,58,0.15);
	border-radius: 10px;
	font-family: inherit;
	background: white;
	width: 100%;
}

/* Country dropdown */
.country-dropdown {
	position: fixed;
	background: white;
	border: 1px solid rgba(15,43,58,0.15);
	border-radius: 10px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
	z-index: 9999;
	margin-top: 4px;
}

.country-list {
	max-height: 200px;
	overflow-y: auto;
	padding: 8px 0;
}

.country-item {
	padding: 8px 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	text-align: right;
	transition: background-color 0.2s;
}

.country-item:hover {
	background-color: rgba(15,43,58,0.05);
}

.country-item.selected {
	background-color: rgba(15,43,58,0.1);
}

.country-item-flag {
	width: 20px;
	height: 14px;
	border-radius: 2px;
	object-fit: cover;
	flex-shrink: 0;
}

.country-input-group {
	position: relative;
}

/* Date input group */
.date-input-group {
	display: none; /* hidden until custom mode */
	gap: 8px;
	align-items: center;
	justify-content: center;
    margin-top: 8px;
}
.date-input-group.active { display: flex; }

.date-input-group select {
	flex: 1;
	padding: 10px 12px;
	border: 1px solid rgba(15,43,58,0.15);
	border-radius: 10px;
	font-family: inherit;
	background: white;
	font-size: 15px;
	font-weight: 500;
	color: #333;
	text-align: right;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
	transition: all 0.2s ease;
	height: 48px;
	display: flex;
	align-items: center;
}

.date-input-group select:hover {
	border-color: rgba(15,43,58,0.3);
	box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.date-input-group select:focus {
	outline: none;
	border-color: var(--color-primary, #0f2b3a);
	box-shadow: 0 0 0 3px rgba(15,43,58,0.1);
}

.date-input-group select:first-child {
	flex: 1; /* Day - adequate size */
	min-width: 87px;
}

.date-input-group select:nth-child(2) {
	flex: 1.8; /* Month - larger for "الشهر" */
	min-width: 85px;
}

.date-input-group select:last-child {
	flex: 1.2; /* Year - slightly larger */
	min-width: 81px;
}

/* Make select text more visible */
.date-input-group select option {
	font-weight: 500;
	color: #333;
	padding: 8px 12px;
	font-size: 15px;
	text-align: right;
}

/* Style for selected value in date selects */
.date-input-group select:not([value=""]) {
	color: #000;
	font-weight: 600;
	background: #f8f9fa;
}

/* Placeholder text styling */
.date-input-group select option[disabled] {
	color: #6c757d;
	font-weight: 400;
	font-style: italic;
	font-size: 15px;
}

.form-row.two label .date-input-group { margin-top: 8px; }
.form-row.two label > select { width: 100%; }
