/* ============================================================
   PENSION CANINE — Design System
   Soft UI Evolution + Pet Tech warmth
   Mobile-first (375px → 768px → 1024px → 1440px)
   ============================================================ */

/* ── Variables CSS ────────────────────────────────────────── */
:root {
  --color-primary:    #2D6A4F;
  --color-primary-l:  #40916C;
  --color-primary-d:  #1B4332;
  --color-accent:     #D4A017;
  --color-accent-l:   #E8B923;
  --color-accent-d:   #B8860B;
  --color-success:    #2E8B57;
  --color-danger:     #C0392B;
  --color-warning:    #D68910;
  --color-bg:         #F0F7F4;
  --color-surface:    #FFFFFF;
  --color-text:       #1A2E25;
  --color-muted:      #5C7A6B;
  --color-border:     #C8DDD5;

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  --transition: 150ms ease;

  --topbar-h:     56px;
  --bottomnav-h:  64px;
  --sidebar-w:    240px;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-d); }

/* ── Top bar ──────────────────────────────────────────────── */
.app-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 100;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-d) 100%);
  box-shadow: 0 2px 8px rgba(45, 106, 79, .3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-h);
  padding-bottom: var(--bottomnav-h);
}

@media (min-width: 1024px) {
  .app-layout {
    padding-bottom: 0;
  }
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  padding-bottom: calc(var(--bottomnav-h) + 16px);
}

@media (min-width: 768px) {
  .app-main { padding: 24px; }
}

@media (min-width: 1024px) {
  .app-main {
    padding: 32px;
    padding-bottom: 32px;
    margin-left: var(--sidebar-w);
  }
}

/* ── Sidebar (desktop) ────────────────────────────────────── */
.app-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    z-index: 50;
  }
}

.sidebar-nav {
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.sidebar-link:hover {
  background: #DFF0E8;
  color: var(--color-primary);
}

.sidebar-link.active {
  background: linear-gradient(135deg, #DFF0E8 0%, #C8E6DA 100%);
  color: var(--color-primary-d);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Bottom nav (mobile) ──────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  font-size: 0.65rem;
  font-weight: 500;
  transition: all var(--transition);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  cursor: pointer;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--color-primary);
}

.bottom-nav-item.active .bottom-nav-icon {
  filter: drop-shadow(0 0 4px rgba(45,106,79,.4));
}

.bottom-nav-icon {
  width: 22px;
  height: 22px;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
}

.flash-success { background: #D5F5E3; color: #1E8449; border-bottom: 1px solid #A9DFBF; }
.flash-error   { background: #FADBD8; color: #922B21; border-bottom: 1px solid #F1948A; }
.flash-warning { background: #FEF9E7; color: #9A7D0A; border-bottom: 1px solid #F9E79F; }
.flash-info    { background: #D6EAF8; color: #1A5276; border-bottom: 1px solid #AED6F1; }

.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: .6;
  flex-shrink: 0;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flash-close:hover { opacity: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 20px;
}

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-d) 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(45,106,79,.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-d) 0%, #0D2B1E 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(45,106,79,.45);
}

.btn-accent {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-d) 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(212,160,23,.35);
}
.btn-accent:hover {
  background: linear-gradient(135deg, var(--color-accent-d) 0%, #8B6508 100%);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, var(--color-success) 0%, #1E8449 100%);
  color: #fff;
}
.btn-success:hover { filter: brightness(0.92); }

.btn-danger {
  background: linear-gradient(135deg, var(--color-danger) 0%, #B03A2E 100%);
  color: #fff;
}
.btn-danger:hover { filter: brightness(0.92); }

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

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  min-height: 36px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  min-height: 52px;
  border-radius: var(--radius-lg);
}

.btn-full { width: 100%; }

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sm svg { width: 16px; height: 16px; }

/* ── Formulaires ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.form-control::placeholder { color: #BDC3C7; }

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%237F8C8D'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
  cursor: pointer;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.8rem;
  color: var(--color-danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(231,76,60,.12);
}

/* Checkboxes / radios */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-height: 44px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* Grid de formulaire */
.form-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Badges / statuts ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #D5F5E3; color: #1E8449; }
.badge-warning { background: #FEF9E7; color: #9A7D0A; }
.badge-danger  { background: #FADBD8; color: #922B21; }
.badge-info    { background: #D6EAF8; color: #1A5276; }
.badge-muted   { background: #F2F3F4; color: #566573; }
.badge-primary { background: #C8E6DA; color: #1B4332; }

/* ── Tableaux ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  background: #E5F2ED;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid #ECEAE8;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}

.table tbody tr:hover { background: #E5F2ED; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 2px;
}

/* ── KPI Cards (Dashboard) ────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.kpi-icon svg { width: 22px; height: 22px; }

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-weight: 500;
}

/* ── Liste de chiens présents ─────────────────────────────── */
.dog-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition);
  cursor: pointer;
}

.dog-card:hover { box-shadow: var(--shadow-md); }

.dog-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #C8E6DA;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dog-avatar svg {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.dog-info { flex: 1; min-width: 0; }

.dog-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dog-breed {
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ── Alert cards ──────────────────────────────────────────── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  border-left: 3px solid;
  text-decoration: none;
  transition: filter var(--transition);
}

.alert-item:hover { filter: brightness(0.96); }

.alert-danger  { background: #FADBD8; border-color: var(--color-danger);  color: #7B241C; }
.alert-warning { background: #FEF9E7; border-color: var(--color-warning); color: #7D6608; }
.alert-info    { background: #D6EAF8; border-color: var(--color-accent);  color: #1A5276; }

.alert-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ── Actions rapides ──────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--color-text);
}

.quick-action-btn:hover {
  border-color: var(--color-primary);
  background: #DFF0E8;
  color: var(--color-primary-d);
  box-shadow: var(--shadow-md);
}

.quick-action-btn svg {
  width: 26px;
  height: 26px;
  color: var(--color-primary);
}

.quick-action-btn span {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

/* ── Section heading ──────────────────────────────────────── */
.section-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  margin-bottom: 10px;
}

/* ── Photo upload ─────────────────────────────────────────── */
.photo-upload {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px dashed var(--color-border);
  cursor: pointer;
  background: #E5F2ED;
  transition: border-color var(--transition);
  flex-shrink: 0;
}

.photo-upload:hover { border-color: var(--color-primary); }

.photo-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity var(--transition);
  color: #fff;
  font-size: 0.7rem;
}

.photo-upload:hover .photo-upload-overlay { opacity: 1; }

/* ── Calendrier Planning ──────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-name {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: 6px 0;
}

.calendar-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  min-height: 44px;
}

.calendar-cell:hover {
  background: #DFF0E8;
  border-color: var(--color-border);
}

.calendar-cell.today {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-d) 100%);
  color: #fff;
}

.calendar-cell.today .calendar-day-num { color: #fff; font-weight: 700; }

.calendar-cell.has-dogs { border-color: var(--color-primary-l); }

.calendar-cell.other-month { opacity: .35; }

.calendar-day-num {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
}

.calendar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 2px;
}

.calendar-cell.today .calendar-dot { background: rgba(255,255,255,.8); }

.calendar-count {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}

.calendar-cell.today .calendar-count { color: rgba(255,255,255,.9); }

/* ── Suivi journalier — checklist ─────────────────────────── */
.log-check-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .log-check-grid { grid-template-columns: repeat(4, 1fr); }
}

.log-check-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--color-surface);
  text-align: center;
}

.log-check-item.checked {
  border-color: var(--color-success);
  background: #D5F5E3;
}

.log-check-item svg {
  width: 28px;
  height: 28px;
  color: var(--color-muted);
  transition: color var(--transition);
}

.log-check-item.checked svg { color: var(--color-success); }

.log-check-item span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
}

.log-check-item.checked span { color: var(--color-success); }

/* ── Search bar ───────────────────────────────────────────── */
.search-bar {
  position: relative;
}

.search-bar svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-muted);
  pointer-events: none;
}

.search-bar .form-control {
  padding-left: 42px;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: #CACFD2;
  margin: 0 auto 16px;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: #7F8C8D;
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 0.875rem;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  transition: all var(--transition);
  text-decoration: none;
}

.page-link:hover { background: #DFF0E8; color: var(--color-primary); border-color: var(--color-primary-l); }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Utilitaires ──────────────────────────────────────────── */
.text-muted  { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.gap-section { margin-bottom: 24px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
