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

:root {
  --primary: #003f7f;
  --primary-light: #0056b3;
  --accent: #c8a415;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --nav-height: 64px;
  --header-height: 56px;
}

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

/* Screens */
.screen { position: fixed; inset: 0; }
.screen.hidden { display: none; }
.screen.active { display: flex; flex-direction: column; }

/* ── Login ── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  background: linear-gradient(160deg, var(--primary) 0%, #001f3f 100%);
}

.login-logo { text-align: center; margin-bottom: 2.5rem; color: #fff; }
.login-logo h1 { font-size: 2rem; font-weight: 700; letter-spacing: 1px; }
.login-logo p { color: rgba(255,255,255,0.6); margin-top: 0.25rem; }

#form-login {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { color: rgba(255,255,255,0.8); font-size: 0.875rem; }
.form-group input {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: rgba(255,255,255,0.4); }

.btn-primary {
  padding: 0.9rem;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: opacity 0.2s;
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  background: rgba(220,53,69,0.2);
  border: 1px solid var(--danger);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
}
.hidden { display: none !important; }

/* ── App Shell ── */
.app-header {
  height: var(--header-height);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-right { font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.header-title { font-weight: 600; font-size: 1rem; }

.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
}

.app-content {
  height: calc(100dvh - var(--header-height) - var(--nav-height));
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1rem;
  padding-bottom: 1.5rem;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid #e0e0e0;
  display: flex;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.58rem;
  transition: color 0.2s;
  padding: 0.4rem 0;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 1.2rem; line-height: 1; }

/* Individuelle Icon-Farben — unabhängig vom OS-Emoji-Rendering */
[data-page="dashboard"] .nav-icon { color: #2563eb; }
[data-page="time"]      .nav-icon { color: #16a34a; }
[data-page="vacation"]  .nav-icon { color: #f59e0b; }
[data-page="sick"]      .nav-icon { color: #dc2626; }
[data-page="chat"]      .nav-icon { color: #7c3aed; }
[data-page="contacts"]  .nav-icon { color: #0891b2; }
[data-page="news"]      .nav-icon { color: #0f766e; }
.nav-item.active .nav-icon        { color: var(--primary); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.card-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* ── Forms ── */
.page-form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; overflow: hidden; }
.field label { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1.5px solid #dde1e7;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
/* iOS Safari: Datum/Zeit-Felder brauchen explizite Breite */
.field input[type="date"],
.field input[type="time"],
.field input[type="number"] {
  min-width: 0;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 80px; }

.btn-submit {
  padding: 0.875rem;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-submit:hover { background: var(--primary-light); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Status Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-approved { background: #d1e7dd; color: #0a3622; }
.badge-rejected { background: #f8d7da; color: #58151c; }

/* ── News ── */
.news-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.news-item h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.news-item .news-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.news-item p { font-size: 0.9rem; color: var(--text-muted); }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid #dde1e7;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard ── */
.dash-today {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 4px solid #dde1e7;
}
.dash-today--none  { border-left-color: var(--text-muted); }
.dash-today--active{ border-left-color: var(--success); background: #f0fdf4; }
.dash-today--done  { border-left-color: var(--primary); }
.dash-today > div  { flex: 1; font-size: 0.9rem; }
.dash-today small  { color: var(--text-muted); font-size: 0.78rem; }

.progress-bar-bg {
  background: #eef0f3;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
  min-width: 4px;
}

/* ── Zeiterfassung Buttons ── */
.time-clock {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 1rem 0 1.5rem;
  letter-spacing: 2px;
}

.time-btn-start, .time-btn-end {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  transition: transform 0.15s, box-shadow 0.15s;
  margin: 0 auto;
}
.time-btn-start     { background: radial-gradient(circle at 35% 35%, #43d17a, #28a745); }
.time-btn-end       { background: radial-gradient(circle at 35% 35%, #f55, #dc3545); }
.veranstaltung-section {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.veranstaltung-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.time-btn-pause-start {
  width: 110px; height: 110px;
  border-radius: 50%; border: none;
  background: radial-gradient(circle at 35% 35%, #f5a623, #e67e22);
  color: #fff; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.4rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
.time-btn-pause-end {
  width: 130px; height: 130px;
  border-radius: 50%; border: none;
  background: radial-gradient(circle at 35% 35%, #43d17a, #28a745);
  color: #fff; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.4rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  transition: transform 0.15s, box-shadow 0.15s;
}
.time-btn-pause-start:active, .time-btn-pause-end:active { transform: scale(0.95); }

.time-paused {
  background: #fff8ee;
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.time-btn-start:active, .time-btn-end:active { transform: scale(0.95); box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.time-btn-start:disabled, .time-btn-end:disabled { opacity: 0.5; cursor: not-allowed; }

.time-running {
  background: #f0fdf4;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.time-summary { text-align: left; margin: 0.5rem 0; }
.time-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.95rem;
}

/* ── Kontakte ── */
.contact-dept {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .75rem 0 .3rem;
}
.contact-card {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  box-shadow: var(--shadow);
}
.contact-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  flex-shrink: 0;
}
.contact-name { font-weight: 600; font-size: .95rem; }
.contact-pos  { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.contact-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.contact-phone {
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  background: #eef2ff;
  padding: .15rem .5rem;
  border-radius: 20px;
}

/* ── Abwesenheitskalender ── */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 0 .75rem;
  font-size: 1rem;
}
.cal-nav {
  background: none; border: 1px solid #dde1e7; border-radius: 8px;
  width: 36px; height: 36px; font-size: 1.2rem; cursor: pointer;
  color: var(--primary);
}
.cal-legend {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: .75rem;
}
.cal-legend-item {
  display: flex; align-items: center; gap: .3rem;
  font-size: .75rem; color: var(--text-muted);
}
.cal-legend-item span {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px;
}
.cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal-table {
  border-collapse: collapse;
  font-size: .75rem;
  min-width: 100%;
}
.cal-name-col {
  position: sticky; left: 0;
  background: var(--surface);
  white-space: nowrap;
  padding: .4rem .6rem;
  border-right: 2px solid #dde1e7;
  font-weight: 600;
  z-index: 2;
  min-width: 110px;
}
.cal-table thead .cal-name-col {
  background: var(--primary);
  color: #fff;
}
.cal-day {
  width: 28px; min-width: 28px;
  text-align: center;
  padding: .35rem .1rem;
  border: 1px solid #f0f0f0;
  cursor: default;
}
.cal-we     { background: #f8f9fa; color: #bbb; }
.cal-today  { background: #fff3cd !important; font-weight: 700; }
.cal-absent { border-radius: 3px; }
.cal-table thead th { background: var(--primary); color: #fff; font-weight: 600; }
.cal-table tbody tr:hover td { background: #f0f4ff !important; }
.cal-table tbody tr:hover .cal-absent { opacity: .85; }

/* ── Logout Button ── */
.btn-logout {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.9rem;
  border: none;
  border-radius: var(--radius);
  background: var(--danger);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.2s;
}
.btn-logout:hover { opacity: 0.88; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 24px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ── Offline-Banner ── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #b91c1c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: offlinePulse 2s ease-in-out infinite;
}
.offline-banner.hidden { display: none; }

.offline-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.offline-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.offline-text strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.offline-text span {
  font-size: 0.8rem;
  opacity: 0.9;
}

@keyframes offlinePulse {
  0%, 100% { background: #b91c1c; }
  50%       { background: #dc2626; }
}
