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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.logo-icon { width: 32px; height: 32px; flex-shrink: 0; }

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 7px;
  padding: .4rem .85rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-primary  { background: #2563eb; color: #fff; }
.btn-primary:hover  { background: #1d4ed8; }

.btn-outline {
  background: transparent;
  color: #374151;
  border: 1px solid #d1d5db;
}
.btn-outline:hover { background: #f3f4f6; }

.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover { background: #f3f4f6; color: #374151; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.hidden { display: none !important; }

/* ── Main calendar area ───────────────────────────────────────────────────── */
main {
  flex: 1;
  overflow: hidden;
  padding: 1rem 1.25rem;
  min-height: 0;
}

#calendar {
  height: 100%;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: .75rem;
}

/* ── FullCalendar overrides ───────────────────────────────────────────────── */
.fc-toolbar-title {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
}

.fc-button {
  background: transparent !important;
  color: #374151 !important;
  border: 1px solid #d1d5db !important;
  border-radius: 6px !important;
  font-size: .8rem !important;
  font-weight: 600 !important;
  text-transform: capitalize !important;
  padding: .3rem .65rem !important;
  box-shadow: none !important;
  transition: background .12s !important;
}
.fc-button:hover, .fc-button:focus {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
.fc-button-active, .fc-button-primary:not(:disabled).fc-button-active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}
.fc-button-group .fc-button { border-radius: 0 !important; }
.fc-button-group .fc-button:first-child { border-radius: 6px 0 0 6px !important; }
.fc-button-group .fc-button:last-child  { border-radius: 0 6px 6px 0 !important; }

.fc-event {
  border-radius: 4px !important;
  border: none !important;
  font-size: .8rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
}

.fc-daygrid-event-dot { display: none; }

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 1rem;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem .9rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  padding: .1rem .35rem;
  border-radius: 4px;
}
.modal-close:hover { background: #f3f4f6; color: #374151; }

#event-form, .modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.footer-right { display: flex; gap: .5rem; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-row { margin-bottom: .9rem; }
.form-row:last-child { margin-bottom: 0; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: .3rem;
}

.required { color: #ef4444; }

input[type=text],
input[type=datetime-local],
input[type=date],
input[type=file],
textarea,
select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  padding: .5rem .7rem;
  font-size: .9rem;
  font-family: inherit;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color .15s;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 400;
  cursor: pointer;
}

.checkbox-label input[type=checkbox] { width: auto; accent-color: #2563eb; }

/* ── Import ───────────────────────────────────────────────────────────────── */
.import-steps {
  padding-left: 1.25rem;
  font-size: .9rem;
  line-height: 1.8;
  color: #374151;
}
.import-steps code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: .1rem .35rem;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: .8rem;
}

.import-result {
  margin-top: .75rem;
  padding: .6rem .85rem;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
}
.import-result.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.import-result.error   { background: #fef2f2; color: #dc2626;  border: 1px solid #fca5a5; }

/* ── CalDAV info table ────────────────────────────────────────────────────── */
.caldav-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.caldav-table td {
  padding: .45rem .5rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.caldav-table td:first-child { color: #6b7280; width: 38%; }
.monospace { font-family: 'SF Mono', Consolas, monospace; font-size: .85rem; }
