@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

/* ---------- THEME: DARK (default) ---------- */
body.theme-dark {
  --bg: #0f1117;
  --bg-elevated: #161923;
  --bg-card: #1a1e2b;
  --bg-hover: #232838;
  --border: #2a3040;
  --text: #eef0f5;
  --text-muted: #9199ac;
  --accent: #6c8cff;
  --accent-2: #8f6cff;
  --accent-soft: rgba(108,140,255,.15);
  --success: #3ecf8e;
  --warning: #f5a623;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* ---------- THEME: LIGHT ---------- */
body.theme-light {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef1f8;
  --border: #e1e5f0;
  --text: #1b1e27;
  --text-muted: #6b7280;
  --accent: #4c6fff;
  --accent-2: #7b4cff;
  --accent-soft: rgba(76,111,255,.10);
  --success: #23a970;
  --warning: #d3860c;
  --danger: #e5484d;
  --shadow: 0 10px 30px rgba(20,30,60,.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: 'SF Mono', Consolas, Menlo, monospace; font-size: 13.5px; line-height: 1.6; }

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }

/* ---------- LAYOUT SHELL ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 22px;
  font-weight: 700;
  font-size: 16px;
}
.brand-icon { font-size: 22px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14.5px;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-footer { padding: 10px; }

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}
.topbar-title { font-size: 19px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; font-size: 13.5px; font-weight: 500; }
.user-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

.icon-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background var(--transition), transform var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.small { width: 28px; height: 28px; font-size: 13px; }

.mobile-only { display: none; }

/* ---------- CONTENT GRID ---------- */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  padding: 22px 26px 60px;
  align-items: start;
}
.center-col { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.section-header h3 { margin: 0; font-size: 16px; }
.filters { display: flex; gap: 8px; }
.filters input, .filters select { width: auto; min-width: 160px; }

/* ---------- BUTTONS ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  transition: transform var(--transition), filter var(--transition), background var(--transition);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ---------- COMPOSER ---------- */
.composer-tabs, .slot-type-toggle, .editor-toolbar { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn, .chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition);
}
.tab-btn.active, .chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; margin-bottom: 5px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; }
.editor-row textarea { width: 100%; }
.markdown-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 160px;
  background: var(--bg-elevated);
  font-size: 14px;
  line-height: 1.65;
}
.markdown-preview img { max-width: 100%; }
.markdown-preview pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; }
.markdown-preview code { background: var(--bg); padding: 2px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---------- ENTRIES LIST ---------- */
.entries-list { display: flex; flex-direction: column; gap: 10px; }
.entries-list-full { max-height: none; }
.entry-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.entry-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.entry-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.entry-item-title { font-weight: 600; font-size: 14.5px; }
.entry-item-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.badge-time { background: rgba(245,166,35,.15); color: var(--warning); }
.badge.badge-loc { background: rgba(62,207,142,.15); color: var(--success); }

/* ---------- RIGHT PANEL ---------- */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 78px;
}
.rp-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.week-nav { display: flex; align-items: center; justify-content: space-between; }
.week-info { text-align: center; }
.week-no { font-weight: 700; font-size: 15px; }
.week-days { display: flex; gap: 6px; justify-content: space-between; }
.week-day {
  flex: 1;
  text-align: center;
  padding: 8px 2px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.week-day .wd-name { display: block; color: var(--text-muted); font-size: 10.5px; margin-bottom: 3px; }
.week-day .wd-num { font-weight: 700; font-size: 14px; }
.week-day:hover { background: var(--bg-hover); }
.week-day.is-today { border-color: var(--accent); background: var(--accent-soft); }
.week-day.is-selected { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.week-day.is-selected .wd-name { color: rgba(255,255,255,.85); }
.week-day.has-entries::after {
  content: '';
  display: block;
  width: 4px; height: 4px;
  background: var(--success);
  border-radius: 50%;
  margin: 3px auto 0;
}

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-label { font-weight: 700; font-size: 13.5px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.month-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: background var(--transition);
}
.month-cell.empty { cursor: default; }
.month-cell:not(.empty):hover { background: var(--bg-hover); }
.month-cell.is-today { color: var(--accent); font-weight: 700; }
.month-cell.is-selected { background: var(--accent); color: #fff; font-weight: 700; }
.month-cell.has-entries::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 3px; height: 3px;
  background: var(--success);
  border-radius: 50%;
}
.month-cell.is-selected.has-entries::after { background: #fff; }
.month-dow { text-align: center; font-size: 10px; color: var(--text-muted); padding-bottom: 4px; }

.hour-slots-header { font-weight: 700; font-size: 13.5px; margin-bottom: 10px; }
.hour-slots { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; }
.hour-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-top: 1px dashed var(--border);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition);
}
.hour-slot:first-child { border-top: none; }
.hour-slot:hover { background: var(--bg-hover); }
.hour-slot-time { font-size: 11.5px; color: var(--text-muted); width: 44px; flex-shrink: 0; }
.hour-slot-content { flex: 1; min-width: 0; font-size: 12.5px; }
.hour-slot-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.hour-slot-empty { color: var(--text-muted); font-style: italic; opacity: .55; }

/* ---------- MODALS ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,12,20,.55);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .18s ease;
}
.map-modal { max-width: 640px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }

.slot-item-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

/* ---------- LOGIN ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  text-align: center;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin: 6px 0 8px; }
.login-card p { margin-bottom: 24px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 16px; }

/* ---------- KANBAN ---------- */
.kanban-page { }
.kanban-toolbar { margin-bottom: 16px; }
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-column {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 280px;
  flex-shrink: 0;
  padding: 12px;
  box-shadow: var(--shadow);
}
.kanban-column-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 4px 6px; }
.kanban-column-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.column-dot { width: 9px; height: 9px; border-radius: 50%; }
.kanban-cards { min-height: 40px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition);
}
.kanban-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.kanban-card .kc-title { font-weight: 600; margin-bottom: 4px; }
.kanban-card .kc-desc { color: var(--text-muted); font-size: 12px; }
.sortable-ghost { opacity: .4; }
.kanban-add-card-btn { width: 100%; padding: 8px; margin-top: 6px; background: transparent; border: 1px dashed var(--border); border-radius: 8px; color: var(--text-muted); font-size: 12.5px; }
.kanban-add-card-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- REPORTS ---------- */
.report-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.report-table th, .report-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.report-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill { background: var(--accent-soft); color: var(--accent); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
  .content-grid { grid-template-columns: 1fr; }
  .right-panel { position: static; }
}

@media (max-width: 760px) {
  .mobile-only { display: inline-flex; position: fixed; top: 14px; left: 14px; z-index: 60; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 14px 16px 14px 62px; }
  .topbar-title { font-size: 16px; }
  .user-chip span { display: none; }
  .content-grid { padding: 16px; gap: 16px; }
  .card { padding: 16px; }
  .form-row.two-col { grid-template-columns: 1fr; }
  .kanban-column { width: 82vw; }
}
