/* =========================================================
   iCal Builder — style.css
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --transition: 0.18s ease;

  /* Light */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e0e2ea;
  --text: #1a1d27;
  --text-2: #5a5f72;
  --accent: #4f6ef7;
  --accent-hover: #3a59e8;
  --danger: #e03e3e;
  --success: #2db784;
  --preview-bg: #1e2030;
  --preview-text: #cdd6f4;
}

[data-theme='dark'] {
  --bg: #1a1d27;
  --surface: #24283b;
  --surface-2: #2a2f45;
  --border: #3b4060;
  --text: #cdd6f4;
  --text-2: #a6adc8;
  --accent: #7aa2f7;
  --accent-hover: #9cbcff;
  --danger: #f38ba8;
  --success: #a6e3a1;
  --preview-bg: #141522;
  --preview-text: #cdd6f4;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

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

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

/* ---------- App shell ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header__logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.app-header__subtitle {
  color: var(--text-2);
  font-size: 12px;
}

.app-header__spacer {
  flex: 1;
}

.app-header__actions {
  display: flex;
  gap: 8px;
}

/* ---------- Main layout ---------- */
.app-body {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(300px, 560px);
  gap: 0;
  height: calc(100vh - 53px);
}

.panel {
  overflow-y: auto;
  padding: 20px;
}

.panel--left {
  border-right: 1px solid var(--border);
}

.panel--right {
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* ---------- Section headings ---------- */
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-2);
  margin-bottom: 10px;
}

/* ---------- Calendar name row ---------- */
.calendar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.calendar-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.calendar-row input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

/* ---------- Events container ---------- */
.events-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.events-empty {
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ---------- Event card ---------- */
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.event-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.event-card__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
}

.event-card > .field,
.event-card > .field-row,
.event-card > .recurrence-wrapper {
  padding: 10px 14px 0;
}

.event-card > .field:last-of-type,
.event-card > .field-row:last-of-type,
.event-card > .recurrence-wrapper:last-of-type {
  padding-bottom: 14px;
}

/* ---------- Fields ---------- */
.field {
  margin-bottom: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.field--inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

.field__input,
.field__select,
.field__textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition);
}

.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  border-color: var(--accent);
}

.field__textarea {
  resize: vertical;
  min-height: 60px;
}

.field__checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.field__input--short {
  width: 80px;
}

.field__input[type='date'],
.field__input[type='time'] {
  cursor: pointer;
}

/* ---------- Recurrence ---------- */
.recurrence-wrapper > .field__label {
  margin-bottom: 6px;
}

.recurrence-extra {
  margin-top: 8px;
}

.recurrence-end-value {
  margin-top: 6px;
}

/* ---------- Upload/paste section ---------- */
.upload-section {
  margin-top: 24px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.drop-zone--over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.drop-zone__hint {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.drop-zone label {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  text-decoration: underline;
}

#file-input {
  display: none;
}

#paste-area {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 8px 10px;
  min-height: 80px;
  resize: vertical;
  outline: none;
  margin-top: 8px;
  transition: border-color var(--transition);
}

#paste-area:focus {
  border-color: var(--accent);
}

/* ---------- Preview panel ---------- */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-2);
}

#ics-preview {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre;
  overflow: auto;
  flex: 1;
  padding: 16px;
  background: var(--preview-bg);
  color: var(--preview-text);
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--small {
  font-size: 11px;
  padding: 4px 10px;
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn--danger:hover {
  background: var(--danger);
  color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app-body {
    grid-template-columns: 1fr;
    height: auto;
  }

  .panel--left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel--right {
    height: 400px;
  }

  #ics-preview {
    font-size: 10px;
  }
}
