/* ========== INVOXA · Premium Design System ========== */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --secondary: #7c3aed;
  --success: #10b981;
  --dark: #1f2937;
  --light: #f9fafb;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(145deg, #ffffff 0%, #f8fcff 100%);
  color: var(--dark);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== GLASSMORPHISM ===== */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 20px -1px rgba(0, 0, 0, 0.03);
}

.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 20px 32px -12px rgba(0, 0, 0, 0.05);
}
.invoice-logo-text {
  font-size: 1.875rem;
  font-weight: 900;
  background: linear-gradient(to right, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #4f46e5; /* Fallback für sehr alte Browser */
}
/* ===== ANIMATIONEN ===== */
@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
}

.animate-blob {
  animation: blob 7s infinite;
}

.animation-delay-2000 {
  animation-delay: 2s;
}

.animation-delay-4000 {
  animation-delay: 4s;
}

.hover-lift {
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 25px 35px -12px rgba(79, 70, 229, 0.15);
}

/* ===== RECHNUNGSVORSCHAU (A4) ===== */
.invoice-a4 {
  background: white;
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.05);
  border: 1px solid #f0f4f8;
  transition: all 0.25s ease;
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
  position: relative;
}

.invoice-a4:hover {
  box-shadow: 0 25px 45px -12px rgba(79, 70, 229, 0.12);
  border-color: var(--primary-light);
}

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  white-space: nowrap;
  transition: all 0.15s;
}

.status-badge:hover {
  transform: scale(1.05);
}

/* ===== FEATURE CARDS ===== */
.feature-card {
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.feature-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(145deg, rgba(79,70,229,0.02) 0%, rgba(124,58,237,0.02) 100%);
  opacity: 0;
  transition: opacity 0.25s;
}

.feature-card:hover::after {
  opacity: 1;
}

/* ===== FORM ELEMENTE ===== */
input, select, textarea {
  transition: all 0.2s ease;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

button {
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:active {
  transform: scale(0.98);
}

/* ===== POSITIONEN ITEMS ===== */
.position-item {
  background: #f9fafb;
  border-radius: 0.75rem;
  padding: 1rem;
  border: 1px solid #edf2f7;
  transition: all 0.2s;
}

.position-item:hover {
  background: white;
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.05);
}

/* ===== TABS ===== */
.tab-button {
  transition: all 0.2s;
  position: relative;
}

.tab-button.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* ===== TABELLEN ===== */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

th {
  font-weight: 600;
  color: #4b5563;
  background: #f9fafb;
}

td, th {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #edf2f7;
}

tr:last-child td {
  border-bottom: none;
}

tr {
  transition: background-color 0.15s;
}

tr:hover td {
  background-color: #fafbff;
}

/* ===== BENACHRICHTIGUNGEN ===== */
.notification {
  position: fixed;
  top: 90px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  background: white;
  box-shadow: 0 15px 30px -10px rgba(0,0,0,0.15);
  border-left: 4px solid var(--primary);
  z-index: 9999;
  animation: slideIn 0.3s ease-out;
}
.invoxa-logo {
    font-size: 1.875rem !important;
    font-weight: 900 !important;
    color: #4f46e5 !important; /* Fallback für alte Browser */
    background: linear-gradient(to right, #4f46e5, #7c3aed) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    display: inline-block !important;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== GLOBALER DARK MODE ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.92);
  color: #374151;
  box-shadow: 0 4px 14px -6px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
  font-size: 0.82rem;
  font-weight: 700;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  color: #4f46e5;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  font-size: 0.78rem;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.theme-toggle-sun {
  color: #f59e0b;
  opacity: 1;
}

.theme-toggle-moon {
  color: #64748b;
  opacity: 0.55;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.18);
  transition: background-color 0.25s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 9999px;
  background: white;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.3);
  transition: transform 0.25s ease;
}

html.dark .theme-toggle-track {
  background: #6366f1;
}

html.dark .theme-toggle-thumb {
  transform: translateX(1.25rem);
}

html.dark .theme-toggle-sun {
  color: #94a3b8;
  opacity: 0.55;
}

html.dark .theme-toggle-moon {
  color: #c4b5fd;
  opacity: 1;
}

.context-switch-btn,
.header-user-chip,
.header-logout-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.context-switch-btn {
  background: #111827;
  color: white;
  box-shadow: 0 5px 14px -7px rgba(15, 23, 42, 0.7);
}

.context-switch-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
}

.header-user-chip {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.82);
  color: #374151;
}

.header-logout-btn {
  border: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.82);
  color: #dc2626;
}

.header-logout-btn:hover {
  border-color: #fecaca;
  background: #fef2f2;
}

.admin-hero {
  position: relative;
  background: linear-gradient(125deg, #312e81 0%, #4f46e5 55%, #7c3aed 100%);
}

.admin-hero::after {
  content: '';
  position: absolute;
  width: 22rem;
  height: 22rem;
  right: -6rem;
  top: -11rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
}

.admin-stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.35rem;
  border: 1px solid #eef2f7;
  border-radius: 1.25rem;
  background: white;
  box-shadow: 0 12px 25px -18px rgba(15, 23, 42, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 32px -18px rgba(79, 70, 229, 0.35);
}

.admin-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border-radius: 1rem;
  font-size: 1.15rem;
}

.admin-nav-tab {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.65rem 0.95rem;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.admin-nav-tab:hover,
.admin-nav-tab.is-active {
  background: #eef2ff;
  color: #4f46e5;
}

.admin-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 0.8rem;
  color: white;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  font-weight: 800;
}

.admin-select {
  min-width: 6.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.7rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.admin-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 9999px;
  padding: 0.35rem 0.7rem;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 800;
}

.admin-plan-badge.is-pro {
  background: #fef3c7;
  color: #a16207;
}

.admin-action-btn {
  border-radius: 0.7rem;
  padding: 0.55rem 0.75rem;
  background: #4f46e5;
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.admin-action-btn:hover {
  background: #4338ca;
}

.admin-action-btn.is-remove {
  background: #fff1f2;
  color: #be123c;
}

.admin-action-btn.is-remove:hover {
  background: #ffe4e6;
}

.admin-action-btn.is-secondary {
  background: #f1f5f9;
  color: #475569;
}

.admin-action-btn.is-secondary:hover {
  background: #e2e8f0;
}

html.dark .context-switch-btn {
  background: #4f46e5;
}

html.dark .header-user-chip,
html.dark .header-logout-btn,
html.dark .admin-stat-card {
  border-color: #334155;
  background: #172033;
  color: #e5e7eb;
}

html.dark .admin-plan-badge {
  background: #263247;
  color: #cbd5e1;
}

html.dark .admin-plan-badge.is-pro {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

html.dark .admin-nav-tab {
  color: #cbd5e1;
}

html.dark .admin-nav-tab:hover,
html.dark .admin-nav-tab.is-active {
  background: rgba(99, 102, 241, 0.18);
  color: #c4b5fd;
}

html.dark .admin-action-btn.is-remove {
  background: rgba(225, 29, 72, 0.15);
  color: #fda4af;
}

html.dark .admin-action-btn.is-secondary {
  background: #263247;
  color: #cbd5e1;
}

html.dark #adminUserModal > div,
html.dark #adminModalBody .bg-gray-50 {
  border-color: #334155;
  background: #172033 !important;
  color: #e5e7eb;
}

html.dark {
  color-scheme: dark;
}

html.dark body {
  background: linear-gradient(145deg, #0b1120 0%, #111827 100%) !important;
  color: #e5e7eb;
}

html.dark .glass,
html.dark .glass-card {
  background: rgba(15, 23, 42, 0.86) !important;
  border-color: rgba(148, 163, 184, 0.2) !important;
  box-shadow: 0 10px 28px -12px rgba(0, 0, 0, 0.7);
}

html.dark .bg-white:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-white\/70:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-white\/80:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-white\/90:not(.invoice-a4):not(.invoice-a4 *) {
  background-color: #172033 !important;
}

html.dark .bg-gray-50:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-gray-100:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-indigo-50:not(.invoice-a4):not(.invoice-a4 *),
html.dark .bg-purple-50:not(.invoice-a4):not(.invoice-a4 *) {
  background-color: #101827 !important;
}

html.dark .text-gray-900:not(.invoice-a4 *),
html.dark .text-gray-800:not(.invoice-a4 *),
html.dark .text-gray-700:not(.invoice-a4 *) {
  color: #f3f4f6 !important;
}

html.dark .text-gray-600:not(.invoice-a4 *),
html.dark .text-gray-500:not(.invoice-a4 *),
html.dark .text-gray-400:not(.invoice-a4 *) {
  color: #aeb9ca !important;
}

html.dark .border-gray-100:not(.invoice-a4 *),
html.dark .border-gray-200:not(.invoice-a4 *),
html.dark .border-gray-300:not(.invoice-a4 *),
html.dark .border-white\/30:not(.invoice-a4 *),
html.dark .border-white\/50:not(.invoice-a4 *),
html.dark .border-white\/60:not(.invoice-a4 *) {
  border-color: #334155 !important;
}

html.dark input,
html.dark select,
html.dark textarea {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748b;
}

html.dark th:not(.invoice-a4 *) {
  color: #cbd5e1;
  background: #111827;
}

html.dark td:not(.invoice-a4 *),
html.dark th:not(.invoice-a4 *) {
  border-bottom-color: #293548;
}

html.dark tr:not(.invoice-a4 *) {
  color: #e5e7eb;
}

html.dark tr:hover td:not(.invoice-a4 *) {
  background-color: #1a2437;
}

html.dark .notification {
  background: #172033;
  color: #f3f4f6;
}

html.dark .theme-toggle {
  border-color: #475569;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
}

html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #475569;
  border-color: #0f172a;
}

/* Rechnungen bleiben am Bildschirm, im PDF und beim Drucken immer weiß. */
html.dark .invoice-a4,
html.dark #invoicePreviewContent {
  color-scheme: light;
  background: white !important;
  color: #1f2937 !important;
}

/* ===== DRUCK-OPTIMIERUNG - RADIKAL VEREINFACHT ===== */
@media print {
    /* ALLES ausblenden - NUR die Rechnung sichtbar */
    header, footer, button, nav, form, .tab-button, .tab-content,
    .bg-white.p-6.rounded-3xl, .lg\\:grid-cols-2 > div:last-child,
    #userMenu, .fixed, .glass, .bg-indigo-600, .flex.items-center.gap-2,
    [onclick], .max-w-7xl > .flex-wrap, .h-20, .py-8, .px-4,
    label, input, select, textarea, .border-t, .border-b:not(.invoice-a4 *),
    .grid:not(.invoice-a4 .grid) {
        display: none !important;
    }
    
    /* Body nur für Rechnung */
    body {
        background: white !important;
        color: #1f2937 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
    }
    
    /* Hauptcontainer zurücksetzen */
    .max-w-7xl, .mx-auto, .px-4, .sm\:px-6, .py-8, .lg\:grid-cols-2 {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
        width: 210mm !important;
    }
    
    /* NUR die Rechnung anzeigen - EXAKT wie PDF */
    .invoice-a4, #invoicePreviewContent, .grid.lg\\:grid-cols-2 > div:first-child {
        display: block !important;
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        min-height: 297mm !important;
        padding: 15mm !important;
        margin: 0 auto !important;
        background: white !important;
        color: #1f2937 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
    }
    
    /* Alle inneren Elemente der Rechnung anzeigen */
    .invoice-a4 *,
    #invoicePreviewContent *,
    .space-y-6, .flex, .grid, .border-t, .border-b,
    .font-bold, .text-sm, .text-gray-600, .font-mono {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Flex und Grid korrekt darstellen */
    .flex.justify-between {
        display: flex !important;
    }
    
    .grid.grid-cols-12,
    .grid.grid-cols-3 {
        display: grid !important;
    }
    
    /* Farben für Druck erzwingen */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    /* INVOXA Logo im Druck */
.invoxa-logo {
    font-size: 1.875rem !important;
    font-weight: 900 !important;
    color: #4f46e5 !important; /* Fallback für alte Browser */
    background: linear-gradient(to right, #4f46e5, #7c3aed) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    display: inline-block !important;
}
}

/* ===== BREITE DESKTOP-ARBEITSBEREICHE ===== */
@media (min-width: 1280px) {
  .max-w-7xl {
    max-width: 96rem !important;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .theme-toggle {
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
  }

  .header-user-chip,
  .header-logout-btn {
    display: none;
  }

  .context-switch-btn {
    padding: 0.6rem;
    font-size: 0;
  }

  .context-switch-btn i {
    margin: 0 !important;
    font-size: 0.85rem;
  }

  .invoice-a4 {
    padding: 1.25rem;
  }
  
  table {
    font-size: 0.8rem;
  }
  
  td, th {
    padding: 0.75rem;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
