/* ========================================
   PORSCHE ELECTRIC COMPONENTS
   Dark | Glass | Precision | Electric Blue
   ======================================== */

/* ===== RESET & BASE ===== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--text-primary);
  background: var(--surface-0);
  line-height: 1.6;
  letter-spacing: var(--ls-normal);
  margin: 0;
  min-height: 100vh;
}

/* Noise texture overlay for depth */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--electric);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--electric-bright);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: 1.15;
  margin: 0;
}

/* ===== SKIP LINK ===== */

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  background: var(--electric);
  color: var(--text-inverse);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  font-weight: var(--fw-semibold);
  z-index: 1000;
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--s-4);
}

/* ===== NAVIGATION ===== */

.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--s-3) var(--s-6);
}

.nav__list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 1400px;
  margin: 0 auto;
}

.nav__brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: var(--ls-tight);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.nav__brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--electric);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-glow);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.nav__link {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.nav__link:hover {
  color: var(--text-primary);
  background: var(--surface-3);
}

.nav__link--active {
  color: var(--electric);
  background: var(--electric-glow);
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-5);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 50%);
  pointer-events: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--electric);
  outline-offset: 2px;
}

/* Primary - Electric glow */
.btn-primary {
  background: var(--electric-gradient);
  color: var(--text-inverse);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary - Glass */
.btn-secondary {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-4);
  border-color: var(--border-strong);
}

/* Danger */
.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.2);
  border-color: var(--error);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--surface-3);
}

/* Sizes */
.btn-sm {
  padding: var(--s-1) var(--s-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--s-3) var(--s-8);
  font-size: var(--text-base);
}

.btn-block {
  width: 100%;
}

/* ===== CARDS ===== */

.card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

.card--glow {
  border-color: var(--border-electric);
  box-shadow: var(--shadow-glow);
}

.card--glow:hover {
  box-shadow: var(--shadow-glow-strong);
}

.card-header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-3);
}

.card-body {
  padding: var(--s-6);
}

.card-footer {
  padding: var(--s-4) var(--s-6);
  background: var(--surface-1);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--s-2);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-widest);
  margin: 0 0 var(--s-2) 0;
}

.card-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* ===== FORMS ===== */

.form-group {
  margin-bottom: var(--s-5);
}

.form-label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  letter-spacing: var(--ls-wide);
}

.form-label--required::after {
  content: ' *';
  color: var(--electric);
}

.form-help {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.form-error {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--text-xs);
  color: var(--error);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: var(--s-3) var(--s-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  transition: all var(--duration-fast) var(--ease-out);
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-disabled);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--electric);
  box-shadow: 0 0 0 3px var(--electric-glow), 0 0 20px rgba(56, 189, 248, 0.1);
}

.input:disabled,
.select:disabled {
  background: var(--surface-0);
  color: var(--text-disabled);
  cursor: not-allowed;
  opacity: 0.5;
}

.textarea {
  resize: vertical;
  min-height: 100px;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 16px;
  padding-right: var(--s-10);
  cursor: pointer;
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.checkbox-label input,
.radio-label input {
  accent-color: var(--electric);
  width: 16px;
  height: 16px;
}

/* ===== STAT CARDS ===== */

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--electric-gradient);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
  border-color: var(--border-default);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: var(--s-1);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--ls-widest);
}

/* ===== TABLES ===== */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-2);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.table thead {
  background: var(--surface-3);
}

.table th {
  padding: var(--s-3) var(--s-5);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-widest);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table td {
  padding: var(--s-4) var(--s-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--surface-3);
}

/* ===== BADGES ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  border-radius: var(--r-full);
  border: 1px solid transparent;
}

.badge--online {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.badge--offline {
  background: var(--surface-4);
  color: var(--text-tertiary);
  border-color: var(--border-default);
}

.badge--live {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
  animation: pulse-glow 2s ease-in-out infinite;
}

.badge--warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

/* ===== ALERTS ===== */

.alert {
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-lg);
  border: 1px solid;
  font-size: var(--text-sm);
}

.alert--success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.alert--error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

.alert--warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.alert--info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

/* ===== ANIMATIONS ===== */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50% { box-shadow: 0 0 12px 2px rgba(248, 113, 113, 0.2); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes electricPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== LOADING ===== */

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-default);
  border-top-color: var(--electric);
  border-radius: var(--r-full);
  animation: spin 0.8s linear infinite;
}

.spinner--sm {
  width: 16px;
  height: 16px;
}

/* ===== MODAL ===== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--s-6);
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.modal__content {
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp var(--duration-normal) var(--ease-out);
}

.modal__header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--s-1);
  line-height: 1;
  border-radius: var(--r-sm);
  transition: all var(--duration-fast);
}

.modal__close:hover {
  color: var(--text-primary);
  background: var(--surface-4);
}

.modal__body {
  padding: var(--s-6);
}

.modal__footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
}

/* ===== INLINE FORM ===== */

.inline-form {
  display: inline;
}

/* ===== MEDIA QUERY: Stagger animations ===== */

.stagger > * {
  animation: fadeIn var(--duration-normal) var(--ease-out) both;
}

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
