/* ==========================================================================
   SB-IT Kundenportal — Shared Styles
   Design-Tokens identisch zur Hauptseite (index.html)
   ========================================================================== */

:root {
  --blue:       #0088d2;
  --blue-light: #2ba9e2;
  --blue-pale:  #e8f4fb;
  --navy:       #0f2438;
  --text:       #33475b;
  --muted:      #6b7d90;
  --bg:         #ffffff;
  --bg-soft:    #f6f9fc;
  --border:     #e3eaf1;
  --green:      #24cf40;
  --yellow:     #f0d131;
  --purple:     #a31dde;
  --red:        #c52d2a;
  --indigo:     #2b33c8;
  --radius:     16px;
  --shadow:     0 6px 24px rgba(15,36,56,.07);
  --shadow-lg:  0 14px 40px rgba(15,36,56,.13);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; flex: 1; }
main { flex: 1; }

/* ── Regenbogenbalken ────────────────────────────────────────────────────── */
.rainbow {
  height: 5px;
  background: linear-gradient(90deg, var(--yellow), var(--blue-light), var(--green), var(--purple), var(--red), var(--indigo));
  flex-shrink: 0;
}

/* ── Portal-Header ───────────────────────────────────────────────────────── */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.portal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.2;
}
.brand:hover { text-decoration: none; }
.brand svg { height: 44px; width: auto; flex-shrink: 0; }
.brand small { display: block; font-weight: 500; font-size: .67rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

.portal-nav-links { display: flex; gap: 22px; font-weight: 600; font-size: .9rem; }
.portal-nav-links a { color: var(--text); transition: color .15s; }
.portal-nav-links a:hover { color: var(--blue); text-decoration: none; }
.portal-nav-links a.active { color: var(--blue); }

/* User-Bereich im Header */
.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem; flex-shrink: 0;
  letter-spacing: .02em;
}
.user-info { line-height: 1.25; }
.user-name { font-weight: 600; font-size: .88rem; color: var(--navy); }
.user-role { font-size: .72rem; color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 999px;
  font-weight: 700; font-size: .88rem;
  transition: .2s; border: 2px solid transparent;
  cursor: pointer; font-family: inherit; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 6px 13px; font-size: .8rem; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #006fab; border-color: #006fab; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline { border-color: var(--blue); color: var(--blue); background: #fff; }
.btn-outline:hover { background: var(--blue-pale); }
.btn-ghost { color: var(--navy); border-color: var(--border); background: #fff; }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #a02020; }

/* ── Karten ──────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px 18px; }

/* ── Formulare ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label {
  display: block; font-weight: 600;
  font-size: .86rem; color: var(--navy); margin-bottom: 6px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .9rem; font-family: inherit;
  color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,136,210,.12);
}
input::placeholder, textarea::placeholder { color: #a8bbc8; }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* Checkbox */
.check-group { display: flex; align-items: center; gap: 9px; }
.check-group input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0;
  border-radius: 4px; cursor: pointer; flex-shrink: 0;
}
.check-group label { margin: 0; font-weight: 500; cursor: pointer; }

/* ── Tabellen ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  padding: 11px 14px; border-bottom: 1.5px solid var(--border);
  background: var(--bg-soft); white-space: nowrap;
}
td {
  padding: 13px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fbfd; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .73rem; font-weight: 700; white-space: nowrap;
}
.badge-green  { background: #e8fbec; color: #1a8c2e; }
.badge-red    { background: #fdeaea; color: #a01818; }
.badge-blue   { background: var(--blue-pale); color: var(--blue); }
.badge-gray   { background: #eef1f5; color: var(--muted); }
.badge-yellow { background: #fdf9e3; color: #8a6c00; }

/* ── Module-Karten (Kundenportal-Bereiche) ───────────────────────────────── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.module-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  text-decoration: none; color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s, background-color .2s; cursor: pointer;
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #c8e4f7;
  background: #f7fbff;
  text-decoration: none;
}
.module-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module-icon svg { width: 22px; height: 22px; }
.module-title { font-weight: 700; color: var(--navy); font-size: .95rem; }
.module-desc { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.module-desc-lang { font-size: .8rem; color: var(--muted); line-height: 1.5; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── Seiten-Kopfzeile ────────────────────────────────────────────────────── */
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; color: var(--navy); letter-spacing: -.01em; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: .93rem; }
.kicker { color: var(--blue); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: .73rem; margin-bottom: 4px; }

.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.section-row h2 { font-size: 1.1rem; font-weight: 700; color: var(--navy); }

/* ── Statistik-Kacheln ───────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 5px; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert { border-radius: 12px; padding: 12px 16px; font-size: .88rem; margin-bottom: 16px; }
.alert-info    { background: var(--blue-pale); color: #005fa0; border: 1px solid #b0d8f5; }
.alert-warning { background: #fdf9e3; color: #7a6000; border: 1px solid #ede08a; }
.alert-success { background: #e8fbec; color: #1a6e2a; border: 1px solid #a8ddb4; }
.alert-error   { background: #fdeaea; color: #8a1010; border: 1px solid #f0b0b0; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 22px; flex-wrap: wrap;
}
.tab {
  padding: 9px 16px; font-weight: 600; font-size: .88rem;
  color: var(--muted); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; font-family: inherit;
  border-radius: 8px 8px 0 0; transition: color .15s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,36,56,.48); backdrop-filter: blur(3px);
  z-index: 200; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 20px;
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--navy); }
.modal-close {
  background: var(--bg-soft); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 50%; font-size: .9rem;
  cursor: pointer; color: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--blue-pale); color: var(--blue); }
.modal-body { padding: 20px 24px 26px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── Portal-Footer ───────────────────────────────────────────────────────── */
.portal-footer {
  padding: 22px 0;
  border-top: 1px solid var(--border);
  background: #fff;
  margin-top: auto;
}
.portal-footer .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; font-size: .83rem; color: var(--muted);
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-nav-links { display: none; }
  .module-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  /* Header: Benutzername/Rolle ausblenden, Abstand reduzieren */
  .portal-nav {
    height: auto;
    min-height: 56px;
    padding: 8px 0;
    flex-wrap: nowrap; /* kein Wrap — stattdessen Brand-Text ausblenden */
    gap: 8px;
  }
  .user-info { display: none; }
  .brand svg { height: 34px; flex-shrink: 0; }
  .brand { font-size: .88rem; min-width: 0; flex-shrink: 1; overflow: hidden; }
  .user-menu { gap: 6px; flex-shrink: 0; }
  .user-menu .btn-sm { padding: 5px 10px; font-size: .78rem; white-space: nowrap; }

  /* Tabs: Kachel-Stil statt Unterstrich — funktioniert korrekt beim Umbrechen */
  .tabs {
    border-bottom: none;
    gap: 6px;
    padding-bottom: 8px;
  }
  .tab {
    margin-bottom: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: .82rem;
    background: var(--bg);
  }
  .tab.active {
    background: var(--blue-pale);
    border-color: var(--blue);
    border-bottom: 1px solid var(--blue);
  }
}

@media (max-width: 480px) {
  .module-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  /* Brand-Text ausblenden — gibt genug Platz für Buttons */
  .brand span { display: none; }
  .brand svg { height: 32px; }
  /* Alle sekundären Nav-Buttons ausblenden, nur Abmelden bleibt sichtbar */
  .user-menu .btn { display: none; }
  .user-menu a[href="auth/logout.php"] { display: inline-flex; }
}
