/* ============================================================
   common.css — Shared styles: variables, reset, layout, header,
   sidebar, navigation, message bar, base components
   
   2026 design:
   - Dark slate sidebar (Linear/Notion style)
   - Header gradient accent bar
   - Icon circles in section headers
   - Micro-interactions & hover lifts
   - prefers-reduced-motion & focus-visible for a11y
   ============================================================ */

:root {
  --primary: #0c7a8f;
  --primary-dark: #095e6e;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --primary-rgb: 12, 122, 143;
  --accent-rgb: 245, 158, 11;
  --primary-soft: rgba(var(--primary-rgb), 0.75);
  --primary-softer: rgba(var(--primary-rgb), 0.5);
  --primary-light: rgba(var(--primary-rgb), 0.08);
  --accent-soft: rgba(var(--accent-rgb), 0.85);
  --accent-softer: rgba(var(--accent-rgb), 0.6);
  --accent-light: rgba(var(--accent-rgb), 0.10);
  --bg: #ffffff;
  --bg-secondary: #f7f8fa;
  --bg-warm: #faf9f7;
  --bg-message: rgba(var(--primary-rgb), 0.04);
  --sidebar-bg: #1e293b;
  --sidebar-bg-deep: #0f172a;
  --sidebar-text: rgba(255, 255, 255, 0.7);
  --sidebar-text-hover: #ffffff;
  --sidebar-text-muted: rgba(255, 255, 255, 0.4);
  --sidebar-active-bg: rgba(255, 255, 255, 0.1);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --text: #3b4252;
  --text-heading: #2e3440;
  --text-muted: #8892a4;
  --border: #e5e9f0;
  --success: #10b981;
  --danger: #ef4444;
  --alert-bg: rgba(var(--accent-rgb), 0.06);
  --alert-bg-strong: rgba(var(--accent-rgb), 0.14);
  --topbar-height: 3.5rem;

  --gap-topbar-message: 0.75rem;
  --header-height: 5.5rem;
  --sidebar-width: 260px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03), 0 1px 3px rgba(0,0,0,0.02);
  --shadow: 0 2px 8px rgba(0,0,0,0.05), 0 1px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-glow-primary: 0 4px 14px rgba(var(--primary-rgb), 0.15);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Accessibility: focus-visible ---- */

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- Accessibility: reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Layout shell ---- */

.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.layout-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---- Top band (header) ---- */

.top-band {
  display: flex;
  align-items: stretch;
  min-height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.top-band::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  z-index: 1;
}

.top-band-left {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  border-right: none;
  background: var(--sidebar-bg);
}

.top-band-left .logo {
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 0.35rem;
}

/* ---- User / family member selector (top-band-right) ---- */

.user-selector {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem 0.3rem 0.35rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}
.user-selector:hover {
  background: var(--primary-light);
  border-color: var(--border);
}
.user-selector[aria-expanded="true"] {
  background: var(--primary-light);
  border-color: rgba(var(--primary-rgb), 0.2);
}
.user-selector[aria-expanded="true"] .user-selector-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.user-selector-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  animation: dropdownSlide 0.18s ease-out;
  padding: 0.35rem 0;
}
.user-selector[aria-expanded="true"] .user-selector-dropdown {
  display: block;
}

@keyframes dropdownSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-selector-dropdown .dropdown-label {
  padding: 0.45rem 0.85rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.user-selector-dropdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.user-selector-dropdown li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.15s ease;
}
.user-selector-dropdown li:hover {
  background: var(--primary-light);
  color: var(--text-heading);
}
.user-selector-dropdown li[aria-selected="true"] {
  color: var(--primary);
  font-weight: 600;
}
.user-selector-dropdown li[aria-selected="true"]:hover {
  background: var(--primary-light);
}

.user-selector-dropdown li svg:first-child {
  flex-shrink: 0;
  opacity: 0.4;
}
.user-selector-dropdown li[aria-selected="true"] svg:first-child {
  opacity: 0.85;
  color: var(--primary);
}

.user-selector-dropdown li .check-icon {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  color: var(--primary);
}
.user-selector-dropdown li[aria-selected="true"] .check-icon {
  opacity: 1;
}

.dropdown-separator {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}
.dropdown-separator-li {
  height: 1px;
  background: var(--border);
  margin: 0.1rem 0;
  padding: 0;
  display: block;
  list-style: none;
  cursor: default;
}
.dropdown-separator-li:hover {
  background: var(--border);
}

.dropdown-action {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-body);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dropdown-action:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.dropdown-action svg {
  flex-shrink: 0;
  opacity: 0.5;
}
.dropdown-action:hover svg {
  opacity: 0.85;
}

.dropdown-action--danger:hover {
  background: rgba(239, 68, 68, 0.06);
  color: var(--danger);
}
.dropdown-action--danger:hover svg {
  color: var(--danger);
}

.user-selector-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--primary);
  padding: 4px;
  box-sizing: content-box;
  background: var(--primary-light);
  border-radius: 50%;
}

.user-selector-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-selector-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  pointer-events: none;
  transition: transform var(--transition);
}
.user-selector:hover .user-selector-chevron {
  color: var(--primary);
}

.top-band-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
}

.top-band-center .page-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 60%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.top-band-right {
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
}

.top-band-right-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

.top-band-right .link-contact {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  transition: all var(--transition);
}
.top-band-right .link-contact:hover {
  background: var(--primary-light);
  text-decoration: none;
}

.top-band-right-inner .link-contact {
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
  margin-right: 0.15rem;
  border-radius: 0;
}

.top-band-right-inner a.picto {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.top-band-right-inner a.picto:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: scale(1.05);
}
.top-band-right-inner a.picto svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

/* ---- Sidebar (dark slate) ---- */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  border-right: none;
}

.sidebar nav {
  padding: 0.6rem 0.6rem;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border-bottom: none;
  transition: all var(--transition);
  position: relative;
}
.sidebar nav a:last-child { border-bottom: none; }
.sidebar nav a:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

.sidebar nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-hover);
  font-weight: 600;
  padding-left: 0.9rem;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar nav a.active svg { color: var(--accent); opacity: 1; }
.sidebar nav a svg { flex-shrink: 0; opacity: 0.5; color: var(--sidebar-text); transition: all var(--transition); }
.sidebar nav a:hover svg { opacity: 0.9; color: var(--sidebar-text-hover); }

.sidebar nav a .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #1e293b;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 1.15rem;
  height: 1.15rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
  box-shadow: 0 1px 6px rgba(var(--accent-rgb), 0.4);
}

/* ---- Main content area ---- */

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---- Content base ---- */

.content {
  padding: 1.5rem 2rem;
}

.page-heading {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 1.25rem 0;
  letter-spacing: -0.02em;
}

/* ---- Section base ---- */

.section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-slow);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text-heading);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.005em;
}
.section-header svg {
  color: var(--primary);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 5px;
  box-sizing: content-box;
  background: rgba(var(--primary-rgb), 0.1);
  border-radius: 50%;
}

/* ---- Info box ---- */

.info-box {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}
.info-box .info-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-heading);
  margin: 0 0 0.35rem 0;
}
.info-box p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
}

/* ---- Document list / items ---- */

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.doc-item:hover {
  box-shadow: var(--shadow);
  border-color: rgba(var(--primary-rgb), 0.15);
  transform: translateY(-1px);
}
.doc-item .doc-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-heading);
}
.doc-item .doc-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.doc-item .doc-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-doc {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: 20px;
  text-decoration: none;
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.btn-doc:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-doc svg { width: 14px; height: 14px; }

/* ---- Actions bar & buttons ---- */

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}
.actions-bar .label-actions {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text-heading);
  margin-right: 0.5rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  font-size: 0.93rem;
  font-weight: 600;
  border-radius: 24px;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  font-family: inherit;
  position: relative;
}
.btn-action.refuse {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-action.refuse:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.04);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}
.btn-action.accept {
  background: var(--success);
  color: white;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.2);
}
.btn-action.accept:hover {
  background: #059669;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}
.btn-action svg { width: 18px; height: 18px; }

/* ============================================================
   Responsive — Tablet (max-width: 1024px)
   ============================================================ */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .top-band-center .page-title { font-size: 1.2rem; }
  .top-band-right { padding: 0 0.75rem; }
  .top-band-right .link-contact { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
  .content { padding: 1.25rem 1.5rem; }
}

/* ============================================================
   Responsive — Mobile (max-width: 768px)
   ============================================================ */

@media (max-width: 768px) {
  .layout {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .layout-body {
    flex-direction: column;
    overflow: visible;
  }

  /* Header: single row, compact */
  .top-band {
    flex-wrap: nowrap;
    min-height: auto;
    padding: 0.4rem 0.5rem;
    gap: 0.4rem;
    align-items: center;
  }
  .top-band::before { left: 0; }

  .top-band-left {
    width: auto;
    flex: 0 0 auto;
    min-width: 0;
    border-right: none;
    padding: 0.25rem 0.5rem;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    background: var(--sidebar-bg);
    border-radius: var(--radius-xs);
  }
  .top-band-left .logo {
    font-size: 0.6rem;
  }

  .top-band-center {
    flex: 1;
    padding: 0 0.5rem;
    min-width: 0;
  }
  .top-band-center .page-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-band-right { flex: 0 0 auto; padding: 0; }
  .top-band-right-inner {
    padding: 0.2rem 0;
    gap: 0.15rem;
    border: none;
    background: transparent;
  }
  .top-band-right-inner .link-contact { display: none; }
  .top-band-right-inner a.picto { width: 34px; height: 34px; }
  .top-band-right-inner a.picto svg { width: 17px; height: 17px; }

  /* User selector: compact on mobile */
  .user-selector { padding: 0.2rem 0.35rem 0.2rem 0.2rem; gap: 0.3rem; }
  .user-selector-icon { width: 20px; height: 20px; padding: 3px; }
  .user-selector-name { max-width: 70px; font-size: 0.78rem; }
  .user-selector-dropdown { right: -0.5rem; min-width: 200px; }

  /* Sidebar: hidden by default on mobile */
  .sidebar {
    display: none;
  }

  /* Main content: full width */
  .main { overflow-y: auto; }
  .content { padding: 1rem; }
  .page-heading { font-size: 1.1rem; margin-bottom: 1rem; }

  /* Message bar */
  /* Sections */
  .section { padding: 1rem; border-radius: var(--radius-sm); }
  .section-header { font-size: 0.88rem; gap: 0.45rem; margin-bottom: 0.75rem; }
  .section-header svg { width: 16px; height: 16px; padding: 4px; }

  /* Document items stack on mobile */
  .doc-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.75rem; }
  .doc-item .doc-actions { align-self: stretch; }
  .doc-item .doc-actions .btn-doc { flex: 1; justify-content: center; }

  /* Actions bar */
  .actions-bar { flex-direction: column; align-items: stretch; gap: 0.65rem; }
  .actions-bar .btn-action { justify-content: center; text-align: center; }
}

/* ============================================================
   Responsive — Small phone (max-width: 480px)
   ============================================================ */

@media (max-width: 480px) {
  .top-band-left { display: none; }
  .top-band-center .page-title { font-size: 0.9rem; }
  .top-band-right-inner a.picto { width: 32px; height: 32px; }
  .user-selector-name { display: none; }
  .content { padding: 0.75rem; }
}
