/* DogDesk Appointments — Calendar Styles */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F8F6F1;
  --surface: #FFFFFF;
  --border: #E5E0D8;
  --text: #2D2006;
  --text-muted: #7A6F5A;
  --primary: #8B5E3C;
  --primary-hover: #6E4930;
  --primary-light: #F5EDE4;
  --accent: #D4A574;
  --success: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(45, 32, 6, 0.10);
  --font: 'Inter', -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.logo-icon { font-size: 22px; }

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ---- Layout ---- */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  height: calc(100vh - 56px);
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upcoming-list { display: flex; flex-direction: column; gap: 8px; }

.upcoming-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
}

.upcoming-item:hover { border-color: var(--accent); background: var(--primary-light); }

.upcoming-date { font-size: 12px; font-weight: 600; color: var(--primary); }
.upcoming-dog { font-weight: 600; font-size: 13px; }
.upcoming-client { font-size: 11px; color: var(--text-muted); }
.empty-msg { font-size: 12px; color: var(--text-muted); text-align: center; padding: 16px 0; }

/* ---- Calendar area ---- */
.calendar-area {
  padding: 20px 24px;
  overflow: auto;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.cal-nav { display: flex; align-items: center; gap: 8px; }

.cal-week-label {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.cal-actions { display: flex; gap: 8px; }

/* ---- Calendar grid ---- */
.cal-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-width: 700px;
}

.cal-header-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background: var(--primary-light);
  border-bottom: 2px solid var(--border);
}

.cal-time-gutter {
  padding: 8px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--bg);
}

.cal-day-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-right: 1px solid var(--border);
  height: 48px;
}

.cal-day-header:last-child { border-right: none; }
.cal-day-header .day-name { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.cal-day-header .day-num { font-size: 18px; font-weight: 700; line-height: 1.2; }
.cal-day-header .today-num { color: var(--primary); }

/* Time rows */
.cal-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.cal-row:last-child { border-bottom: none; }

.cal-cell {
  border-right: 1px solid var(--border);
  padding: 2px;
  position: relative;
  min-height: 52px;
  cursor: pointer;
  transition: background 0.1s;
}

.cal-cell:last-child { border-right: none; }
.cal-cell:hover { background: var(--primary-light); }
.cal-cell.now-slot { background: #FEF9EC; }

/* Appointment blocks */
.appt-block {
  border-left: 3px solid #9CA3AF;
  border-radius: 4px;
  padding: 3px 6px;
  margin: 1px 2px;
  font-size: 11px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.appt-block:hover { opacity: 0.85; transform: scale(1.01); }
.appt-block.status-cancelled { opacity: 0.45; text-decoration: line-through; }
.appt-block.status-done { opacity: 0.7; }

.appt-time { font-weight: 700; color: var(--text); font-size: 11px; }
.appt-dog { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-svc { font-size: 10px; color: var(--text-muted); }
.appt-client { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Skeleton ---- */
.skeleton-overlay { display: none; padding: 16px; }
.skeleton-overlay .skeleton-cols {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 0;
}
.skeleton-cell {
  height: 40px;
  background: linear-gradient(90deg, var(--border) 25%, #ede8e0 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin: 2px;
  border-radius: 4px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  padding: 6px 10px;
  font-size: 16px;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803D; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.btn-close:hover { color: var(--text); }

/* ---- Modal ---- */
.modal {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 32, 6, 0.45);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 0;
}

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

.modal-header h2 { font-size: 17px; font-weight: 700; }

/* ---- Form ---- */
.appt-form { padding: 20px 24px 24px; }

.form-row { margin-bottom: 16px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12);
}

.form-input:disabled, .form-select:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

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

.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-bottom: 12px;
  min-height: 18px;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* ---- Detail view ---- */
.appt-detail { padding: 0 24px 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }

.detail-row {
  display: contents;
}
.detail-row > * {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-row > *:nth-child(odd) { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.detail-row > *:nth-child(even) { }
.detail-row:last-child > * { border-bottom: none; }

.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-warn { background: #FEF3C7; color: #92400E; }
.badge-ok { background: #D1FAE5; color: #065F46; }
.badge-done { background: #DBEAFE; color: #1E40AF; }
.badge-danger { background: #FEE2E2; color: #991B1B; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 2000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { background: #16A34A; color: #fff; }
.toast-warn { background: #D97706; color: #fff; }
.toast-error { background: #DC2626; color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}