/* ============================================================
   CABINET DENTAIRE - Design system
   Palette clinique teal + accent ambre, sidebar de navigation,
   cartes, badges de statut. Tout en variables CSS pour rester
   coherent et facile a retoucher depuis un seul endroit.
   ============================================================ */

:root {
	/* Couleurs de marque */
	--teal-50:  #E1F5EE;
	--teal-100: #B9E8D8;
	--teal-400: #1D9E75;
	--teal-600: #0F6E56;
	--teal-700: #0A5F4E;
	--teal-900: #04342C;

	--amber-50:  #FCF3E3;
	--amber-400: #E2A73E;
	--amber-600: #B5790E;
	--amber-900: #4A3103;

	--red-50:  #FCEBEB;
	--red-400: #E24B4A;
	--red-600: #A32D2D;
	--red-900: #501313;

	--green-50:  #EAF3DE;
	--green-400: #639922;
	--green-600: #3B6D11;

	--blue-50:  #E6F1FB;
	--blue-400: #378ADD;
	--blue-600: #185FA5;

	--purple-50:  #EEEDFE;
	--purple-400: #7F77DD;
	--purple-600: #534AB7;

	/* Neutres */
	--ink-900: #16222B;
	--ink-700: #33434E;
	--ink-500: #64757F;
	--ink-300: #A8B4BB;

	--page-bg:    #F1F5F4;
	--surface:    #FFFFFF;
	--surface-2:  #F7FAF9;
	--border:     #DCE6E2;
	--border-strong: #C3D2CC;

	/* Semantique */
	--color-primary: var(--teal-600);
	--color-primary-hover: var(--teal-700);
	--color-accent: var(--amber-600);
	--color-danger: var(--red-600);
	--color-success: var(--green-600);
	--color-warning: var(--amber-600);

	/* Echelle */
	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 16px;
	--shadow-sm: 0 1px 2px rgba(22, 34, 43, 0.06);
	--shadow-md: 0 6px 20px rgba(22, 34, 43, 0.08);

	--font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
	--font-mono: 'Consolas', 'SF Mono', 'Courier New', monospace;

	--sidebar-width: 232px;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	background: var(--page-bg);
	color: var(--ink-900);
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--ink-900); font-weight: 600; letter-spacing: -0.01em; margin-top: 0; }
h2 { font-size: 20px; }
h2 small { font-size: 13px; font-weight: 400; color: var(--ink-500); font-family: var(--font-mono); }
h3 { font-size: 16px; margin-bottom: 10px; color: var(--ink-700); }

/* ============================================================
   STRUCTURE: sidebar + topbar
   ============================================================ */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
	width: var(--sidebar-width);
	flex-shrink: 0;
	background: var(--ink-900);
	color: #cfe3dd;
	padding: 20px 14px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.sidebar .brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 4px 10px 22px;
	color: #fff;
}
.sidebar .brand .mark {
	width: 34px; height: 34px;
	background: var(--teal-400);
	color: #04241d;
	border-radius: var(--radius-sm);
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 14px;
	flex-shrink: 0;
}
.sidebar .brand .titre { font-size: 15px; font-weight: 600; line-height: 1.2; }
.sidebar .brand .sous-titre { font-size: 11px; color: #8fa8a0; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.sidebar nav a {
	display: flex; align-items: center; gap: 10px;
	padding: 9px 12px;
	border-radius: var(--radius-sm);
	color: #cfe3dd;
	font-size: 13.5px;
	text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar nav a.actif { background: var(--teal-600); color: #fff; }
.sidebar nav a .icone { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }

.main-content { flex: 1; min-width: 0; }

.topbar {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: 14px 28px;
	display: flex; align-items: center; justify-content: space-between;
}
.topbar .titre-page { font-size: 15px; font-weight: 600; color: var(--ink-900); }

.conteneur-principal { padding: 24px 28px 48px; max-width: 1180px; }

/* ============================================================
   CARTES / SECTIONS
   ============================================================ */

fieldset {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 18px 22px;
	margin-bottom: 18px;
	box-shadow: var(--shadow-sm);
}
legend {
	font-weight: 600;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--teal-700);
	padding: 0 8px;
}

/* ============================================================
   MESSAGES FLASH
   ============================================================ */

.message, .flash-success, .flash-error {
	padding: 11px 16px;
	border-radius: var(--radius-sm);
	margin-bottom: 18px;
	font-size: 13.5px;
	border: 1px solid transparent;
}
.message.success, .flash-success { background: var(--green-50); color: var(--green-600); border-color: #cfe4b2; }
.message.error, .flash-error { background: var(--red-50); color: var(--red-600); border-color: #f3c9c9; }

/* ============================================================
   BOUTONS
   ============================================================ */

.btn, .btn-primary, .btn-danger, button, input[type="submit"] {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	background: var(--surface);
	color: var(--ink-700);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	font-family: var(--font-sans);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary, input[type="submit"] {
	background: var(--color-primary);
	color: #fff;
	border-color: var(--color-primary);
}
.btn-primary:hover, input[type="submit"]:hover { background: var(--color-primary-hover); }

.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #8a2626; }

.actions-bar { margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   FORMULAIRES
   ============================================================ */

fieldset {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px 24px;
	align-content: start;
}
fieldset > legend { grid-column: 1 / -1; }

.input {
	margin-bottom: 16px;
	position: relative;
}
.input:has(textarea),
.input.checkbox,
.input:has(select[multiple]) {
	grid-column: 1 / -1;
}

.input label {
	display: block;
	font-size: 11.5px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 7px;
	color: var(--ink-500);
}

.input input[type="text"], .input input[type="number"], .input input[type="date"],
.input input[type="time"], .input input[type="email"], .input select, .input textarea,
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="email"], select, textarea {
	width: 100%;
	max-width: 100%;
	padding: 10px 13px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	font-family: var(--font-sans);
	font-size: 13.5px;
	color: var(--ink-900);
	background: var(--surface-2);
	transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
	appearance: none;
	-webkit-appearance: none;
}

.input textarea, textarea { min-height: 78px; resize: vertical; line-height: 1.5; }

.input input::placeholder, input::placeholder, textarea::placeholder { color: var(--ink-300); }

.input select, select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364757F' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 34px;
	cursor: pointer;
}

.input input:hover, .input select:hover, .input textarea:hover,
input:hover, select:hover, textarea:hover {
	border-color: var(--border-strong);
	background: var(--surface);
}

.input input:focus, .input select:focus, .input textarea:focus, input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--teal-400);
	background: var(--surface);
	box-shadow: 0 0 0 4px var(--teal-50);
}

.input.checkbox {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	background: var(--surface-2);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	margin-bottom: 10px;
}
.input.checkbox label {
	margin: 0;
	font-weight: 500;
	font-size: 13px;
	text-transform: none;
	letter-spacing: normal;
	color: var(--ink-700);
}
.input.checkbox input[type="checkbox"] {
	width: 17px; height: 17px;
	accent-color: var(--teal-600);
	cursor: pointer;
	flex-shrink: 0;
}

.input .error-message {
	color: var(--color-danger);
	font-size: 12px;
	margin-top: 5px;
	display: block;
}
.input.error input, .input.error select, .input.error textarea {
	border-color: var(--red-400);
	background: var(--red-50);
}

form > div.submit,
form p.submit {
	grid-column: 1 / -1;
	margin-top: 6px;
}

@media (max-width: 700px) {
	fieldset { grid-template-columns: 1fr; }
}

/* ============================================================
   TABLES
   ============================================================ */

table.table {
	width: 100%;
	border-collapse: collapse;
	margin: 14px 0;
	background: var(--surface);
	border-radius: var(--radius-md);
	overflow: hidden;
	box-shadow: var(--shadow-sm);
}
table.table th, table.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
table.table th {
	background: var(--surface-2);
	color: var(--ink-500);
	font-weight: 600;
	font-size: 11.5px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: var(--surface-2); }

table.table-details th { text-align: left; padding: 7px 16px 7px 0; color: var(--ink-500); width: 180px; font-weight: 500; }
table.table-details td { padding: 7px 0; }

/* ============================================================
   BADGES DE STATUT
   ============================================================ */

.statut-badge, .tag {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 100px;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.statut-badge.statut-payee { background: var(--green-50); color: var(--green-600); }
.statut-badge.statut-partielle { background: var(--amber-50); color: var(--amber-600); }
.statut-badge.statut-impayee { background: var(--red-50); color: var(--red-600); }
.statut-badge.statut-annulee { background: #eceeec; color: var(--ink-500); }

.tags-medicaux { list-style: none; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.tags-medicaux .tag { background: var(--surface-2); color: var(--ink-700); border: 1px solid var(--border); }
.tags-medicaux .tag-alerte { background: var(--red-50); color: var(--red-600); border-color: #f3c9c9; }

/* ============================================================
   PAGINATION
   ============================================================ */

.paginator { margin-top: 18px; font-size: 12.5px; color: var(--ink-500); }
.pagination { list-style: none; display: flex; gap: 10px; padding: 0; }
.pagination a { color: var(--color-primary); text-decoration: none; }
.pagination .disabled { color: var(--ink-300); }

/* ============================================================
   ODONTOGRAMME
   ============================================================ */

.dent-grid { display: table; margin: 20px 0; }
.dent-row { display: table-row; }
.dent {
	display: inline-block;
	width: 36px; height: 36px;
	line-height: 36px;
	text-align: center;
	margin: 3px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
	font-family: var(--font-mono);
	transition: transform 0.1s ease;
}
.dent:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.dent[data-etat="saine"] { background: var(--green-50); color: var(--green-600); }
.dent[data-etat="cariee"] { background: var(--red-50); color: var(--red-600); }
.dent[data-etat="obturee"] { background: var(--amber-50); color: var(--amber-600); }
.dent[data-etat="devitalisee"] { background: #fdeee1; color: #9a5518; }
.dent[data-etat="couronne"] { background: var(--blue-50); color: var(--blue-600); }
.dent[data-etat="implant"] { background: var(--purple-50); color: var(--purple-600); }
.dent[data-etat="absente"] { background: var(--surface-2); color: var(--ink-300); text-decoration: line-through; }
.dent[data-etat="a_extraire"] { background: var(--ink-900); color: #fff; }

.legende span { display: inline-flex; align-items: center; gap: 5px; margin-right: 14px; font-size: 12px; color: var(--ink-700); }
.legende i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--border-strong); }

#dent-menu {
	display: none; position: absolute; background: var(--surface); border: 1px solid var(--border);
	box-shadow: var(--shadow-md); padding: 6px; z-index: 100; border-radius: var(--radius-md);
}
#dent-menu div { padding: 6px 12px; cursor: pointer; font-size: 13px; border-radius: var(--radius-sm); }
#dent-menu div:hover { background: var(--surface-2); }

/* ============================================================
   AGENDA
   ============================================================ */

.agenda-nav { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.agenda-nav button { padding: 7px 14px; }
.agenda-grille { display: grid; grid-template-columns: 56px repeat(7, 1fr); border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-md); overflow: hidden; }
.agenda-cell { border: 1px solid var(--border); min-height: 42px; padding: 2px; font-size: 11px; position: relative; }
.agenda-heure { background: var(--surface-2); font-size: 11px; text-align: right; padding-right: 6px; color: var(--ink-500); font-family: var(--font-mono); }
.agenda-jour-header { font-weight: 600; text-align: center; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--ink-700); }
.rdv-bloc { border-radius: 4px; padding: 3px 5px; color: #fff; font-size: 10px; margin-bottom: 2px; cursor: pointer; }
.rdv-bloc.statut-annule { text-decoration: line-through; opacity: 0.5; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
	.app-shell { flex-direction: column; }
	.sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 16px; overflow-x: auto; }
	.sidebar .brand { padding: 0 14px 0 0; }
	.sidebar nav { flex-direction: row; margin-top: 0; }
	.conteneur-principal { padding: 18px 16px 40px; }
}