/* ══════════════════════════════════════════════════════
   Ambrotos – Fælles kalender
   ══════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────── */
:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --danger:       #dc2626;
  --danger-dark:  #b91c1c;
  --bg:           #f1f5f9;
  --card:         #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Flash messages ──────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary      { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline      { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }

.btn-danger       { background: var(--danger); color: white; }
.btn-danger:hover  { background: var(--danger-dark); }

.btn-sm    { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-full  { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

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

/* ══════════════════════════════════════════════════════
   Login page
   ══════════════════════════════════════════════════════ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-size: 40px;
  margin-bottom: 8px;
}

.login-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ══════════════════════════════════════════════════════
   App layout
   ══════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.navbar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.user-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.user-name { font-weight: 500; }

/* ── Main content ────────────────────────────────────── */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Calendar panel ──────────────────────────────────── */
.calendar-panel {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

#calendar {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* FullCalendar customisation */
.fc-toolbar-title { font-size: 17px !important; font-weight: 700 !important; }
.fc-button         { font-size: 13px !important; }
.fc-daygrid-event  { border-radius: 4px !important; font-size: 11px !important; padding: 1px 5px !important; cursor: pointer !important; }
.fc-daygrid-event:hover { opacity: 0.82; }
.fc-day-today      { background: var(--primary-soft) !important; }
.fc-daygrid-more-link { font-size: 11px !important; color: var(--text-muted) !important; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 20px 20px 0;
  overflow: hidden;
}

/* ── Legend ──────────────────────────────────────────── */
.legend-card { flex-shrink: 0; }

.legend-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  overflow: hidden;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-you { font-weight: 700; }
.legend-you em { font-style: normal; font-weight: 400; color: var(--text-muted); }

/* ── Chat ────────────────────────────────────────────── */
.chat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.chat-hint strong { color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0;
  min-height: 0;
  scroll-behavior: smooth;
}

.chat-message         { display: flex; }
.chat-message.user    { justify-content: flex-end; }
.chat-message.ai      { justify-content: flex-start; }

.chat-bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
}

.chat-message.user .chat-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 3px;
}

.chat-message.ai .chat-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 3px;
}

.chat-bubble em { font-style: italic; color: inherit; opacity: 0.85; }

/* Typing animation */
.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 3px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
  30%            { opacity: 1;    transform: scale(1); }
}

/* Chat input */
.chat-input-area {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-area input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

#chatSend {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   Modal
   ══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 24px;
  min-width: 300px;
  max-width: 420px;
  width: 100%;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.modal-member:last-child { border-bottom: none; }

.modal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.modal-member-name { flex: 1; }
.modal-member-you  { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

.modal-holiday {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: #c0392b;
}

.modal-holiday-icon { font-size: 15px; }
.modal-holiday-name { font-weight: 600; }
.modal-holiday-desc {
  font-size: 12px;
  font-weight: 400;
  color: #922b21;
  margin-top: 1px;
}

.modal-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px 0;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════ */

/* ── Calendar toolbar (event mode) ──────────────────── */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.event-mode-btn.active {
  background: #7c3aed;
  color: white;
  border-color: #7c3aed;
}

.event-mode-hint {
  font-size: 13px;
  color: #7c3aed;
  font-weight: 500;
}

#calendar.event-mode-active {
  outline: 3px solid #7c3aed;
  outline-offset: 2px;
  border-radius: var(--radius);
}

#calendar.event-mode-active .fc-daygrid-day,
#calendar.event-mode-active .fc-timegrid-slot {
  cursor: crosshair !important;
}

/* ── Upcoming events card ────────────────────────────── */
.events-card {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.upcoming-events-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding-right: 2px;
}

.events-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.event-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.event-item:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.event-item-date {
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.event-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.event-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Unavailability circles in day cells ─────────────── */
.day-unavail-circles {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 1px 4px 3px;
}

.day-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: white;
  cursor: default;
  flex-shrink: 0;
}

.day-avatar-more {
  background: var(--text-muted);
  font-size: 7px;
}

/* ── Avatar circles (attendance + date modal) ────────── */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  cursor: default;
  border: 2px solid white;
  margin-left: -4px;
  transition: transform 0.1s;
}

.avatar:first-child { margin-left: 0; }
.avatar:hover { transform: scale(1.15); z-index: 1; }

/* ── Attendance section in event detail ──────────────── */
.attendance-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attendance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}

.attendance-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  min-width: 100px;
}

.attendance-label.attending    { color: #16a34a; }
.attendance-label.not-attending { color: var(--danger); }

.attendance-avatars {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

.attendance-none {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Wide modal ──────────────────────────────────────── */
.modal-wide { max-width: 520px; }

/* ── Event detail ────────────────────────────────────── */
.event-detail-date {
  font-size: 13px;
  color: #7c3aed;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: capitalize;
}

.event-detail-desc {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.5;
}

.event-detail-creator {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.event-detail-actions { margin-bottom: 16px; }

/* ── Comments ────────────────────────────────────────── */
.comments-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

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

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.comments-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 0;
}

.comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.comment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.comment-content { flex: 1; }

.comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.comment-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}

.comment-text {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.4;
}

.comment-input-area {
  display: flex;
  gap: 8px;
}

.comment-input-area input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.comment-input-area input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Textarea in modals */
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ══════════════════════════════════════════════════════
   Admin panel
   ══════════════════════════════════════════════════════ */

.admin-layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

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

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

.admin-title { font-size: 20px; font-weight: 700; color: var(--text); }

.admin-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.admin-table th small { font-size: 10px; display: block; font-weight: 400; }

.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

.user-cell { display: flex; align-items: center; gap: 8px; }

.table-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.admin-badge, .you-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-badge { background: #ede9fe; color: #6d28d9; }
.you-badge   { background: #e0f2fe; color: #0369a1; }

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 5px;
  border: 1px solid rgba(0,0,0,0.1);
}

.color-code { font-size: 12px; color: var(--text-muted); font-family: monospace; }

.stat-cell  { text-align: center; font-weight: 600; }
.stat-green { color: #16a34a; }
.stat-red   { color: var(--danger); }
.stat-muted { color: var(--text-muted); font-weight: 400; }

.action-cell { display: flex; gap: 6px; }

.color-input-row { display: flex; gap: 8px; align-items: center; }

.color-input-row input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.color-input-row input[type="text"] { flex: 1; }

.form-check label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.label-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: #fee2e2;
  border-radius: 6px;
}

/* ══════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .app-layout   { height: auto; overflow: auto; }
  .main-content { flex-direction: column; overflow: visible; }

  .sidebar {
    width: 100%;
    padding: 0 16px 20px;
    overflow: visible;
  }

  .calendar-panel { padding: 16px 16px 0; }

  .events-card { min-height: 320px; }
}
