/* Design "soins" – clair, clinique, apaisant */

:root {
  --bg-main: #f4f7fb;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --accent: #0f7dcf;
  --accent-soft: rgba(15, 125, 207, 0.1);
  --text-main: #1e2933;
  --text-muted: #708097;
  --border-subtle: #d4dde8;
  --danger: #c53030;
  --success: #2f855a;
  --warning: #d69e2e;

  --status-libre: #e3fcec;
  --status-occupe: #fde2e4;
  --status-rdv: #e0f0ff;
  --status-autre: #edf2f7;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(90deg, #f9fbff, #eef4fb);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.app-logo.logo-fallback {
  display: none;
}

.app-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-brand {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-name {
  font-size: 18px;
  font-weight: 600;
}

.header-right {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tabs */
.app-main {
  padding: 16px 22px 60px;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
  position: sticky;
  top: 58px;
  z-index: 9;
}

.tab-button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease-out;
}

.tab-button.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.05), 0 4px 18px rgba(15, 125, 207, 0.4);
}

/* Panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title h2 {
  margin: 0 0 2px;
  font-size: 20px;
}

.panel-title p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s ease-out;
  font-weight: 500;
}

.btn.primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 125, 207, 0.35);
}

.btn.primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(15, 125, 207, 0.4);
}

.btn.ghost {
  background: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn.ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: #f5f8ff;
}

.btn.full {
  width: 100%;
}

/* Inputs */
input,
select,
textarea {
  background: #ffffff;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

textarea {
  border-radius: 12px;
  resize: vertical;
}

label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Planning layout */
.planning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.planning-grid-wrapper {
  overflow: auto;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.08);
}

.planning-grid {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 12px;
}

.planning-grid th,
.planning-grid td {
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #edf2f7;
  padding: 4px 6px;
  white-space: nowrap;
}

.planning-grid th {
  position: sticky;
  top: 0;
  background: #f1f5fb;
  z-index: 2;
  font-weight: 500;
}

.planning-grid th.bed-col {
  left: 0;
  z-index: 3;
}

.planning-grid td.bed-col {
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 1;
  font-weight: 500;
}

.cell-status {
  border-radius: 8px;
  padding: 4px 6px;
  text-align: center;
  min-width: 90px;
  border: 1px solid transparent;
}

.cell-status.libre {
  background: var(--status-libre);
  color: #276749;
  border-color: #c6f6d5;
}

.cell-status.occupe {
  background: var(--status-occupe);
  color: #822727;
  border-color: #fed7d7;
}

.cell-status.rdv {
  background: var(--status-rdv);
  color: #1a365d;
  border-color: #bee3f8;
}

.cell-status.empty {
  opacity: 0.7;
}

/* Side panel */
.planning-side {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.planning-side h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-results {
  flex: 1;
  min-height: 120px;
  padding: 8px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e0;
  font-size: 12px;
}

.query-item {
  padding: 4px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.query-item:last-child {
  border-bottom: none;
}

.query-item span.label {
  color: var(--text-muted);
  font-size: 11px;
}

.legend {
  border-top: 1px solid #edf2f7;
  padding-top: 8px;
}

.legend ul {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.15);
}

/* Agenda */
.agenda-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.5fr);
  gap: 16px;
}

.agenda-form-card,
.agenda-list-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.06);
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.form-row > * {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.agenda-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.agenda-table th,
.agenda-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 6px;
}

.agenda-table th {
  text-align: left;
  background: #f1f5fb;
}

/* Patients */
.patients-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.5fr);
  gap: 16px;
}

.patients-form-card,
.patients-list-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.06);
}

.patients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.patients-table th,
.patients-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 6px;
}

.patients-table th {
  text-align: left;
  background: #f1f5fb;
}

/* BI */
.bi-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
}

.bi-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.bi-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
}

.bi-card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.bi-metric {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.bi-chart-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
}

.bi-chart {
  height: 160px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e0;
  display: flex;
  align-items: flex-end;
  padding: 6px;
  gap: 4px;
}

.bi-bar {
  flex: 1;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, #0f7dcf, #63b3ed);
}

/* Settings */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.settings-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 14px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.pill-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill-delete {
  cursor: pointer;
  font-size: 13px;
  color: #c53030;
}

.color-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.color-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f8fafc;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  font-size: 12px;
}

.color-item input[type="color"] {
  width: 38px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #cbd5e0;
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  background: #f9fbff;
  border-top: 1px solid var(--border-subtle);
}

/* Responsive */
@media (max-width: 960px) {
  .planning-layout,
  .agenda-layout,
  .patients-layout,
  .bi-layout,
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .tabs {
    width: 100%;
    justify-content: space-between;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
}


.patients-table tr.selected {
  background: #e3f2ff;
}


.bi-stays-card {
  margin-top: 16px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.stays-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stays-table th,
.stays-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 6px;
}

.stays-table th {
  text-align: left;
  background: #f1f5fb;
}


.header-right {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.today-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-select {
  font-size: 12px;
  color: var(--text-muted);
}

.role-select select {
  margin-left: 4px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #ffffff;
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
}

.view-presets {
  display: inline-flex;
  gap: 4px;
  margin: 0 6px;
}

.view-presets .btn {
  padding-inline: 8px;
}

body[data-theme="dark"] {
  --bg-main: #020617;
  --bg-panel: #020617;
  --bg-card: #020617;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --border-subtle: #1f2937;
}

body[data-theme="dark"] .app-header {
  background: linear-gradient(90deg, #020617, #020617);
  border-bottom-color: #1f2937;
}

body[data-theme="dark"] .app-main {
  background: radial-gradient(circle at top, #0f172a, #020617);
}

body[data-theme="dark"] .tabs {
  background: #020617;
  border-color: #1f2937;
}

body[data-theme="dark"] .tab-button {
  color: #9ca3af;
}

body[data-theme="dark"] .tab-button.active {
  color: #0b1120;
}

body[data-theme="dark"] .planning-grid-wrapper,
body[data-theme="dark"] .planning-side,
body[data-theme="dark"] .agenda-form-card,
body[data-theme="dark"] .agenda-list-card,
body[data-theme="dark"] .patients-form-card,
body[data-theme="dark"] .patients-list-card,
body[data-theme="dark"] .bi-card,
body[data-theme="dark"] .bi-chart-card,
body[data-theme="dark"] .settings-card,
body[data-theme="dark"] .bi-stays-card {
  background: #020617;
  border-color: #1f2937;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.8);
}

body[data-theme="dark"] .planning-grid th {
  background: #020617;
}

body[data-theme="dark"] .planning-grid td.bed-col {
  background: #020617;
}

body[data-theme="dark"] .agenda-table th,
body[data-theme="dark"] .patients-table th,
body[data-theme="dark"] .stays-table th {
  background: #0b1120;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background: #020617;
  color: #e5e7eb;
  border-color: #1f2937;
}

body[data-theme="dark"] .app-footer {
  background: #020617;
  border-top-color: #1f2937;
}

/* Status selection menu for cells */
.status-menu {
  position: absolute;
  z-index: 50;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
  padding: 6px;
  min-width: 160px;
}

body[data-theme="dark"] .status-menu {
  background: #020617;
}

.status-menu h4 {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
}

.status-menu button:hover {
  background: #eff6ff;
}

body[data-theme="dark"] .status-menu button:hover {
  background: #0b1120;
}

.status-menu button.status-remove {
  color: #b91c1c;
}


/* Dashboard */
.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: 16px;
}

.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.dash-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

body[data-theme="dark"] .dash-card {
  background: #020617;
}

.dash-card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.dash-metric {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.dash-table-card {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

body[data-theme="dark"] .dash-table-card {
  background: #020617;
}

.dash-table-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.dash-table-header h3 {
  margin: 0;
  font-size: 14px;
}

.dash-table-caption {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 960px) {
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* Recherche globale */
.search-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.search-controls label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  gap: 4px;
}

.search-controls input,
.search-controls select {
  min-width: 200px;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.search-column h3 {
  margin-top: 0;
  margin-bottom: 4px;
  font-size: 14px;
}


/* Écran de connexion */
.login-screen {
  position: fixed;
  inset: 0;
  background: rgba(12, 21, 38, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--surface);
  padding: 24px 28px;
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.login-header p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #708097;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-field input[type="text"],
.login-field input[type="password"] {
  border-radius: 999px;
  border: 1px solid #d0d7e2;
  padding: 8px 12px;
  font-size: 0.95rem;
}

.login-roles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.login-roles label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f4f7fb;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Affichage utilisateur dans le header */
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.user-label {
  font-size: 0.85rem;
  color: #e2e8f0;
}

/* Agenda filters - UX améliorée */
.agenda-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.agenda-filters-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agenda-filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agenda-filter-row--inline {
  flex-direction: row;
  gap: 12px;
}

.agenda-filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.agenda-period-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-filter-row--buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Agenda table sortable headers */
.agenda-table th.sortable {
  cursor: pointer;
  position: relative;
}

.agenda-table th.sorted-asc::after,
.agenda-table th.sorted-desc::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.agenda-table th.sorted-asc::after {
  border-bottom: 6px solid var(--accent);
}

.agenda-table th.sorted-desc::after {
  border-top: 6px solid var(--accent);
}
