/* ================================================================
   Zeiterfassung – Stylesheet
   Vollständig responsive, Mobile-first
   ================================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --secondary:      #16a34a;
  --secondary-dark: #15803d;
  --secondary-light:#dcfce7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --info:           #0891b2;
  --info-light:     #cffafe;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --white: #ffffff;
  --body-bg: #f1f5f9;
  --surface: #ffffff;

  /* Timeline-Farben */
  --color-work:    #2563eb;
  --color-break:   #f59e0b;
  --color-rest:    #e2e8f0;
  --color-vacation:#16a34a;
  --color-sick:    #dc2626;
  --color-holiday: #7c3aed;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);

  /* Radius */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transition */
  --transition: all .2s ease;

  /* Layout */
  --sidebar-w: 240px;
  --header-h:  64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--body-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 640px)  { .container { padding: 0 24px; } }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

/* ── Header ─────────────────────────────────────────────────── */
.main-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
}

.main-header .container {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.5rem; line-height: 1; }

/* Desktop-Nav */
.main-nav {
  display: none;
  align-items: center;
  gap: 2px;
  flex: 1;
}
@media (min-width: 768px) { .main-nav { display: flex; } }

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}
.main-nav a:hover   { background: var(--gray-100); color: var(--gray-800); }
.main-nav a.active  { background: var(--primary-light); color: var(--primary-dark); }

/* User-Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.user-name {
  display: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
}
@media (min-width: 640px) { .user-name { display: block; } }

/* Hamburger (mobile) */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--gray-600);
  border-radius: 2px;
  transition: var(--transition);
}
@media (min-width: 768px) { .nav-toggle { display: none; } }

/* Mobile-Nav Drawer */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
}
.mobile-nav.open { display: block; }

.mobile-nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
}
.mobile-nav-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--white);
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-nav-drawer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--gray-700);
  text-decoration: none;
}
.mobile-nav-drawer a:hover  { background: var(--gray-100); }
.mobile-nav-drawer a.active { background: var(--primary-light); color: var(--primary); }
.mobile-nav-close {
  align-self: flex-end;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-500);
  margin-bottom: 12px;
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px 0 48px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.main-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  font-size: 0.8rem;
  text-align: center;
  padding: 16px;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--gray-900);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header h2,
.card-header h3,
.card-header h4 { font-size: 1rem; font-weight: 600; color: var(--gray-800); margin: 0; }
.card-body   { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ── Grid ────────────────────────────────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2,1fr); }

@media (min-width: 640px)  { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (min-width: 768px)  {
  .grid-2 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(3,1fr); }
  .grid-4 { grid-template-columns: repeat(4,1fr); }
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary   { background: var(--primary);   color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100);  color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success   { background: var(--secondary); color: var(--white); }
.btn-success:hover { background: var(--secondary-dark); }
.btn-danger    { background: var(--danger);    color: var(--white); }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning   { background: var(--warning);   color: var(--white); }
.btn-warning:hover { background: #b45309; }

.btn-small  { padding: 5px 12px; font-size: 0.8rem; }
.btn-large  { padding: 13px 28px; font-size: 1rem; }
.btn-block  { width: 100%; }
.btn-icon   { width: 34px; height: 34px; padding: 0; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}
.form-control {
  width: 100%;
  padding: 9px 13px;
  font-size: 0.9rem;
  color: var(--gray-800);
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control::placeholder { color: var(--gray-400); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px; }

.form-row { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 480px) { .form-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.form-row .form-group { margin-bottom: 0; }

.form-hint { display: block; margin-top: 5px; font-size: 0.78rem; color: var(--gray-500); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--gray-100); }
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.table tbody tr:hover { background: var(--gray-50); }
.table-striped tbody tr:nth-child(even) { background: var(--gray-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-bottom: 24px; }
@media (min-width: 768px) { .stats-grid { grid-template-columns: repeat(4,1fr); } }

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--gray-300);
  text-align: center;
}
.stat-card.primary { border-top-color: var(--primary); }
.stat-card.success { border-top-color: var(--secondary); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger  { border-top-color: var(--danger); }
.stat-card.info    { border-top-color: var(--info); }

.stat-value {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.875rem;
  border-left: 4px solid;
}
.alert-success { background: var(--secondary-light); border-color: var(--secondary); color: #14532d; }
.alert-danger  { background: var(--danger-light);    border-color: var(--danger);    color: #7f1d1d; }
.alert-warning { background: var(--warning-light);   border-color: var(--warning);   color: #78350f; }
.alert-info    { background: var(--info-light);      border-color: var(--info);      color: #164e63; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--secondary-light); color: var(--secondary-dark); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ── Progress ────────────────────────────────────────────────── */
.progress { height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--primary); transition: width .5s ease; }
.progress-bar.success { background: var(--secondary); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; overflow-x: auto; }
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
  text-decoration: none;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Clock / Stempeluhr ─────────────────────────────────────── */
.clock-display { text-align: center; padding: 24px 16px; }
.clock-time {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: 1;
}
.clock-date { font-size: 0.875rem; color: var(--gray-500); margin: 6px 0 18px; }
.clock-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.clock-status.active { background: var(--secondary-light); color: var(--secondary-dark); }
.clock-status.paused { background: var(--warning-light); color: var(--warning); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray-400); flex-shrink: 0; }
.clock-status.active .status-dot { background: var(--secondary); animation: pulse 2s infinite; }
.clock-status.paused .status-dot { background: var(--warning); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .6; transform: scale(.85); }
}

.clock-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ── Entry List (Dashboard) ─────────────────────────────────── */
.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  flex-wrap: wrap;
}
.entry-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.entry-time { font-size: 0.9rem; font-weight: 600; color: var(--gray-700); white-space: nowrap; min-width: 110px; }
.entry-details { flex: 1; min-width: 0; }
.entry-date { font-weight: 600; font-size: 0.875rem; }
.entry-project { font-size: 0.78rem; color: var(--gray-500); }
.entry-hours { font-size: 1.1rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.entry-actions { display: flex; gap: 6px; }

/* ── Auth Pages ──────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 5vw, 40px);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-header p { color: var(--gray-500); font-size: 0.875rem; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--gray-500); }

/* ── Timeline / Tagesbalken ─────────────────────────────────── */
.timeline-chart { width: 100%; }

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 10px;
  min-height: 44px;
}
.timeline-label {
  flex-shrink: 0;
  width: 90px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  padding-right: 10px;
  text-align: right;
  line-height: 1.3;
}
@media (min-width: 640px) { .timeline-label { width: 110px; } }

.timeline-bar-wrap {
  flex: 1;
  position: relative;
  height: 36px;
  background: var(--gray-100);
  border-radius: 6px;
  overflow: hidden;
}
.timeline-bar-wrap.empty { background: var(--gray-100); }

.tl-segment {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 0;
  transition: opacity .15s;
  cursor: default;
}
.tl-segment:hover { opacity: .82; }
.tl-segment.work    { background: var(--color-work); }
.tl-segment.break   { background: var(--color-break); }
.tl-segment.rest    { background: var(--color-rest); }
.tl-segment.vacation{ background: var(--color-vacation); }
.tl-segment.sick    { background: var(--color-sick); }
.tl-segment.holiday { background: var(--color-holiday); }

/* first / last segment rounding */
.tl-segment:first-child { border-radius: 6px 0 0 6px; }
.tl-segment:last-child  { border-radius: 0 6px 6px 0; }
.tl-segment:only-child  { border-radius: 6px; }

.timeline-hours {
  flex-shrink: 0;
  width: 48px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-600);
  padding-left: 8px;
  text-align: left;
}

/* Tooltip on hover */
.tl-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: var(--white);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 10;
}
.tl-segment:hover .tl-tooltip { opacity: 1; }

/* Axis ticks */
.timeline-axis {
  display: flex;
  margin-left: 90px;
  margin-bottom: 4px;
  position: relative;
}
@media (min-width: 640px) { .timeline-axis { margin-left: 110px; } }
.timeline-axis-tick {
  font-size: 0.68rem;
  color: var(--gray-400);
  position: absolute;
  transform: translateX(-50%);
}

/* Legend */
.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 0.78rem;
  color: var(--gray-600);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-100);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot  { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* Multi-user admin timeline */
.admin-timeline-row { margin-bottom: 6px; }
.admin-timeline-label {
  font-size: 0.78rem;
  color: var(--gray-600);
  width: 130px;
  flex-shrink: 0;
  padding-right: 10px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) { .admin-timeline-label { width: 160px; } }

/* ── Chart Container ─────────────────────────────────────────── */
.chart-container { position: relative; height: 260px; width: 100%; }
@media (min-width: 768px) { .chart-container { height: 300px; } }
.chart-container.tall { height: 360px; }

/* ── Utilities ───────────────────────────────────────────────── */
.mt-1 { margin-top: 8px;  }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px;  }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.text-success { color: var(--secondary); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--gray-500); }
.text-sm      { font-size: 0.85rem; }
.text-xs      { font-size: 0.75rem; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }

.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }

/* ── Scrollbar (Webkit) ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Focus visible ───────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
