/* ===== PLANOWIEC — Global Styles ===== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0d9488;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;

  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --sidebar-text: #93a3c2;
  --sidebar-text-active: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 8px 24px rgba(0,0,0,.10);
  --transition: .16s ease;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

/* ===== DARK MODE ===== */
html[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59,130,246,.16);
  --secondary: #2dd4bf;
  --success: #22c55e;
  --danger: #f87171;
  --warning: #fbbf24;
  --info: #38bdf8;

  --bg: #0b1220;
  --bg-card: #131b2c;
  --bg-sidebar: #070c17;
  --bg-sidebar-hover: #1a2436;
  --sidebar-text: #8291b3;
  --sidebar-text-active: #ffffff;
  --border: #23304a;
  --text: #e5eaf5;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --shadow: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
}

html[data-theme="dark"] .auth-wrapper {
  background: linear-gradient(135deg, #0b1220, #131b2c);
}

html[data-theme="dark"] .badge-success { background: rgba(34,197,94,.16); }
html[data-theme="dark"] .btn-secondary:hover { background: #1a2436; }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: 1.05rem;
  transition: background var(--transition), border-color var(--transition);
}
.theme-toggle:hover { background: var(--bg); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo a { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: #fff; letter-spacing: -.3px; }
.sidebar-logo .logo-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.sidebar-nav .nav-item:hover { background: var(--bg-sidebar-hover); color: var(--sidebar-text-active); }
.sidebar-nav .nav-item.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-section-title {
  padding: 16px 12px 6px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-light); font-weight: 600;
}

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user .avatar { width: 34px; height: 34px; font-size: .82rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { color: #fff; font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info .username { color: var(--text-light); font-size: .75rem; }
.sidebar-logout { color: var(--text-light); font-size: 1.1rem; }
.sidebar-logout:hover { color: var(--danger); }

.main-content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 100;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; color: var(--text); }

.page { padding: 24px; flex: 1; }

/* ===== AVATAR ===== */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex-shrink: 0;
}

/* ===== CARDS ===== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: 1.02rem; font-weight: 700; }
.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .88rem; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #edf1f7; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .78rem; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; background: var(--bg-card); color: var(--text); transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ===== BADGES / CHIPS ===== */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: .76rem; font-weight: 600;
}
.type-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #ecfdf5; color: var(--success); }
.badge-muted { background: var(--bg); color: var(--text-muted); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data-table th { text-align: left; padding: 10px 16px; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
table.data-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }

/* ===== FOOTER ===== */
.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted);
}
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--primary); text-decoration: underline; }
.app-footer-guest { max-width: 420px; margin: 0 auto; border-top: none; justify-content: center; gap: 20px; }

/* ===== ANNOUNCEMENTS ===== */
.announcement { border-radius: var(--radius-sm); padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid; margin-bottom: 8px; }
.announcement-info { background: var(--primary-light); border-color: var(--primary); }
.announcement-warning { background: #fef3c7; border-color: var(--warning); }
.announcement-danger { background: #fee2e2; border-color: var(--danger); }
.announcement-success { background: #ecfdf5; border-color: var(--success); }
.announcement .icon { flex-shrink: 0; font-size: 1.05rem; }
.announcement .title { font-weight: 700; font-size: .88rem; }
.announcement .body { font-size: .83rem; opacity: .85; margin-top: 2px; }

/* ===== ALERTS / FLASH ===== */
.flash-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .86rem; box-shadow: var(--shadow-md); border-left: 4px solid; background: var(--bg-card); }
.alert-success { border-color: var(--success); }
.alert-danger { border-color: var(--danger); }
.alert-info { border-color: var(--info); }
.alert-warning { border-color: var(--warning); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 2.2rem; margin-bottom: 10px; }

/* ===== AUTH PAGES ===== */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef2ff, #f5f7fb); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 32px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; font-weight: 800; font-size: 1.4rem; }
.auth-logo .logo-icon { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; }
.auth-footer { text-align: center; margin-top: 18px; font-size: .86rem; color: var(--text-muted); }

/* ===== CALENDAR ===== */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.calendar-nav { display: flex; align-items: center; gap: 6px; }
.calendar-title { font-size: 1.1rem; font-weight: 700; min-width: 180px; text-align: center; }
.calendar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.type-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.type-filter-item { display: inline-flex; align-items: center; gap: 2px; }
.type-filter {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--border); font-size: .8rem; font-weight: 600; background: var(--bg-card);
  color: var(--text-muted); transition: all var(--transition);
}
.type-filter.active { border-color: transparent; color: #fff; }
.type-filter .add-type-btn { border-style: dashed; }
.type-filter-tool {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); font-size: .74rem;
  transition: all var(--transition); flex-shrink: 0;
}
.type-filter-tool:hover { background: var(--bg); color: var(--text); }
.type-filter-tool-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.calendar-weekday { text-align: center; font-size: .74rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding-bottom: 6px; }
.calendar-day {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: box-shadow var(--transition), border-color var(--transition);
}
.calendar-day:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.calendar-day.outside { opacity: .4; }
.calendar-day.today { border-color: var(--primary); border-width: 2px; }
.calendar-day-num { font-size: .8rem; font-weight: 700; }
.calendar-day.today .calendar-day-num { color: var(--primary); }
.calendar-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.calendar-event-chip {
  font-size: .68rem; padding: 2px 6px; border-radius: 5px; color: #fff; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calendar-event-more { font-size: .68rem; color: var(--text-muted); font-weight: 600; padding-left: 4px; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none;
  align-items: center; justify-content: center; z-index: 500; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius); width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.02rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.2rem; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.readonly-banner {
  background: var(--primary-light); color: var(--primary); padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ===== LISTS (friends / groups) ===== */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item-info { flex: 1; min-width: 0; }
.list-item-name { font-weight: 600; font-size: .92rem; }
.list-item-sub { font-size: .78rem; color: var(--text-muted); }
.list-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: .88rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-color: var(--primary); }

.code-display {
  font-family: 'Courier New', monospace; font-size: 1.3rem; font-weight: 700; letter-spacing: 1px;
  background: var(--primary-light); color: var(--primary); padding: 12px 18px; border-radius: var(--radius-sm);
  text-align: center; margin: 12px 0;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ===== SEARCH ===== */
.search-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.search-bar .form-control { flex: 1; }

/* ===== ERROR PAGE ===== */
.error-wrapper { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .calendar-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .calendar-day { min-height: 70px; padding: 4px; }
  .calendar-day-num { font-size: .72rem; }
  .calendar-event-chip { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
  .calendar-weekday { font-size: .62rem; }
  .page { padding: 14px; }
  .calendar-title { min-width: 0; font-size: 1rem; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
}
