﻿/* ============================================================
   InsightTool - Custom Stylesheet
   Helles modernes Design - Weiss und #ba2e17
   ============================================================ */

/* Variablen */
:root {
  --primary:           #ba2e17;
  --primary-dark:      #9a2412;
  --primary-light:     #fdf0ee;
  --primary-muted:     rgba(186,46,23,.12);
  --sidebar-width:     260px;
  --sidebar-bg:        #ffffff;
  --sidebar-border:    #ebebeb;
  --sidebar-text:      #4a5568;
  --sidebar-active-bg: var(--primary-muted);
  --sidebar-active-text: var(--primary);
  --sidebar-label-color: #9aa5b4;
  --topbar-height:     62px;
  --topbar-bg:         #ffffff;
  --topbar-border:     #ebebeb;
  --content-bg:        #f5f6fa;
  --card-shadow:       0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --card-shadow-hover: 0 4px 16px rgba(0,0,0,.10);
}

/* Reset / Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  margin: 0;
  color: #2d3748;
}

/* Bootstrap primary override */
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:active { background-color: #872010; border-color: #872010; }
.btn-primary:focus-visible { box-shadow: 0 0 0 .25rem rgba(186,46,23,.35); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); color: #fff; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* Layout */
.layout-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .3s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}
.sidebar-brand-logo { width: auto; max-width: 220px; object-fit: contain; flex-shrink: 0; }
.sidebar-brand.has-logo {
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: .9rem 1rem;
  white-space: normal;
  overflow: visible;
}
.sidebar-brand.has-logo .sidebar-brand-logo {
  max-height: 75px;
  max-width: 190px;
}
.sidebar-brand.has-logo .sidebar-brand-text {
  font-size: .78rem;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}
.sidebar-brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: .45rem;
  flex-shrink: 0;
}
.sidebar-brand-icon i { font-size: 1.1rem; color: #fff; }
.sidebar-brand-text { display: block;  font-size: .95rem; font-weight: 700; color: #1a202c; line-height: 1.2; }
.sidebar-brand-text small { display: block; font-size: .68rem; font-weight: 400; color: var(--sidebar-label-color); letter-spacing: .02em; }
.sidebar-nav { flex: 1; padding: .75rem .75rem 0; }
.sidebar-label {
  display: block;
  font-size: .65rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--sidebar-label-color);
  padding: 1.1rem .5rem .3rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem;
  border-radius: .45rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
  transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; color: #9aa5b4; transition: color .15s; }
.sidebar-link:hover { background: #f5f6fa; color: #1a202c; }
.sidebar-link:hover i { color: var(--primary); }
.sidebar-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-link.active i { color: var(--primary); }
.sidebar-link--danger { color: #e53e3e !important; }
.sidebar-link--danger i { color: #e53e3e !important; }
.sidebar-link--danger:hover { background: #fff5f5 !important; color: #c53030 !important; }
.sidebar-footer { padding: .75rem; border-top: 1px solid var(--sidebar-border); margin-top: auto; }
.sidebar-footer .sidebar-link { font-size: .85rem; }

/* Mobile Overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 1039;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}

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

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle {
  background: none; border: none; color: #64748b;
  cursor: pointer; padding: .3rem .45rem;
  border-radius: .4rem; display: none; line-height: 1;
}
.sidebar-toggle:hover { background: #f5f6fa; color: #1a202c; }
.topbar-title { font-size: 1.05rem; font-weight: 600; color: #1a202c; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

/* Content Area */
.content-area { flex: 1; padding: 1.75rem 2rem; }

/* Cards */
.card { border: 1px solid #e8ecf2; border-radius: .6rem; box-shadow: var(--card-shadow); background: #fff; }
.card:hover { box-shadow: var(--card-shadow-hover); transition: box-shadow .2s; }
.card-header {
  background: #fff; border-bottom: 1px solid #eef0f5;
  font-weight: 600; color: #1a202c;
  border-radius: .6rem .6rem 0 0 !important;
  padding: .9rem 1.25rem;
}

/* Stat Cards */
.stat-card {
  background: #fff; border-radius: .6rem;
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--card-shadow); border: 1px solid #e8ecf2;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.stat-icon.red    { background: var(--primary-light); color: var(--primary); }
.stat-icon.blue   { background: #f1f5f9; color: #475569; }
.stat-icon.green  { background: #f0fdf4; color: #22c55e; }
.stat-icon.orange { background: #fff7ed; color: #f97316; }
.stat-icon.purple { background: #faf5ff; color: #a855f7; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: #1a202c; }
.stat-label { font-size: .8rem; color: #64748b; margin-top: .2rem; }

/* Tables */
.table thead th {
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: #64748b; border-bottom-width: 1px; background: #fafbfd;
}
.table td { vertical-align: middle; }
.table tbody tr:hover { background: #fafbfd; }

/* DataTables: Abstand für Controls-Zeilen (auch in p-0 Cards) */
div.dataTables_wrapper > .row:first-child { padding: .65rem 1.1rem; }
div.dataTables_wrapper > .row:last-child  { padding: .5rem 1.1rem; border-top: 1px solid #eef0f5; }
div.dataTables_wrapper div.dataTables_filter input { border-radius: .4rem; }
div.dataTables_wrapper div.dataTables_length select { border-radius: .4rem; }

/* Bootstrap Pagination auf Rot-Palette */
.page-link { color: var(--primary); }
.page-link:hover { color: var(--primary-dark); background-color: var(--primary-light); border-color: rgba(186,46,23,.2); }
.page-link:focus { color: var(--primary-dark); box-shadow: 0 0 0 .25rem rgba(186,46,23,.25); }
.page-item.active .page-link { background-color: var(--primary); border-color: var(--primary); color: #fff; }
.page-item.disabled .page-link { color: #94a3b8; }

/* Dashboard KPI-Kacheln: Bootstrap-Farbklassen auf Rot-Palette umbiegen */
.card.text-bg-primary { background-color: var(--primary)   !important; border-color: var(--primary)   !important; color: #fff !important; }
.card.text-bg-info    { background-color: #9a2412          !important; border-color: #9a2412          !important; color: #fff !important; }
.card.text-bg-secondary { background-color: #475569        !important; border-color: #475569          !important; color: #fff !important; }
.card.text-bg-dark    { background-color: #1e293b          !important; border-color: #1e293b          !important; color: #fff !important; }
.card.text-bg-primary a,  .card.text-bg-info a,
.card.text-bg-secondary a, .card.text-bg-dark a { color: rgba(255,255,255,.8); }

/* Badges */
.badge-field { font-size: .7rem; font-weight: 500; }
.badge.bg-primary { background-color: var(--primary) !important; }
.badge.bg-info    { background-color: #475569 !important; color: #fff !important; }

/* Forms */
.form-label { font-weight: 500; font-size: .9rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .25rem rgba(186,46,23,.18);
}
.form-section-title {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--primary);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: .4rem; margin-bottom: 1rem;
}

/* Alerts */
.alert-success  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger   { background: #fff5f5; border-color: #fecaca; color: #991b1b; }
.alert-warning  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info     { background: var(--primary-light); border-color: rgba(186,46,23,.2); color: var(--primary-dark); }

/* Utilities */
.text-truncate-2 {
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* Responsive */
@media (max-width: 992px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); box-shadow: none; }
  .sidebar.show { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.12); }
  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.show { opacity: 1; pointer-events: all; }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .content-area { padding: 1.25rem 1rem; }
}
@media (max-width: 768px) {
  .topbar { padding: 0 1rem; gap: .6rem; }
  .topbar-title { font-size: .95rem; }
  .event-switcher-btn { max-width: 200px; }
  .event-switcher-name { max-width: 110px; }
  .content-area { padding: 1rem .875rem; }
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_filter { text-align: left; float: none; width: 100%; margin-bottom: .4rem; }
  div.dataTables_wrapper div.dataTables_info,
  div.dataTables_wrapper div.dataTables_paginate { text-align: left; float: none; width: 100%; margin-top: .4rem; }
  div.dataTables_wrapper div.dataTables_paginate .paginate_button { padding: .3em .6em; }
}
@media (max-width: 576px) {
  .topbar { padding: 0 .75rem; gap: .4rem; height: auto; min-height: var(--topbar-height); flex-wrap: wrap; padding-top: .5rem; padding-bottom: .5rem; }
  .topbar-title { font-size: .875rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .event-switcher-name { display: none; }
  .event-switcher-date { display: none; }
  .event-switcher-btn { max-width: unset; padding: .3rem .6rem; }
  .topbar-right .badge { font-size: .65rem; padding: .25em .45em; }
  .content-area { padding: .875rem .625rem; }
  .d-flex.justify-content-between.align-items-center { flex-wrap: wrap; gap: .5rem; }
  .d-flex.justify-content-end.align-items-center { flex-wrap: wrap; gap: .5rem; }
  .card { border-radius: .5rem; }
  .login-card { padding: 1.5rem 1.25rem; border-radius: .75rem; }
  .stat-card { padding: .875rem 1rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
  .stat-value { font-size: 1.5rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
  div.dataTables_wrapper div.dataTables_length select,
  div.dataTables_wrapper div.dataTables_filter input { font-size: .85rem; }
  div.dataTables_wrapper div.dataTables_paginate .paginate_button { min-width: 1.8rem; padding: .25em .45em; }
  .alert { font-size: .875rem; padding: .75rem 1rem; }
  .form-label { font-size: .85rem; }
  .form-control, .form-select { font-size: .9rem; }
  .row.small dl.row dt, .row.small dl.row dd { font-size: .8rem; }
  .mb-3.d-flex.gap-2.flex-wrap { gap: .4rem !important; }
  .mb-3.d-flex.gap-2.flex-wrap .btn { font-size: .8rem; padding: .3rem .65rem; }
  .table th, .table td { font-size: .82rem; }
}

/* Login Page */
.login-page {
  min-height: 100vh;
  background: linear-gradient(150deg, #f5f6fa 0%, #fdf0ee 60%, #f8d5ce 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 1rem; padding: 2.5rem;
  box-shadow: 0 8px 40px rgba(186,46,23,.12), 0 2px 8px rgba(0,0,0,.06);
  border: 1px solid #f0e8e6;
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo .login-logo-img { max-height: 60px; max-width: 180px; object-fit: contain; margin-bottom: .75rem; display: block; margin-left: auto; margin-right: auto; }
.login-logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 58px; height: 58px;
  background: var(--primary); border-radius: .75rem; margin-bottom: .75rem;
}
.login-logo-icon i { font-size: 1.75rem; color: #fff; }
.login-logo h1 { font-size: 1.2rem; font-weight: 700; margin: .4rem 0 .2rem; color: #1a202c; }
.login-logo p { font-size: .85rem; color: #64748b; margin: 0; }

/* Event-Switcher */
.event-switcher { position: relative; }
.event-switcher .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 260px;
  display: none;
  z-index: 1050;
}
.event-switcher .dropdown-menu.show { display: block; }
.event-switcher-btn {
  display: flex; align-items: center; gap: .4rem;
  background: var(--primary-light);
  border: 1px solid rgba(186,46,23,.2);
  border-radius: .5rem; padding: .35rem .75rem;
  cursor: pointer; font-size: .88rem;
  color: var(--primary-dark);
  transition: background .15s, border-color .15s;
  max-width: 260px;
}
.event-switcher-btn:hover { background: rgba(186,46,23,.18); border-color: rgba(186,46,23,.35); color: var(--primary-dark); }
.event-switcher-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.event-switcher-date {
  font-size: .72rem; background: var(--primary); color: #fff;
  border-radius: .25rem; padding: .05rem .35rem; flex-shrink: 0;
}
.dropdown-menu {
  border: 1px solid #e8ecf2; border-radius: .55rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.1); padding: .35rem;
}
.dropdown-item { border-radius: .35rem; font-size: .88rem; padding: .45rem .75rem; color: #2d3748; }
.dropdown-item:hover { background: #f5f6fa; color: #1a202c; }
.dropdown-item.active, .dropdown-item:active { background: var(--primary-light); color: var(--primary); }
.dropdown-header { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-label-color); }

/* Event-Label (Sidebar) */
.event-label {
  display: block; font-size: .65rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--primary); padding: 1.1rem .5rem .3rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(var(--sidebar-width) - 1.5rem);
}

/* Sidebar No-Event Warning */
.sidebar-no-event {
  margin: .5rem .25rem;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: .4rem; padding: .6rem .75rem;
  font-size: .8rem; color: #92400e; line-height: 1.4;
}
.sidebar-no-event a { color: var(--primary); font-weight: 600; }
.sidebar-no-event a:hover { color: var(--primary-dark); }

/* Event Cards */
.event-card { border: 1px solid #e8ecf2; border-radius: .6rem; box-shadow: var(--card-shadow); transition: box-shadow .15s, border-color .15s; background: #fff; }
.event-card:hover { box-shadow: var(--card-shadow-hover); border-color: rgba(186,46,23,.25); }
.event-card--active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(186,46,23,.15); }
.event-card--active .card-header { background: var(--primary-light); border-bottom-color: rgba(186,46,23,.15); }

/* Admin Badge */
.topbar-admin-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid rgba(186,46,23,.2);
  border-radius: 2rem; padding: .2rem .6rem;
}