/* ============================================================
   Zeiterfassung – App CSS (Mobile-First)
   ============================================================ */

:root {
  --primary:       #2563EB;
  --primary-dark:  #1E40AF;
  --primary-light: #EFF6FF;
  --success:       #16A34A;
  --warning:       #D97706;
  --danger:        #DC2626;
  --gray-50:       #F8FAFC;
  --gray-100:      #F1F5F9;
  --gray-200:      #E2E8F0;
  --gray-400:      #94A3B8;
  --gray-600:      #475569;
  --gray-800:      #1E293B;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --border:        #E2E8F0;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.1);
  --transition:    .2s ease;
  --header-h:      56px;
  --nav-h:         64px;
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       font-size: 16px; line-height: 1.5; color: var(--text);
       background: var(--gray-50); min-height: 100%; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── Utilities ──────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); font-size: .875rem; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm      { font-size: .875rem; }
.font-bold    { font-weight: 700; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: .6rem 1.2rem; border: none; border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; transition: background var(--transition),
  box-shadow var(--transition), transform .1s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline  { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger   { background: var(--danger); color: white; }
.btn-success  { background: var(--success); color: white; }
.btn-sm       { padding: .4rem .9rem; font-size: .875rem; }
.btn-lg       { padding: .85rem 1.5rem; font-size: 1rem; }
.btn-block    { width: 100%; }
.btn-row      { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }
.form-group label { font-size: .875rem; font-weight: 600; color: var(--gray-600); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%; padding: .65rem .9rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: white; color: var(--text); outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

.input-with-icon { position: relative; }
.input-with-icon input { padding-right: 2.8rem; }
.toggle-pw {
  position: absolute; right: .7rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--gray-400); padding: .2rem;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 1rem; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: white;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
.login-container { width: 100%; max-width: 420px; }
.login-logo {
  text-align: center; color: white; margin-bottom: 2rem;
}
.login-logo h1 { font-size: 1.75rem; margin-top: .75rem; }
.login-card {
  background: white; border-radius: var(--radius); padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 1.25rem; margin-bottom: 1.5rem; }

/* ════════════════════════════════════════════════════════════
   PWA APP
   ════════════════════════════════════════════════════════════ */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--primary); color: white;
  height: var(--header-h);
  padding-top: env(safe-area-inset-top, 0);
  box-shadow: var(--shadow-md);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 1rem;
}
.header-title  { font-weight: 700; font-size: 1.1rem; }
.header-right  { display: flex; align-items: center; gap: .75rem; }
.user-name     { font-size: .875rem; opacity: .9; }
.icon-btn {
  background: rgba(255,255,255,.15); border: none; border-radius: 50%;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: white; cursor: pointer; transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.25); }

/* Dropdown */
.dropdown-menu {
  position: fixed; top: calc(var(--header-h) + 4px); right: .75rem; z-index: 200;
  background: white; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 180px; overflow: hidden;
}
.dropdown-menu a {
  display: block; padding: .75rem 1rem; color: var(--text); font-size: .9rem;
  transition: background var(--transition);
}
.dropdown-menu a:hover { background: var(--gray-100); }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); }

/* Content area */
#content {
  flex: 1; margin-top: var(--header-h); margin-bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow-y: auto;
}
.page { display: none; }
.page.active { display: block; }
.page-content { padding: 1.25rem; max-width: 640px; margin: 0 auto; }
.page-content h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.page-content h3 { font-size: 1rem; margin: 1.25rem 0 .75rem; }

/* Bottom Nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: white; border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .25rem; padding: .5rem;
  color: var(--gray-400); font-size: .7rem; font-weight: 500;
  transition: color var(--transition); -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.nav-item.active, .nav-item:hover { color: var(--primary); }
.nav-item svg { transition: transform .15s; }
.nav-item.active svg { transform: scale(1.1); }

/* ── Stempel-Bereich ─────────────────────────────────────── */
.stamp-card {
  padding: 1.5rem 1.25rem 1rem; max-width: 480px; margin: 0 auto;
}
.status-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .4rem 1rem; border-radius: 99px;
  font-size: .875rem; font-weight: 600; margin-bottom: 1rem;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
/* Status-Varianten */
.status-working  { background: #DCFCE7; color: #166534; }
.status-working .status-dot { background: #16A34A; }
.status-break    { background: #FEF9C3; color: #854D0E; }
.status-break .status-dot  { background: #D97706; }
.status-not_working { background: var(--gray-100); color: var(--gray-600); }
.status-not_working .status-dot { background: var(--gray-400); animation: none; }

.last-booking  { font-size: .875rem; color: var(--text-muted); margin-bottom: .25rem; }
.work-time     { font-size: 2rem; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; }

.stamp-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.stamp-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; padding: 1.25rem; border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: transform .15s, box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent; box-shadow: var(--shadow);
  min-height: 110px;
}
.stamp-btn:active { transform: scale(.95); }
.stamp-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.btn-come   { background: var(--primary); color: white; }
.btn-come:hover:not(:disabled) { background: var(--primary-dark); }
.btn-break  { background: #FFFBEB; color: #92400E; }
.btn-break:hover:not(:disabled) { background: #FEF3C7; }
.btn-resume { background: #F0FDF4; color: #166534; }
.btn-resume:hover:not(:disabled) { background: #DCFCE7; }
.btn-go     { background: #FEF2F2; color: #991B1B; }
.btn-go:hover:not(:disabled) { background: #FEE2E2; }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-bottom) + 1rem);
  left: 50%; transform: translateX(-50%);
  background: var(--gray-800); color: white; padding: .65rem 1.25rem;
  border-radius: 99px; font-size: .875rem; z-index: 300;
  animation: fadeInUp .3s ease;
  white-space: nowrap;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Tages-Timeline */
.day-timeline { padding: 0 1.25rem 1rem; max-width: 480px; margin: 0 auto; }
.day-timeline h3 { font-size: .95rem; color: var(--text-muted); margin-bottom: .75rem; }
.timeline-item {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.timeline-time { font-weight: 600; font-size: .9rem; min-width: 48px; }
.timeline-type { flex: 1; font-size: .9rem; }
.timeline-src  { font-size: .75rem; color: var(--text-muted); }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-come   { background: #DBEAFE; color: var(--primary); }
.icon-go     { background: #FEE2E2; color: var(--danger); }
.icon-break  { background: #FEF3C7; color: var(--warning); }

/* Buchungsübersicht */
.day-group { background: white; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; overflow: hidden; }
.day-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; background: var(--gray-50);
  font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--border);
}
.day-work-time { color: var(--primary); font-weight: 700; }
.booking-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; border-bottom: 1px solid var(--gray-100);
  font-size: .875rem;
}
.booking-row:last-child { border-bottom: none; }
.booking-time  { font-weight: 600; min-width: 46px; }
.booking-label { flex: 1; }
.booking-badge {
  padding: 2px 8px; border-radius: 99px; font-size: .7rem; font-weight: 600;
}
.badge-normal   { background: #DCFCE7; color: #166534; }
.badge-pending  { background: #FEF9C3; color: #854D0E; }
.badge-approved { background: #DBEAFE; color: #1E40AF; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }

.filter-row { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.export-row { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* Urlaubsanträge */
.vacation-item {
  background: white; border-radius: var(--radius-sm); padding: .875rem 1rem;
  box-shadow: var(--shadow); margin-bottom: .75rem;
}
.vacation-dates { font-weight: 600; font-size: .9rem; }
.vacation-meta  { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; display: flex; gap: .75rem; flex-wrap: wrap; }

/* Profil */
.profile-card { display: flex; align-items: center; gap: 1rem; background: white; padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--primary);
  color: white; font-size: 1.25rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.profile-info { display: flex; flex-direction: column; }
.profile-info strong { font-size: 1rem; }
.profile-info span   { font-size: .875rem; color: var(--text-muted); }

/* ── Responsive ─────────────────────────────────────────── */
@media (min-width: 640px) {
  .stamp-buttons { grid-template-columns: repeat(4, 1fr); }
  .stamp-btn { min-height: 100px; }
}

/* ── Dienstplan (Mitarbeiter) ────────────────────────────── */
.sched-week-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  padding: 1rem 1rem .4rem;
}
.sched-day {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem; margin: 0 0 2px;
  background: white;
  border-left: 3px solid transparent;
}
.sched-day.sched-today  { border-left-color: var(--primary); background: var(--primary-light); }
.sched-day.sched-weekend { background: var(--gray-50); }
.sched-date {
  display: flex; flex-direction: column; align-items: center;
  min-width: 36px;
}
.sched-dow { font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.sched-dd  { font-size: .88rem; font-weight: 600; }
.sched-content { display: flex; align-items: center; gap: .6rem; flex: 1; flex-wrap: wrap; }
.sched-badge {
  padding: .25rem .55rem; border-radius: 5px;
  color: white; font-weight: 800; font-size: .9rem;
}
.sched-type  { font-size: .875rem; font-weight: 600; }
.sched-time  { font-size: .78rem; color: var(--text-muted); }
.sched-note  { font-size: .75rem; color: var(--text-muted); font-style: italic; flex-basis: 100%; padding-left: calc(36px + 1rem); }
.sched-vac   { font-weight: 600; color: #16A34A; font-size: .875rem; }
.sched-empty { color: var(--gray-300); font-size: .82rem; }
