* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0077be 0%, #00a8e8 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 420px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 25px;
}

header h1 {
  font-size: 2rem;
}

.subtitle {
  opacity: 0.9;
  font-size: 1rem;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 15px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.card h2 {
  margin-bottom: 20px;
  text-align: center;
  color: #333;
}

.card h3 {
  margin-bottom: 15px;
  color: #666;
  font-size: 0.95rem;
}

label {
  display: block;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="time"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 15px;
  transition: border-color 0.2s;
}

/* iOS Safari ignoriert sonst width:100% bei nativen Time-/Date-Inputs und
   lässt das Feld rechts über den Container hinausragen. */
input[type="time"],
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #0077be;
}

.btn {
  display: inline-block;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn.primary {
  background: #0077be;
  color: white;
  width: 100%;
}

.btn.primary:hover {
  background: #005a8c;
}

.btn.primary:active {
  transform: scale(0.98);
}

.btn.secondary {
  background: #f0f0f0;
  color: #666;
  width: 100%;
}

.btn.large {
  padding: 18px;
  font-size: 1.1rem;
}

.status-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.status-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 0.85rem;
  background: #f5f5f5;
  color: #666;
  border: 2px solid transparent;
}

.status-btn.active[data-status="open"] {
  background: #d4edda;
  color: #155724;
  border-color: #28a745;
}

.status-btn.active[data-status="closed"] {
  background: #f8d7da;
  color: #721c24;
  border-color: #dc3545;
}

.status-btn.active[data-status="special"] {
  background: #fff3cd;
  color: #856404;
  border-color: #ffc107;
}

.time-row {
  display: flex;
  gap: 15px;
}

.time-field {
  flex: 1;
}

.time-field input {
  margin-bottom: 15px;
}

#time-inputs.hidden-times {
  opacity: 0.4;
  pointer-events: none;
}

.error {
  color: #dc3545;
  text-align: center;
  margin-top: 10px;
  font-size: 0.9rem;
}

.status-msg {
  text-align: center;
  margin-top: 15px;
  font-size: 0.9rem;
}

.status-msg.success {
  color: #28a745;
}

.status-msg.error {
  color: #dc3545;
}

.preview {
  background: #f8f9fa;
}

#preview-content {
  text-align: center;
  padding: 10px 0;
}

#preview-content .preview-status {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

#preview-content .preview-times {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0077be;
}

#preview-content .preview-notice {
  font-style: italic;
  color: #666;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

/* Ensure dialog.hidden is truly hidden */
.dialog.hidden {
  display: none !important;
  pointer-events: none !important;
}

.screen {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes highlight {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 168, 232, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(0, 168, 232, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 168, 232, 0);
  }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  background: white;
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #666;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: #0077be;
  color: white;
}

.tab-content {
  display: none !important;
}

.tab-content.active {
  display: block !important;
  animation: fadeIn 0.3s ease;
}

/* Schedule */
.schedule-notice {
  background: #e7f3ff;
  color: #0077be;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.9rem;
  text-align: center;
}

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 10px;
}

.schedule-header > div {
  flex: 1;
  text-align: center;
}

.week-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: #333;
}

.week-dates {
  font-size: 0.85rem;
  color: #666;
}

.btn.small {
  padding: 10px 14px;
  font-size: 0.85rem;
  width: auto;
}

.schedule-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.template-select {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.template-select:focus {
  outline: none;
  border-color: #0077be;
}

.template-select {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  min-width: 150px;
}

.template-select:focus {
  outline: none;
  border-color: #0077be;
}

.schedule-days {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.schedule-day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 10px;
  border-left: 4px solid #0077be;
}

.day-info {
  flex: 1;
}

.day-date {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

.day-status {
  font-size: 0.85rem;
  color: #666;
  margin-top: 3px;
}

.day-edit-btn {
  margin-left: 10px;
}

/* Inline Edit Views (Schedule & Musterwochen) */
#schedule-day-edit,
#mw-day-edit {
  margin-top: 20px;
  padding: 20px;
  background: #fafafa;
  border-radius: 10px;
  border-left: 4px solid #0077be;
}

#schedule-day-edit h3,
#mw-day-edit h4 {
  margin-bottom: 20px;
  color: #333;
}

.edit-time-inputs {
  margin-bottom: 15px;
}

.edit-time-inputs.hidden-times {
  opacity: 0.4;
  pointer-events: none;
}

.dialog-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.dialog-buttons .btn {
  flex: 1;
  margin: 0;
}

/* Musterwochen List */
.musterwochen-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.musterwochen-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #0077be;
}

.musterwochen-name {
  font-weight: 600;
  color: #333;
  flex: 1;
}

.musterwochen-buttons {
  display: flex;
  gap: 5px;
}

.musterwochen-buttons .btn {
  padding: 6px 10px;
  font-size: 0.75rem;
}

/* Musterwochen Details */
.musterwochen-details h4 {
  margin-bottom: 15px;
  color: #333;
}

#musterwochen-details-name {
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

#musterwochen-details-name:hover {
  background-color: #e8f4f8;
}

.musterwochen-days {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.musterwoche-day {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #0077be;
}

.musterwoche-day-name {
  font-weight: 700;
  color: #333;
  width: 40px;
}

.musterwoche-day-info {
  color: #666;
  font-size: 0.9rem;
}

.musterwochen-details-buttons {
  display: flex;
  gap: 10px;
}

.musterwochen-details-buttons .btn {
  flex: 1;
}

/* User Management */
.users-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #0077be;
  cursor: pointer;
  transition: background 0.15s;
}

.user-item:hover {
  background: #e8f4f8;
}

.user-item-name {
  font-weight: 600;
  color: #333;
}

.user-item-role {
  font-size: 0.85rem;
  color: #666;
}

.user-detail-name-display {
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.user-detail-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.user-detail-buttons .btn {
  flex: 1;
}

#user-detail-extra-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

/* QR Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 25px;
  max-width: 400px;
  width: 90%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-bottom: 15px;
  text-align: center;
  color: #333;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

.modal-content img {
  display: block;
  width: 100%;
  margin: 15px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.modal-content p {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 15px;
}

.modal-content button {
  width: 100%;
}

.inline-edit-input {
  font-size: 1.2rem;
  padding: 8px 12px;
  border: 2px solid #0077be;
  border-radius: 4px;
  font-weight: 600;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
}

.inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 8px rgba(0, 119, 190, 0.3);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .container {
    max-width: 100%;
  }

  .card {
    padding: 18px;
    margin-bottom: 12px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .tabs {
    gap: 6px;
    padding: 6px;
  }

  .tab {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .time-row {
    flex-direction: row;
    gap: 10px;
  }

  .time-field {
    flex: 1;
    min-width: 0;
  }

  input[type="text"],
  input[type="password"],
  input[type="time"],
  input[type="date"],
  textarea,
  select {
    padding: 10px 8px;
    margin-bottom: 12px;
    font-size: 14px;
  }

  input[type="time"],
  input[type="date"] {
    font-size: 13px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .btn {
    padding: 12px 16px;
    font-size: 0.95rem;
  }
}

/* Outside Season Styling */
.schedule-day.outside-season {
  background: #e8e8e8;
  border-left-color: #999;
  opacity: 0.65;
}

.schedule-day.outside-season .day-date,
.schedule-day.outside-season .day-status {
  color: #666;
}

.musterwochen-day.outside-season {
  background: #e8e8e8;
  opacity: 0.65;
}

/* iOS Safe Area */
/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  margin: 30px auto;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0077be;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* Users Admin Screen - same width as container */
#users-admin-screen {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
