/* Design-Tokens als CSS-Variablen */
:root {
  /* Farben */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --muted: #6b7280;      /* Text sekundär */
  --text: #111827;       /* Text primär */
  --border: #e5e7eb;

  --primary: #2563eb;    /* Blau */
  --primary-600: #1d4ed8;
  --accent: #14b8a6;     /* Teal für Status "bereit" */
  --warning: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --info: #3b82f6;

  /* Radius, Schatten, Abstände, Breiten */
  --r-sm: .5rem; 
  --r-md: 1rem; 
  --r-lg: 1.25rem;
  --shadow: 0 6px 20px rgba(17,24,39,.06);
  --space-1: .25rem; 
  --space-2: .5rem; 
  --space-3: .75rem; 
  --space-4: 1rem; 
  --space-6: 1.5rem; 
  --space-8: 2rem;
  --container: 1200px;

  /* Typografie */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  --h1: clamp(1.8rem, 1.2rem + 1.5vw, 2.6rem);
  --h2: 1.25rem; 
  --h3: 1.125rem; 
  --body: .95rem;
}

/* Layout-Primitives */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--body);
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: all 0.3s ease;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .nav a span:not(.icon),
.sidebar.collapsed .user-details,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .logo-text-wrapper {
  display: none;
}

/* Logo größer machen wenn Sidebar collapsed - Logo kann alleine stehen */
.sidebar.collapsed .logo-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto;
}

.sidebar.collapsed .logo {
  justify-content: center;
}

.sidebar.collapsed .nav a {
  justify-content: center;
  padding: var(--space-3);
}

.sidebar.collapsed .user-info {
  justify-content: center;
}

.sidebar-toggle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--r-sm);
  transition: all 0.2s ease;
  margin-left: var(--space-2);
  width: 28px;
  height: 28px;
  justify-content: center;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.sidebar-toggle span {
  width: 14px;
  height: 2px;
  background-color: var(--muted);
  transition: all 0.3s ease;
  border-radius: 1px;
  display: block;
  transform-origin: center;
}

.sidebar-toggle:hover span {
  background-color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.sidebar.collapsed .sidebar-toggle span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.sidebar.collapsed .sidebar-toggle span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  position: relative;
  min-height: 64px;
  gap: var(--space-3);
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  position: relative;
}

.organization-name-text {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
  word-break: break-word;
  display: block;
  margin-top: 0.125rem;
  opacity: 0.8;
}

.logo {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex: 1;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.logo-text-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
  transition: all 0.3s ease;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.logo-icon:has(img) {
  background: transparent;
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

/* Logo ohne Text "Siqment" - aber mit "Company" und Organisationsname */
.logo.logo-icon-only .logo-text {
  display: none;
}

.logo.logo-icon-only {
  gap: var(--space-3);
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
}

.logo.logo-icon-only .logo-icon {
  width: auto;
  height: 40px;
  margin: 0;
}

.logo.logo-icon-only .logo-icon img {
  max-width: 150px;
}

.logo.logo-icon-only .logo-text-wrapper {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  margin-top: var(--space-2);
}

.company-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#organization-name-root {
  flex: 1;
  min-width: 0;
}

.main {
  flex: 1;
  padding: var(--space-2);
  padding-left: 0;
  background: var(--bg);
  margin-left: 0;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: var(--h1);
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 var(--space-6);
}

.section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.card__body {
  padding: var(--space-6);
}

.toolbar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
}

/* Interaktive Elemente */
.button {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border-radius: var(--r-md);
  padding: .7rem 1.2rem;
  font-weight: 600;
  border: none;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  font-size: var(--body);
}

.button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.5s ease;
}

.button:hover::before {
  left: 100%;
}

.button--primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.button--primary:hover {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.button--primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.button--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.button--ghost:hover {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.button:focus {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.input, .select {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .55rem .7rem;
  background: #fff;
  width: 100%;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 999px;
  padding: .22rem .55rem;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge--success {
  background: color-mix(in srgb, var(--success) 12%, #fff);
  color: #166534;
  border-color: color-mix(in srgb, var(--success) 40%, #fff);
}

.badge--info {
  background: color-mix(in srgb, var(--info) 12%, #fff);
  color: #1e3a8a;
  border-color: color-mix(in srgb, var(--info) 40%, #fff);
}

.badge--warning {
  background: color-mix(in srgb, var(--warning) 14%, #fff);
  color: #7c3e00;
  border-color: color-mix(in srgb, var(--warning) 40%, #fff);
}

.badge--danger {
  background: color-mix(in srgb, var(--danger) 12%, #fff);
  color: #7f1d1d;
  border-color: color-mix(in srgb, var(--danger) 40%, #fff);
}

.badge--error {
  background: color-mix(in srgb, var(--danger) 12%, #fff);
  color: #7f1d1d;
  border-color: color-mix(in srgb, var(--danger) 40%, #fff);
}

.kpi {
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  font-size: .8rem;
  color: var(--muted);
}

.icon {
  width: 1rem;
  height: 1rem;
  display: inline-block;
}

/* Listen- und Tabellenansicht */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.list-row {
  display: grid;
  grid-template-columns: 420px 1fr 320px 160px;
  gap: var(--space-4);
  padding: var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
}

.list-row:hover {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.list-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.list-sub {
  color: var(--muted);
  font-size: .85rem;
}

/* Navigationsmuster */
.breadcrumb {
  display: flex;
  gap: .5rem;
  align-items: center;
  color: var(--muted);
  font-size: .85rem;
}

.tabs {
  display: flex;
  gap: .4rem;
}

.tab {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab--active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, #fff);
}

.sidebar .nav {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.nav a {
  display: flex;
  gap: .75rem;
  align-items: center;
  border-radius: var(--r-sm);
  padding: .65rem .75rem;
  color: #9ca3af;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9375rem;
}

.nav a .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #9ca3af;
}

.nav a .icon svg {
  width: 20px;
  height: 20px;
}

.nav a .nav-text {
  color: #9ca3af;
  font-weight: 500;
}

.nav a:hover {
  background: rgba(147, 51, 234, 0.08);
  color: #6b7280;
}

.nav a:hover .icon {
  color: #6b7280;
}

.nav a:hover .nav-text {
  color: #6b7280;
}

.nav a[aria-current="page"],
.nav a.active {
  background: rgba(147, 51, 234, 0.12);
  color: #9333ea;
  font-weight: 600;
}

.nav a[aria-current="page"] .icon,
.nav a.active .icon {
  color: #9333ea;
}

.nav a[aria-current="page"] .nav-text,
.nav a.active .nav-text {
  color: #9333ea;
}

/* Upload Area Styles */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-8);
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 2%, transparent);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: var(--space-2);
}

.upload-buttons {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .main {
    width: 100%;
    margin-left: 0;
  }
  
  .section {
    grid-template-columns: 1fr;
  }
  
  .list-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}
