/* ============================================================================
 * GLOBAL UI SYSTEM - Apple-Style Design Tokens & Components
 * ============================================================================
 * Basis-Layer: Tokens, Layout, Buttons, Tables, Forms, Alerts, Cards
 * Responsive, Mobile-First
 * ============================================================================ */

:root {
  /* Design Tokens */
  --ui-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ui-radius: 12px;
  --ui-radius-lg: 16px;
  --ui-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
  --ui-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Colors */
  --ui-bg: #f5f5f7;
  --ui-card: #ffffff;
  --ui-text: #1d1d1f;
  --ui-text-muted: #6e6e73;
  --ui-border: #e5e5e7;
  --ui-border-light: #f5f5f7;
  
  /* Primary (iOS Blue) */
  --ui-primary: #007AFF;
  --ui-primary-hover: #0051D5;
  --ui-primary-light: rgba(0, 122, 255, 0.1);
  
  /* Secondary (Neutral) */
  --ui-secondary: #f5f5f7;
  --ui-secondary-hover: #e5e5e7;
  
  /* Destructive (Red) */
  --ui-danger: #ff3b30;
  --ui-danger-hover: #d70015;
  
  /* Success (Green) */
  --ui-success: #34c759;
  --ui-success-hover: #30d158;
  
  /* Warning (Orange) */
  --ui-warn: #ff9500;
  --ui-warn-hover: #ff8c00;
}

/* ============================================================================
 * RESET & BASE
 * ============================================================================ */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ui-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ui-text);
  background-color: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
 * TYPOGRAPHY
 * ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ui-text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
  margin: 0 0 1rem 0;
}

a {
  color: var(--ui-primary);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* ============================================================================
 * LAYOUT
 * ============================================================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
}

/* ============================================================================
 * CARDS
 * ============================================================================ */

.card {
  background: var(--ui-card);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 20px;
  box-shadow: var(--ui-shadow);
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .card {
    padding: 16px;
  }
}

/* ============================================================================
 * BUTTONS
 * ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--ui-radius);
  font-family: var(--ui-font);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--ui-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--ui-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow);
}

.btn-secondary {
  background-color: var(--ui-secondary);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--ui-secondary-hover);
}

.btn-danger {
  background-color: var(--ui-danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--ui-danger-hover);
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow);
}

.btn-success {
  background-color: var(--ui-success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: var(--ui-success-hover);
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow);
}

.btn-warning {
  background-color: var(--ui-warn);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background-color: var(--ui-warn-hover);
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 18px;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .btn-group {
    flex-direction: column;
  }
  
  .btn-group .btn {
    width: 100%;
  }
}

/* ============================================================================
 * FORMS
 * ============================================================================ */

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  font-family: var(--ui-font);
  font-size: 16px;
  background-color: var(--ui-card);
  color: var(--ui-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ui-primary);
  box-shadow: 0 0 0 3px var(--ui-primary-light);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--ui-secondary);
  color: var(--ui-text-muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
 * TABLES
 * ============================================================================ */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--ui-radius);
  border: 1px solid var(--ui-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--ui-card);
}

thead {
  background-color: var(--ui-secondary);
}

th {
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-text);
  border-bottom: 2px solid var(--ui-border);
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ui-border-light);
  font-size: 15px;
}

tbody tr:hover {
  background-color: var(--ui-secondary);
}

tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 768px) {
  .table-responsive {
    border-radius: var(--ui-radius);
  }
  
  th, td {
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* ============================================================================
 * ALERTS & MESSAGES
 * ============================================================================ */

.alert,
.meldung {
  padding: 14px 18px;
  border-radius: var(--ui-radius);
  margin-bottom: 20px;
  font-weight: 500;
  border: 1px solid;
}

.alert-success,
.meldung.success {
  background-color: rgba(52, 199, 89, 0.1);
  color: #1e7e34;
  border-color: rgba(52, 199, 89, 0.3);
}

.alert-error,
.alert-danger,
.meldung.error {
  background-color: rgba(255, 59, 48, 0.1);
  color: #c62828;
  border-color: rgba(255, 59, 48, 0.3);
}

.alert-warning {
  background-color: rgba(255, 149, 0, 0.1);
  color: #b8860b;
  border-color: rgba(255, 149, 0, 0.3);
}

.alert-info {
  background-color: rgba(0, 122, 255, 0.1);
  color: #0051D5;
  border-color: rgba(0, 122, 255, 0.3);
}

/* ============================================================================
 * UTILITIES
 * ============================================================================ */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--ui-text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================================================================
 * RESPONSIVE HELPERS
 * ============================================================================ */

@media (max-width: 768px) {
  /* Mobile: Form inputs full width */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    width: 100%;
  }
  
  /* Mobile: Buttons full width in forms */
  form .btn {
    width: 100%;
  }
}

