/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #ff6b35;
  --push: #e74c3c;
  --pull: #3498db;
  --legs: #2ecc71;
  --swim: #00bcd4;
  --other: #9b59b6;
  --empty: #444;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.view { min-height: 100vh; }

/* === Login === */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text);
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-group select,
.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
  border-color: var(--accent);
}

.form-group select option {
  background: var(--surface2);
}

.error-msg {
  color: #e74c3c;
  font-size: 0.85rem;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover { opacity: 0.85; }

/* === Header === */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-logout:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* === Main / Week Grid === */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.week-grid {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Header Row */
.grid-header {
  background: var(--surface2);
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

/* Day label column */
.day-label {
  background: var(--surface);
  padding: 1rem;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* User cells */
.user-cell {
  background: var(--surface);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Partner cell with multiple badges */
.partner-badges {
  flex-direction: row;
  flex-wrap: wrap;
}

/* Activity badge (read-only) */
.activity-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
}

.badge-Gym      { background: rgba(255,107,53,0.2);  color: #ff6b35; }
.badge-Swim     { background: rgba(0,188,212,0.2);   color: #00bcd4; }
.badge-Rest     { background: rgba(241,196,15,0.2);  color: #f1c40f; }
.badge-Gesellschaftliche-Verpflichtungen { background: rgba(233,30,99,0.2);   color: #e91e63; }
.badge-custom   { background: rgba(155,89,182,0.2);  color: #9b59b6; }
.badge-empty    { background: rgba(68,68,68,0.2);    color: var(--text-muted); font-weight: 400; font-style: italic; }

/* Activity selector (own cells) */
.activity-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.act-btn {
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  background: var(--surface2);
  color: var(--text-muted);
}

.act-btn:hover { opacity: 0.85; transform: scale(1.04); }

.act-btn.active-Gym      { background: rgba(255,107,53,0.25);  color: #ff6b35;  border-color: #ff6b35; }
.act-btn.active-Swim     { background: rgba(0,188,212,0.25);   color: #00bcd4;  border-color: #00bcd4; }
.act-btn.active-Rest     { background: rgba(241,196,15,0.25);  color: #f1c40f;  border-color: #f1c40f; }
.act-btn.active-Gesellschaftliche-Verpflichtungen { background: rgba(233,30,99,0.25);   color: #e91e63;  border-color: #e91e63; }
.act-btn.active-Sonstiges { background: rgba(155,89,182,0.25); color: #9b59b6;  border-color: #9b59b6; }

.act-btn.active-clear  {
  background: rgba(68,68,68,0.2);
  color: var(--text-muted);
  border-color: var(--text-muted);
}

.custom-label {
  font-size: 0.78rem;
  color: #9b59b6;
  font-style: italic;
  padding-left: 0.2rem;
}

.custom-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.custom-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  outline: none;
  width: 140px;
  transition: border-color 0.2s;
}

.custom-input:focus { border-color: var(--other); }

.btn-save {
  background: var(--other);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-save:hover { opacity: 0.8; }

.save-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.modal-card h2 {
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
}

.pw-hint {
  background: rgba(255,107,53,0.1);
  border: 1px solid rgba(255,107,53,0.3);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.muted { color: var(--text-muted); font-weight: 400; }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-actions .btn-primary { flex: 1; margin-top: 0; }

/* === Responsive === */
@media (max-width: 520px) {
  .week-grid {
    grid-template-columns: 72px 1fr 1fr;
  }

  .day-label {
    font-size: 0.75rem;
    padding: 0.75rem 0.5rem;
  }

  .user-cell {
    padding: 0.6rem 0.5rem;
  }

  .act-btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
  }
}
