/* kalender-drawer.css — Event drawer, form, category picker, smart-drawer */
/* Auto-split from kalender.css + kalender-ai.css — 1070 lines */

/* ════════════════════════════════════════════════════════════
   RIGHT DRAWER — Slide-in event editor
   ════════════════════════════════════════════════════════════ */

.cal-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.cal-drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.cal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--color-card);
  z-index: 301;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.08), -2px 0 8px rgba(0, 0, 0, 0.04);
}

.cal-drawer-overlay.active .cal-drawer {
  transform: translateX(0);
}

/* Drawer content stagger — fields cascade in */
.cal-drawer-overlay.active .cal-drawer-body .input-group,
.cal-drawer-overlay.active .cal-drawer-body .cal-drawer-dates,
.cal-drawer-overlay.active .cal-drawer-body .toggle {
  animation: drawer-field-in 0.3s ease both;
}

.cal-drawer-overlay.active .cal-drawer-body .input-group:nth-child(1) { animation-delay: 0.08s; }
.cal-drawer-overlay.active .cal-drawer-body .input-group:nth-child(2) { animation-delay: 0.12s; }
.cal-drawer-overlay.active .cal-drawer-body .cal-drawer-dates { animation-delay: 0.16s; }
.cal-drawer-overlay.active .cal-drawer-body .toggle { animation-delay: 0.20s; }
.cal-drawer-overlay.active .cal-drawer-body .input-group:nth-child(n+5) { animation-delay: 0.24s; }

@keyframes drawer-field-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer buttons stagger */
.cal-drawer-overlay.active .cal-drawer-footer {
  animation: drawer-field-in 0.25s ease 0.2s both;
}

.cal-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.cal-drawer-header h5 {
  font-size: 18px;
  font-weight: 650;
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: -0.2px;
}

.cal-drawer-close {
  background: transparent;
  border: none;
  padding: 10px; /* 44px touch target */
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full, 50%);
  transition: all 0.15s ease;
}

.cal-drawer-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-primary);
}

.cal-drawer-close:active {
  transform: scale(0.85);
  transition: transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cal-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 20px;
  scrollbar-width: none;           /* Firefox — hide scrollbar */
}

.cal-drawer-body::-webkit-scrollbar {
  display: none;                   /* Chrome/Safari — hide scrollbar */
}

.cal-drawer-body .input-group {
  margin-bottom: 14px;
}

.cal-drawer-body .input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 5px;
}

.cal-drawer-body .input {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  accent-color: var(--color-text-primary);
  color-scheme: light;
}

.cal-drawer-body .input:hover {
  border-color: rgba(0, 0, 0, 0.08);
}

.cal-drawer-body .input:focus,
.cal-drawer-body .input:focus-visible,
.cal-drawer-body textarea:focus,
.cal-drawer-body textarea:focus-visible,
.cal-drawer-body select:focus,
.cal-drawer-body select:focus-visible,
.smart-drawer .input:focus,
.smart-drawer .input:focus-visible,
.smart-drawer textarea:focus,
.smart-drawer textarea:focus-visible,
.smart-drawer select:focus,
.smart-drawer select:focus-visible {
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: none !important;
  outline: none !important;
}

.cal-drawer-body .input::placeholder {
  color: var(--color-text-tertiary);
  opacity: 0.5;
}

.cal-drawer-body select.input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23697a8d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Native date picker & select option theming */
.cal-drawer-body input[type="date"],
.cal-drawer-body input[type="time"] {
  accent-color: var(--color-text-primary);
  color-scheme: light;
}

.cal-drawer-body input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.cal-drawer-body input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 0.8;
}

/* Style select option highlight (limited browser support but progressive) */
.cal-drawer-body select.input option {
  padding: 8px 14px;
  font-size: 14px;
  font-family: var(--font-family);
}

.cal-drawer-body select.input option:checked {
  background: linear-gradient(0deg, var(--color-text-primary) 0%, var(--color-text-primary) 100%);
  color: #fff;
}

/* ═══════════════════════════════════════════
   Custom category dropdown (replaces native <select>)
   ═══════════════════════════════════════════ */
.custom-cat-select {
  position: relative;
  width: 100%;
}

/* Hide the native select when custom is active */
.custom-cat-select + select.input,
select.input.custom-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

/* Trigger button (looks like input) */
.custom-cat-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  min-height: 44px; /* 44px touch target */
  border-radius: var(--radius-md);
  background: var(--color-card);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23697a8d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.custom-cat-trigger:hover {
  border-color: rgba(0, 0, 0, 0.08);
}

.custom-cat-trigger:focus,
.custom-cat-trigger.open {
  box-shadow: none;
  outline: none;
}

.custom-cat-trigger:focus-visible {
  outline: none;
}

.custom-cat-trigger:active {
  transform: scale(0.995);
}

.custom-cat-trigger .cat-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

/* Chevron rotation when open */
.custom-cat-trigger.open {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23697a8d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7.5 6 4.5 9 7.5'/%3E%3C/svg%3E");
}

/* Dropdown panel */
.custom-cat-options {
  position: fixed;
  background: var(--color-card);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  z-index: 10000;
  overflow: hidden;
  overflow-y: auto;
  max-height: 70vh;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.custom-cat-options.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Individual option */
.custom-cat-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-height: 44px; /* 44px touch target */
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
}

.custom-cat-option:hover {
  background: rgba(0, 0, 0, 0.04);
}

.custom-cat-option.selected {
  background: rgba(0, 0, 0, 0.07);
  font-weight: 600;
}

.custom-cat-option .cat-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.custom-cat-option:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.custom-cat-option:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }

/* --- Inline category creation in dropdown --- */
.custom-cat-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 44px; /* 44px touch target */
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.custom-cat-add-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}
.custom-cat-add-icon {
  font-size: 16px;
  font-weight: 650;
  line-height: 1;
}

.custom-cat-add-form {
  padding: 10px 14px 12px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
}
.custom-cat-add-form input.custom-cat-add-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px; /* 44px touch target */
  min-height: 44px;
  font-size: 14px;
  font-family: var(--font-family);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  outline: none;
  background: transparent;
  color: var(--color-text-primary);
  transition: border-color 0.15s ease;
}
.custom-cat-add-form input.custom-cat-add-input:focus {
  box-shadow: none;
}

.custom-cat-add-form input.custom-cat-add-input:focus-visible {
  outline: none;
}

.custom-cat-add-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.custom-cat-add-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  position: relative;
}

/* Invisible touch expander — 44px tap area around 28px swatch */
.custom-cat-add-swatch::before {
  content: '';
  position: absolute;
  inset: -8px; /* (44 - 28) / 2 = 8px each side */
}
.custom-cat-add-swatch:hover {
  transform: scale(1.15);
}
.custom-cat-add-swatch.selected {
  border-color: var(--color-text-primary, #333);
  transform: scale(1.1);
}

.custom-cat-add-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.custom-cat-add-actions button {
  padding: 10px 16px; /* 44px touch target */
  min-height: 44px;
  font-size: 13px;
  font-family: var(--font-family);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.custom-cat-add-actions .custom-cat-add-create {
  background: var(--color-text-primary);
  color: #fff;
  font-weight: 600;
}
.custom-cat-add-actions .custom-cat-add-create:hover {
  opacity: 0.88;
}
.custom-cat-add-actions .custom-cat-add-cancel {
  background: var(--color-bg);
  color: var(--color-text-secondary, rgb(60, 60, 58));
}
.custom-cat-add-actions .custom-cat-add-cancel:hover {
  background: rgba(0,0,0,0.09);
}

/* ── Dark mode ── */
[data-theme="dark"] .custom-cat-trigger {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .custom-cat-trigger:hover {
  border-color: rgba(255,255,255,0.15);
}
[data-theme="dark"] .custom-cat-options {
  position: fixed;
  background: var(--color-card);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
[data-theme="dark"] .custom-cat-option:hover {
  background: rgba(255,255,255,0.06);
}
[data-theme="dark"] .custom-cat-option.selected {
  background: rgba(var(--color-primary-rgb, 105,108,255), 0.15);
}

/* Dark mode — inline category creation */
[data-theme="dark"] .custom-cat-add-btn {
  border-top-color: rgba(255,255,255,0.06);
  color: var(--color-text-primary);
}
[data-theme="dark"] .custom-cat-add-btn:hover {
  background: rgba(0, 0, 0, 0.07);
}
[data-theme="dark"] .custom-cat-add-form {
  border-top-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .custom-cat-add-form input.custom-cat-add-input {
  border-color: rgba(255,255,255,0.12);
  color: #e0e0e0;
}
[data-theme="dark"] .custom-cat-add-form input.custom-cat-add-input:focus {
  
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .custom-cat-add-swatch.selected {
  border-color: rgba(255,255,255,0.7);
}
[data-theme="dark"] .custom-cat-add-actions .custom-cat-add-cancel {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6);
}
[data-theme="dark"] .custom-cat-add-actions .custom-cat-add-cancel:hover {
  background: rgba(255,255,255,0.1);
}

/* Toggle — match blue accent */
.cal-drawer-body .toggle input {
  accent-color: var(--color-text-primary);
}

.cal-drawer-body textarea.input {
  resize: vertical;
  min-height: 72px;
}

/* Date row */
.cal-drawer-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Time row — animated slide via max-height */
.cal-drawer-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              margin-bottom 0.3s ease;
}

.cal-drawer-times.time-row-visible {
  max-height: 90px;
  opacity: 1;
  margin-bottom: 4px;
}

/* Recurrence edit scope radio */
.cal-recurrence-scope {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.04);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 12px;
}

.cal-recurrence-scope-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.cal-recurrence-scope-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text-primary);
  cursor: pointer;
  padding: 4px 0;
}

.cal-recurrence-scope-option input[type="radio"] {
  accent-color: var(--color-text-primary);
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .cal-recurrence-scope {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.cal-drawer-times .input[type="time"] {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cal-drawer-times .input[type="time"]:hover {
  border-color: rgba(0, 0, 0, 0.08);
}

.cal-drawer-times .input[type="time"]:focus {
  box-shadow: none;
  background: var(--color-card);
  outline: none;
}

.cal-drawer-times .input[type="time"]:focus-visible {
  outline: none;
}

/* Toggle — spring bounce on the knob */
.cal-drawer-body .toggle {
  margin-bottom: 14px;
  padding: 2px 0;
}

.cal-drawer-body .toggle-track::after {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cal-drawer-body .toggle-track {
  transition: background 0.2s ease;
}

.cal-drawer-body .toggle:active .toggle-track::after {
  width: 24px;
}

/* Drawer footer */
.cal-drawer-footer {
  padding: 16px 24px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-drawer-footer .btn {
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  padding: 0 24px;
  height: 44px;       /* 44px touch target */
  min-height: 44px;
  transition: all 0.15s ease;
}

.cal-drawer-footer .btn-primary {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.cal-drawer-footer .btn-primary:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-0.5px);
}

.cal-drawer-footer .btn-primary:active {
  transform: translateY(0) scale(0.95);
  box-shadow: none;
  transition: transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cal-drawer-footer .btn-secondary:active {
  transform: scale(0.95);
  transition: transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cal-drawer-footer .btn-secondary {
  background: transparent;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  color: var(--color-text-primary);
}

.cal-drawer-footer .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--color-text-primary);
}

.cal-drawer-footer .btn-delete {
  margin-left: auto;
  background: transparent;
  color: var(--color-error);
  border: 0.5px solid transparent;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px; /* 44px touch target */
  min-height: 44px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cal-drawer-footer .btn-delete:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-error);
  border-color: transparent;
}


/* ════════════════════════════════════════════════════════════
   DRAWER INLINE ERROR
   ════════════════════════════════════════════════════════════ */

.cal-drawer-error {
  background: var(--color-error-light);
  color: #d4331a;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
}

.cal-drawer-error.active {
  display: block;
}

/* ════════════════════════════════════════════════════════════
   DRAWER CONFLICT WARNING (amber/warning variant)
   ════════════════════════════════════════════════════════════ */

.cal-drawer-warning {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
  line-height: 1.4;
}

.cal-drawer-warning.active {
  display: block;
}

/* Conflict alternative slot suggestions */
.cal-conflict-suggestions {
  margin-bottom: 12px;
}

.cal-conflict-suggest-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  margin: 8px 0 6px;
}

.cal-conflict-suggest-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cal-conflict-suggest-btn {
  padding: 10px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 22px;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px; /* 44px touch target */
  white-space: nowrap;
}

.cal-conflict-suggest-btn:hover {
  border-color: var(--color-text-primary);
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .cal-conflict-suggest-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .cal-conflict-suggest-btn:hover {
  background: rgba(var(--color-primary-rgb, 105, 108, 255), 0.1);
}

/* ════════════════════════════════════════════════════════════
   DRAWER UX POLISH — Validation, delete confirm, char count, category dot
   ════════════════════════════════════════════════════════════ */

/* ── 1. Form validation: red border + shake ── */
.cal-drawer-body .input.input-error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

@keyframes drawer-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

.cal-drawer-body .input.shake {
  animation: drawer-shake 0.45s ease;
}

/* ── 2. Delete button confirmation state ── */
.cal-drawer-footer .btn-delete.btn-delete-confirm {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  border: 0.5px solid rgba(239, 68, 68, 0.3);
  font-weight: 600;
}

/* ── 3. Category color dot ── */
.cat-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4A90E2;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
  vertical-align: middle;
  margin-left: 2px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

/* ── 4. Character count hint ── */
.char-count {
  display: block;
  font-size: 11px;
  color: var(--color-text-tertiary);
  text-align: right;
  margin-top: 4px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}

.char-count.char-count-visible {
  opacity: 1;
  max-height: 20px;
}

.char-count.char-count-danger {
  color: var(--color-error);
  font-weight: 600;
}

/* ── 5. Save button disabled state polish ── */
.cal-drawer-footer .btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════
   SMART DRAWER — AI-Powered Natural Language Event Creation
   Appended to kalender.css (v15)
   ════════════════════════════════════════════════════════════ */

/* ── 1. NL Input Group — textarea replaces title input in create mode ── */

.smart-drawer-nl-group .smart-drawer-nl-input {
  min-height: 64px;
  resize: none;
  line-height: 1.5;
  font-size: 15px;
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.15s ease;
  accent-color: var(--color-text-primary);
}

.smart-drawer-nl-group .smart-drawer-nl-input::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

.smart-drawer-nl-group .smart-drawer-nl-input:hover {
  border-color: rgba(0, 0, 0, 0.08);
}

.smart-drawer-nl-group .smart-drawer-nl-input:focus {
  box-shadow: none;
  background: var(--color-card);
  outline: none;
}

.smart-drawer-nl-group .smart-drawer-nl-input:focus-visible {
  outline: none;
}

/* When NL mode is active — no special border, clean */
.smart-drawer-nl-group.nl-active .smart-drawer-nl-input {
  border-color: rgba(0, 0, 0, 0.08);
}


/* ── 2. NL Hint Text — helper below textarea, visible only in NL mode ── */

/* Drawer mic — sits in label row */
.cal-drawer-mic {
  width: 44px;  /* 44px touch target */
  height: 44px;
  border-radius: var(--radius-md);
  margin-left: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-drawer-mic svg {
  width: 16px;
  height: 16px;
}

.smart-drawer-nl-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 6px;
  line-height: 1.4;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, max-height 0.25s ease, margin 0.25s ease;
}

.smart-drawer-nl-group.nl-active .smart-drawer-nl-hint {
  opacity: 1;
  max-height: 40px;
}


/* ── 3. AI Loading Spinner — inline CSS-only spinner ── */

.smart-drawer-ai-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--color-text-primary);
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.smart-drawer-ai-spinner.active {
  opacity: 1;
  transform: scale(1);
  animation: smart-drawer-spin 0.7s linear infinite;
}

@keyframes smart-drawer-spin {
  to { transform: rotate(360deg); }
}


/* ── 4. AI Field Badges — inline confidence indicators next to labels ── */

.ai-field-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 6px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
  vertical-align: middle;
}

.ai-field-badge.active {
  opacity: 1;
  transform: scale(1);
}

/* High confidence — solid, trustworthy */
.ai-field-badge--high {
  background: rgba(0, 0, 0, 0.08);
  color: rgb(19, 19, 19);
}

/* Inferred/guessed — needs user attention */
.ai-field-badge--inferred {
  background: rgba(255, 171, 0, 0.12);
  color: #a67200;
}


/* ── 5. Field Fill Animation — subtle flash when AI populates a field ── */

.cal-drawer-body .input.ai-just-filled {
  animation: smart-drawer-field-flash 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes smart-drawer-field-flash {
  0%   { background-color: rgba(0, 0, 0, 0.07); }
  100% { background-color: transparent; }
}


/* ── 6. Progressive Disclosure — collapsible advanced fields ── */

.smart-drawer-details-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 0;
  margin: 4px 0 0;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s ease;
}

.smart-drawer-details-toggle:hover {
  color: var(--color-text-primary);
}

.smart-drawer-details-toggle svg {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.smart-drawer-details-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.smart-drawer-details-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.smart-drawer-details-body.expanded {
  max-height: 600px;
  opacity: 1;
}


/* ── 7. Summary Preview — card showing what will be created ── */

.smart-drawer-preview {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.04);
  border: 0.5px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--color-text-primary);
  transition: opacity 0.3s ease;
}

.smart-drawer-preview-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.smart-drawer-preview-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}

.smart-drawer-preview-text {
  line-height: 1.4;
}


/* ── 8. Inline Messages — chat/clarify responses below textarea ── */

.smart-drawer-inline-msg {
  font-size: 13px;
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.04);
  border: 0.5px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-top: 8px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.smart-drawer-inline-msg.visible {
  opacity: 1;
  transform: translateY(0);
}



/* ════════════════════════════════════════════════════════════
   TIME SELECT, DATE CHIPS, FLATPICKR — Drawer form enhancements
   ════════════════════════════════════════════════════════════ */

/* ── Time select (replaces native time input) ── */
.smart-drawer select.time-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 48px;
  padding: 10px 36px 10px 14px;
  font-family: var(--font-family);
  font-size: 16px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  background: var(--color-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  background-size: 12px;
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.smart-drawer select.time-select:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

.smart-drawer select.time-select:focus-visible {
  outline: none;
}

/* ── Date quick-pick chips ── */
.date-chips,
.smart-drawer .date-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px 0;
  padding: 0;
}
.date-chip,
.smart-drawer .date-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  background: var(--color-bg, #f8f8f6);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 17px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  min-height: 44px; /* touch target */
  user-select: none;
}
.date-chip:hover,
.smart-drawer .date-chip:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--color-text-primary, rgb(19, 19, 19));
}
.date-chip.active,
.smart-drawer .date-chip.active {
  background: var(--color-text-primary);
  color: #fff;
  border-color: var(--color-text-primary);
}

/* ── flatpickr visible input inside drawer ── */
.smart-drawer .flatpickr-input {
  width: 100%;
  height: 48px;
  padding: 10px 14px;
  font-family: var(--font-family);
  font-size: 16px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  background: var(--color-card);
  color: var(--color-text-primary);
  cursor: pointer;
}
.smart-drawer .flatpickr-input:focus {
  outline: none;
  box-shadow: none;
}

.smart-drawer .flatpickr-input:focus-visible {
  outline: none;
}

/* ── Dark mode: time select, date chips, flatpickr ── */
[data-theme="dark"] .smart-drawer select.time-select {
  background-color: #2a2a3c;
  border-color: #3a3a4c;
  color: #e0e0e0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
[data-theme="dark"] .date-chip,
[data-theme="dark"] .smart-drawer .date-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}
[data-theme="dark"] .date-chip:hover,
[data-theme="dark"] .smart-drawer .date-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}
[data-theme="dark"] .date-chip.active,
[data-theme="dark"] .smart-drawer .date-chip.active {
  background: var(--color-text-primary);
  color: #fff;
}
[data-theme="dark"] .smart-drawer .flatpickr-input {
  background: #2a2a3c;
  border-color: #3a3a4c;
  color: #e0e0e0;
}

@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .cal-drawer {
    width: 100%;
    height: auto;
    max-height: 85dvh;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  .cal-drawer-overlay.active .cal-drawer {
    transform: translateY(0);
  }

  .cal-drawer::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
}

@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  .cal-drawer {
    width: 380px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cal-drawer *,
  .smart-drawer * {
    animation: none !important;
    transition: none !important;
  }
}
