/* ============================================
   Gesundheitsapp - Design System v2.0
   Light Theme mit DSGVO-konformen Fonts
   ============================================ */

/* === Font Faces === */
/* Inter - Headings */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter/inter-v18-latin-regular.woff2') format('woff2'),
       url('../fonts/inter/inter-v18-latin-regular.woff') format('woff');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter/inter-v18-latin-500.woff2') format('woff2'),
       url('../fonts/inter/inter-v18-latin-500.woff') format('woff');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter/inter-v18-latin-600.woff2') format('woff2'),
       url('../fonts/inter/inter-v18-latin-600.woff') format('woff');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter/inter-v18-latin-700.woff2') format('woff2'),
       url('../fonts/inter/inter-v18-latin-700.woff') format('woff');
}

/* Roboto - Body Text */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/roboto/roboto-v30-latin-regular.woff2') format('woff2'),
       url('../fonts/roboto/roboto-v30-latin-regular.woff') format('woff');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/roboto/roboto-v30-latin-500.woff2') format('woff2'),
       url('../fonts/roboto/roboto-v30-latin-500.woff') format('woff');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/roboto/roboto-v30-latin-700.woff2') format('woff2'),
       url('../fonts/roboto/roboto-v30-latin-700.woff') format('woff');
}

/* Roboto Mono - Code/Monospace */
@font-face {
  font-family: 'Roboto Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/roboto-mono/roboto-mono-v23-latin-regular.woff2') format('woff2'),
       url('../fonts/roboto-mono/roboto-mono-v23-latin-regular.woff') format('woff');
}
@font-face {
  font-family: 'Roboto Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/roboto-mono/roboto-mono-v23-latin-500.woff2') format('woff2'),
       url('../fonts/roboto-mono/roboto-mono-v23-latin-500.woff') format('woff');
}

/* === CSS Variables === */
:root {
  /* Colors - Brand Palette */
  --primary: #347BB7;
  --primary-hover: #2A6396;
  --primary-light: #E8F3FB;
  --accent: #E48F6C;
  --accent-hover: #D67951;
  --accent-light: #FDF5F1;

  /* Backgrounds */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --bg-tertiary: #E9ECEF;

  /* Surface Colors */
  --surface: #FFFFFF;
  --surface-hover: #F8F9FA;
  --surface-pressed: #E9ECEF;

  /* Text Colors */
  --text-primary: #1A202C;
  --text-secondary: #4A5568;
  --text-muted: #718096;
  --text-disabled: #A0AEC0;
  --text-inverse: #FFFFFF;

  /* Borders */
  --border: #E2E8F0;
  --border-hover: #CBD5E0;
  --border-focus: #347BB7;

  /* Semantic Colors */
  --success: #38A169;
  --success-light: #F0FFF4;
  --success-border: #9AE6B4;

  --warning: #DD6B20;
  --warning-light: #FFFAF0;
  --warning-border: #FBD38D;

  --error: #E53E3E;
  --error-light: #FFF5F5;
  --error-border: #FEB2B2;

  --info: #3182CE;
  --info-light: #EBF8FF;
  --info-border: #90CDF4;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'Roboto Mono', 'Courier New', monospace;

  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Breakpoints (for reference in media queries) */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* === CSS Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-4) 0;
}

h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
}

h2 {
  font-size: var(--text-3xl);
  font-weight: 600;
}

h3 {
  font-size: var(--text-2xl);
  font-weight: 600;
}

h4 {
  font-size: var(--text-xl);
  font-weight: 600;
}

h5 {
  font-size: var(--text-lg);
  font-weight: 600;
}

h6 {
  font-size: var(--text-base);
  font-weight: 600;
}

p {
  margin: 0 0 var(--space-4) 0;
}

small {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.text-muted, .muted {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* === Links === */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* === Layout === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-10) var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: var(--space-12) var(--space-8);
  }
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-compact {
  padding: var(--space-4);
}

.card-large {
  padding: var(--space-8);
}

/* === Navigation === */
nav.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

nav.card a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

nav.card a:hover {
  background: var(--bg-secondary);
  color: var(--primary);
  text-decoration: none;
}

nav.card a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* Icon in Navigation */
nav.card a .icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

@media (max-width: 767px) {
  nav.card {
    flex-direction: column;
    align-items: stretch;
  }

  nav.card a {
    justify-content: center;
    width: 100%;
    padding: var(--space-3) var(--space-4);
  }
}

/* === Buttons === */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

button:hover, .btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  text-decoration: none;
}

button:active, .btn:active {
  background: var(--surface-pressed);
  transform: translateY(1px);
}

button:focus, .btn:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: var(--text-inverse);
}

.btn-success:hover {
  background: #2F855A;
}

.btn-danger {
  background: var(--error);
  border-color: var(--error);
  color: var(--text-inverse);
}

.btn-danger:hover {
  background: #C53030;
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: var(--text-inverse);
}

.btn-warning:hover {
  background: #C05621;
}

/* Button Sizes */
.btn-small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.btn-large {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
}

/* Button Icon */
.btn .icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-small .icon {
  width: 16px;
  height: 16px;
}

.btn-large .icon {
  width: 20px;
  height: 20px;
}

/* === Forms === */
label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

input, select, textarea {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:hover, select:hover, textarea:hover {
  border-color: var(--border-hover);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(52, 123, 183, 0.1);
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-secondary);
  color: var(--text-disabled);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Input Groups */
.input-group {
  margin-bottom: var(--space-4);
}

.input-hint {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* === Alerts === */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.alert-success {
  background: var(--success-light);
  border-color: var(--success);
  color: #22543D;
}

.alert-error {
  background: var(--error-light);
  border-color: var(--error);
  color: #742A2A;
}

.alert-warning {
  background: var(--warning-light);
  border-color: var(--warning);
  color: #7C2D12;
}

.alert-info {
  background: var(--info-light);
  border-color: var(--info);
  color: #2C5282;
}

/* === Tables === */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-4) 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

table thead {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
}

table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
}

table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

table tbody tr {
  transition: background-color var(--transition-fast);
}

table tbody tr:hover {
  background: var(--bg-secondary);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* Responsive Tables */
@media (max-width: 767px) {
  table {
    font-size: var(--text-xs);
  }

  table th,
  table td {
    padding: var(--space-2) var(--space-3);
  }
}

/* === KPI Cards (Dashboard Stats) === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-card-icon {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
}

.kpi-card-value {
  font-size: var(--text-4xl);
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.kpi-card-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.kpi-card-trend.positive {
  background: var(--success-light);
  color: var(--success);
}

.kpi-card-trend.negative {
  background: var(--error-light);
  color: var(--error);
}

.kpi-card-trend .icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

@media (max-width: 767px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* === Charts === */
.chart-container {
  position: relative;
  width: 100%;
  margin-bottom: var(--space-6);
}

.chart {
  width: 100%;
  height: 400px;
}

@media (max-width: 767px) {
  .chart {
    height: 300px;
  }
}

/* === Divider === */
.hr {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-6) 0;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-error {
  background: var(--error-light);
  color: var(--error);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

/* Role Badges */
.badge-role {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.badge-role.admin {
  background: #D1FAE5;
  color: #065F46;
}

.badge-role.arzt {
  background: #DBEAFE;
  color: #1E40AF;
}

.badge-role.patient {
  background: #FEF3C7;
  color: #92400E;
}

/* === Edit Form (collapsible) === */
.edit-form {
  display: none;
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
  border: 1px solid var(--border);
}

.edit-form.active {
  display: grid;
  gap: var(--space-3);
}

/* === Utilities === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* === Accessibility === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* === Print Styles === */
@media print {
  nav.card {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .btn, button {
    display: none;
  }
}
