/* =============================================
   Flexility Solutions – Kundenportal
   Dark Professional Theme
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #1c2128;
  --border:      #30363d;
  --border2:     #21262d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #484f58;
  --accent:      #2a7a4b;
  --accent-light:#3fb96e;
  --accent-glow: rgba(42,122,75,0.15);
  --gold:        #d4a843;
  --gold-light:  #f0c96b;
  --red:         #f85149;
  --red-bg:      rgba(248,81,73,0.1);
  --yellow:      #e3b341;
  --yellow-bg:   rgba(227,179,65,0.1);
  --blue:        #58a6ff;
  --blue-bg:     rgba(88,166,255,0.1);
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --sidebar-w:   260px;
  --header-h:    64px;
  --font-body:   'DM Sans', sans-serif;
  --font-head:   'Space Grotesk', sans-serif;
  --transition:  0.18s cubic-bezier(0.4,0,0.2,1);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.portal-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border2);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-text { font-family: var(--font-head); font-size: 0.9rem; font-weight: 600; }
.sidebar-logo-text small { display: block; font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { padding: 8px 16px 4px; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-subtle); font-weight: 600; margin-top: 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}
.nav-link:hover { color: var(--text); background: var(--accent-glow); }
.nav-link.active { color: var(--accent-light); background: var(--accent-glow); }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent-light);
  border-radius: 0 2px 2px 0;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 0.8rem; font-weight: 700;
  color: var(--bg);
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-firm { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.notif-btn:hover { color: var(--text); border-color: var(--accent); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--accent-light);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.page-body { padding: 32px; flex: 1; }
.page-body.narrow { max-width: 800px; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--text-muted); margin-top: 4px; font-size: 0.88rem; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2 { font-family: var(--font-head); font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border2); background: var(--surface2); }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.green { background: var(--accent-glow); color: var(--accent-light); }
.stat-icon.gold { background: rgba(212,168,67,0.12); color: var(--gold-light); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-value { font-family: var(--font-head); font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
  border-bottom: 1px solid var(--border2);
}
tbody tr { border-bottom: 1px solid var(--border2); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 12px 16px; color: var(--text); vertical-align: middle; }
.td-muted { color: var(--text-muted); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-open    { background: var(--blue-bg);   color: var(--blue); }
.badge-progress{ background: var(--yellow-bg); color: var(--yellow); }
.badge-waiting { background: rgba(212,168,67,.15); color: var(--gold-light); }
.badge-solved  { background: var(--accent-glow); color: var(--accent-light); }
.badge-closed  { background: rgba(139,148,158,.1); color: var(--text-subtle); }

.priority-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem;
}
.priority-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.p-niedrig::before { background: var(--text-subtle); }
.p-normal::before  { background: var(--blue); }
.p-hoch::before    { background: var(--yellow); }
.p-kritisch::before{ background: var(--red); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); padding: 7px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--bg); font-weight: 600; }
.btn-gold:hover { background: var(--gold-light); border-color: var(--gold-light); }

/* ---- Forms ---- */
.form-grid { display: grid; gap: 18px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
label span.req { color: var(--accent-light); margin-left: 2px; }

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--surface); }

.form-hint { font-size: 0.74rem; color: var(--text-subtle); }
.form-error { font-size: 0.78rem; color: var(--red); }

/* ---- File Upload ---- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.upload-zone-icon { color: var(--text-subtle); margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: 0.88rem; }
.upload-zone strong { color: var(--accent-light); }
.file-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.file-item-name { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--text-subtle); }
.file-remove { color: var(--red); cursor: pointer; opacity: 0.6; }
.file-remove:hover { opacity: 1; }

/* ---- Alert / Notification ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--accent-glow); border: 1px solid var(--accent); color: var(--accent-light); }
.alert-error   { background: var(--red-bg);     border: 1px solid var(--red);    color: var(--red); }
.alert-warning { background: var(--yellow-bg);  border: 1px solid var(--yellow); color: var(--yellow); }
.alert-info    { background: var(--blue-bg);    border: 1px solid var(--blue);   color: var(--blue); }

/* ---- Ticket Detail / Comment Thread ---- */
.comment-thread { display: flex; flex-direction: column; gap: 16px; }
.comment {
  display: flex;
  gap: 14px;
}
.comment-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
}
.comment-avatar.kunde { background: var(--blue-bg); color: var(--blue); }
.comment-avatar.mitarbeiter { background: var(--accent-glow); color: var(--accent-light); }
.comment-body {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.comment-author { font-weight: 600; font-size: 0.84rem; }
.comment-time { font-size: 0.74rem; color: var(--text-subtle); }
.comment-text { font-size: 0.86rem; line-height: 1.65; }
.comment.mine .comment-body { border-color: rgba(88,166,255,0.2); }

/* ---- Login / Auth Pages ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  position: relative;
}
.auth-page::before {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(42,122,75,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(212,168,67,0.04) 0%, transparent 60%);
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 40px;
  position: relative;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 22px; font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
}
.auth-logo h1 { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.auth-logo p { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 20px 0 4px;
}
.page-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--text); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---- Mobile ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .page-body { padding: 20px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 20px; }
}

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state svg { color: var(--text-subtle); margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-head); font-size: 1rem; margin-bottom: 6px; }
.empty-state p { font-size: 0.84rem; }

/* ---- Tabs ---- */
.tabs { display: flex; border-bottom: 1px solid var(--border2); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 20px;
  font-size: 0.86rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent-light); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Attachment list ---- */
.attachments-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.attachment-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
}
.attachment-chip:hover { border-color: var(--accent); color: var(--accent-light); }
.attachment-chip svg { width: 14px; height: 14px; color: var(--text-muted); }
