/* CalendarHub – stylesheet */
:root {
  --bg:      #f0f2f5;
  --surface: #ffffff;
  --border:  #dde1e7;
  --primary: #4a6cf7;
  --primary-dark: #3a5bd9;
  --danger:  #e74c3c;
  --success: #27ae60;
  --text:    #1a1d23;
  --muted:   #6b7280;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar .logo { font-size: 1.2rem; font-weight: 700; color: var(--primary); flex: 1; }
.topbar nav a { margin-left: 1.5rem; color: var(--muted); font-size: .9rem; }
.topbar nav a:hover { color: var(--primary); text-decoration: none; }
.sync-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 3px;
  position: relative;
  top: -1px;
}
.sync-dot-ok      { background: var(--success); }
.sync-dot-error   { background: var(--danger); }
.sync-dot-pending { background: #f39c12; }

/* ── Main layout ────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; color: var(--muted); }
.cb-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .9rem; font-weight: 400; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .95rem;
  color: var(--text);
  background: #fafbfc;
  transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
.form-group .hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border: none;
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none !important;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cdd1d9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; }
.btn-google { background: #4285f4; color: #fff; }
.btn-google:hover { background: #3574d4; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 7px;
  margin-bottom: 1.25rem;
  font-size: .9rem;
  border-left: 4px solid;
}
.alert-success { background: #edfaf3; border-color: var(--success); color: #1a5e35; }
.alert-error   { background: #fdf0ee; border-color: var(--danger);  color: #7f1d1d; }
.alert-info    { background: #eef2ff; border-color: var(--primary);  color: #1e3a8a; }

/* ── Calendar source list ───────────────────────────────────── */
.source-list { display: flex; flex-direction: column; gap: .75rem; }
.source-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}
.source-color {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.source-info { flex: 1; min-width: 0; }
.source-name { font-weight: 500; font-size: .95rem; }
.source-meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.badge-local     { background: #e0e7ff; color: #3730a3; }
.badge-ical      { background: #fef3c7; color: #92400e; }
.badge-google    { background: #dbeafe; color: #1e40af; }
.badge-apple     { background: #f3e8ff; color: #6b21a8; }
.badge-nextcloud { background: #d1fae5; color: #065f46; }
.badge-caldav    { background: #ffe4e6; color: #881337; }
.badge-ro        { background: #f1f5f9; color: #64748b; }

/* ── Event count pill ───────────────────────────────────────── */
.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  flex-shrink: 0;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: .3rem .5rem;
  line-height: 1.2;
}
.stat-num   { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Sync time ──────────────────────────────────────────────── */
.sync-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 62px;
  flex-shrink: 0;
  font-size: .78rem;
  line-height: 1.4;
}
.sync-label { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.sync-val   { font-weight: 500; color: var(--text); }

/* ── Badge column ───────────────────────────────────────────── */
.badge-col { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; flex-shrink: 0; }

/* ── Connection info box ────────────────────────────────────── */
.connection-box {
  background: #f8f9ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  font-size: .88rem;
}
.connection-box strong { display: block; margin-bottom: .5rem; color: var(--primary); }
.connection-box code {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .45rem .75rem;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: .85rem;
  word-break: break-all;
  margin: .35rem 0;
  cursor: text;
}

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.75rem; }

/* ── Misc ───────────────────────────────────────────────────── */
.flex-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.mt1 { margin-top: .75rem; }
.mt2 { margin-top: 1.5rem; }
h2 { font-size: 1.3rem; margin-bottom: 1rem; }
hr  { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--muted); font-size: .88rem; }

/* ── Language switcher ──────────────────────────────────────── */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  margin-left: 1.25rem;
  font-size: .8rem;
  color: var(--muted);
}
.lang-switch a {
  color: var(--muted);
  padding: .1rem .25rem;
  border-radius: 3px;
}
.lang-switch a:hover { color: var(--primary); text-decoration: none; }
.lang-switch a.lang-active { color: var(--primary); font-weight: 700; }
.lang-switch .lang-sep { color: var(--border); }


/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Topbar: logo + scrollable nav */
  .topbar { padding: 0 .75rem; height: auto; min-height: 56px; flex-wrap: wrap; gap: 0; }
  .topbar .logo { font-size: 1rem; padding: .5rem 0; }
  .topbar nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: .35rem 0 .45rem;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { margin-left: .75rem; white-space: nowrap; font-size: .82rem; }
  .topbar nav a:first-child { margin-left: 0; }
  .lang-switch { margin-left: .75rem; }

  /* Layout */
  .container { padding: 0 .75rem; margin: 1rem auto; }
  .card { padding: 1.25rem; }

  /* Source list */
  .source-item { flex-wrap: wrap; gap: .5rem; }
  .source-actions { flex-wrap: wrap; }

  /* Stat pill & sync time: smaller on mobile */
  .stat-pill { min-width: 44px; padding: .25rem .4rem; }
  .stat-num  { font-size: .95rem; }
  .sync-time { min-width: 50px; }

  /* Tables: horizontal scroll */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modals */
  .modal { margin: .75rem; padding: 1.25rem; }

  /* Auth pages */
  .auth-card { padding: 1.75rem 1.25rem; }

  /* Buttons */
  .flex-row { gap: .5rem; }
}
