/* LICENSE COMMANDER - ENHANCED STYLES */

/* Design Tokens */
:host {
  /* Typography */
  --font-base: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;
  
  /* Colors - Light Theme */
  --bg-gradient: linear-gradient(135deg, #e3f2fd 0%, #fce4ec 100%);
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafd;
  --bg-hover: #f0f7ff;
  
  /* Borders */
  --border-subtle: #e8eff7;
  --border-default: #d1dbe6;
  --border-strong: #b8c8d9;
  
  /* Text */
  --text-primary: #1a2332;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  
  /* Brand Colors */
  --brand-blue: #1976d2;
  --brand-blue-light: #42a5f5;
  --brand-pink: #f48fb1;
  --brand-green: #21a366; /* Excel green */
  
  /* Semantic Colors */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-warning: #f59e0b;
  --color-warning-bg: #fef3c7;
  --color-danger: #ef5350;
  --color-danger-bg: #ffebee;
  
  /* Spacing Scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(25, 118, 210, 0.08);
  --shadow-md: 0 4px 16px rgba(25, 118, 210, 0.12);
  --shadow-lg: 0 10px 40px rgba(25, 118, 210, 0.15);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
body.dark-mode {
  background: #0a0f1a !important;
  color: #FFFFFF !important;
}

body.dark-mode header {
  background: #0f172a !important;
  border-color: #1e293b !important;
}

body.dark-mode main {
  background: #0a0f1a !important;
}

body.dark-mode #license-commander-root {
  background: #0f172a !important;
  border-color: #1e293b !important;
}

body.dark-mode footer {
  background: #0f172a !important;
  border-color: #1e293b !important;
}

body.dark-mode :host {
  --bg-gradient: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --bg-hover: #475569;
  
  --border-subtle: #334155;
  --border-default: #475569;
  --border-strong: #64748b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --brand-blue: #60a5fa;
  --brand-blue-light: #93c5fd;
  
  --color-success-bg: #14532d;
  --color-warning-bg: #422006;
  --color-danger-bg: #450a0a;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
}

body.dark-mode .controls-row {
  background: #334155 !important;
  border-color: #475569 !important;
}

body.dark-mode #unitSelect {
  background: #1e293b !important;
  color: #60a5fa !important;
  border-color: #34d399 !important;
}

body.dark-mode #unitSelect:hover {
  background: #334155 !important;
}

body.dark-mode table#licenseTable {
  background: #1e293b !important;
  border-color: #475569 !important;
}

body.dark-mode thead th {
  background: linear-gradient(90deg, #1e40af 60%, #831843 100%) !important;
  color: #e0e7ff !important;
  border-bottom-color: #60a5fa !important;
}

body.dark-mode thead th:hover {
  background: linear-gradient(90deg, #1e3a8a 60%, #701a3a 100%) !important;
}

body.dark-mode tbody tr:hover {
  background: #334155 !important;
}

body.dark-mode tbody td {
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

body.dark-mode .open-order {
  background-color: #14532d !important;
}

body.dark-mode .row-revoked {
  background-color: #450a0a !important;
}

body.dark-mode .row-removed {
  background-color: #1e293b !important;
  border-left-color: #64748b !important;
}

body.dark-mode .row-removed td {
  color: #cbd5e1 !important;
}

body.dark-mode .lc-cell-input,
body.dark-mode .lc-cell-select {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}

body.dark-mode .lc-cell-input:hover,
body.dark-mode .lc-cell-select:hover {
  background: #334155 !important;
  border-color: #64748b !important;
}

body.dark-mode .lc-cell-input:focus,
body.dark-mode .lc-cell-select:focus {
  border-color: #60a5fa !important;
  background: #1e293b !important;
}

body.dark-mode .show-changes-btn {
  background: #1e293b !important;
  color: #60a5fa !important;
  border-color: #60a5fa !important;
}

body.dark-mode .show-changes-btn:hover {
  background: #60a5fa !important;
  color: #1e293b !important;
}

body.dark-mode .lc-btn-undo {
  background: #1e293b !important;
  color: #f87171 !important;
  border-color: #f87171 !important;
}

body.dark-mode .lc-btn-undo:hover {
  background: #f87171 !important;
  color: #1e293b !important;
}

body.dark-mode .text-slate-700 {
  color: #FFFFFF !important;
}

body.dark-mode .text-slate-500 {
  color: #E5E7EB !important;
}

body.dark-mode .text-slate-400 {
  color: #D1D5DB !important;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode .font-bold {
  color: #FFFFFF !important;
}

/* SVG icons should inherit color for proper contrast */
body.dark-mode svg {
  stroke: currentColor;
}

body.dark-mode .bg-slate-50 {
  background: #0a0f1a !important;
}

body.dark-mode .bg-slate-100 {
  background: #0f172a !important;
}

body.dark-mode .border-slate-200 {
  border-color: #475569 !important;
}

body.dark-mode .bg-white {
  background: #0f172a !important;
}

/* Dark mode toggle button styling */
body.dark-mode #darkModeToggle {
  background: #1e293b !important;
  border-color: #3b82f6 !important;
  color: #FFFFFF !important;
}

body.dark-mode #darkModeToggle:hover {
  background: #334155 !important;
  border-color: #60a5fa !important;
  color: #FFFFFF !important;
}

/* 1. BASE LAYOUT */
:host {
  display: block;
  font-family: var(--font-base);
  background: var(--bg-gradient);
  padding: var(--space-8) var(--space-5);
  min-height: 100vh;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#lc-scope {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  transition: box-shadow var(--transition-base);
}

#lc-scope:hover {
  box-shadow: 0 12px 48px rgba(25, 118, 210, 0.18);
}


/* 2. CONTROLS ROW */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-5);
  background: var(--bg-elevated);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.unit-label {
  font-weight: 600;
  color: var(--brand-blue);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#unitSelect {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--brand-green);
  background: var(--bg-surface);
  color: var(--brand-blue);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-base);
  transition: all var(--transition-fast);
  font-size: 0.9375rem;
}

#unitSelect:hover {
  border-color: #16a34a;
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(33, 163, 102, 0.1);
}

#unitSelect:focus {
  outline: none;
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(33, 163, 102, 0.2);
}


/* 3. DATA TABLE */
table#licenseTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

thead th {
  background: linear-gradient(90deg, #e3f2fd 60%, #fce4ec 100%);
  color: var(--brand-blue);
  padding: var(--space-4) var(--space-3);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  border-bottom: 2px solid var(--brand-blue);
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

thead th:hover {
  background: linear-gradient(90deg, #bbdefb 60%, #f8bbd0 100%);
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.5;
}

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

/* Row State Styling */
.open-order {
  border-left: 4px solid var(--color-success) !important;
  background-color: var(--color-success-bg) !important;
}

.row-revoked {
  background-color: var(--color-danger-bg) !important;
  border-left: 4px solid var(--color-danger) !important;
}

.row-revoked td {
  opacity: 0.85;
}

/* Removed (deprovisioned / swept) records — archive gray, dashed rail, muted + struck holder.
   Deliberately NOT red: a removed record is retired, not an error. Shows only in admin search. */
.row-removed {
  background-color: #f1f5f9 !important;
  border-left: 4px dashed #94a3b8 !important;
}

.row-removed td {
  opacity: 0.75;
  color: #475569 !important;
}

.row-pending-approval {
  background-color: #f0fff0 !important;
  border-left: 4px solid #4caf50 !important;

.row-pending-approval td {
  opacity: 1;
}

/* 4. FORM INPUTS */
.lc-cell-input, 
.lc-cell-select {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  outline: none;
}

.lc-cell-input:hover,
.lc-cell-select:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.lc-cell-input:focus,
.lc-cell-select:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
  background: var(--bg-surface);
}

/* 5. BUTTONS */
.download-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: linear-gradient(90deg, var(--brand-green) 0%, #34a853 100%);
  color: white !important;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  font-weight: 600;
  font-family: var(--font-base);
  margin-left: auto;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
}

.download-link:hover {
  background: linear-gradient(90deg, #16a34a 0%, #2d9348 100%);
  box-shadow: 0 4px 12px rgba(33, 163, 102, 0.25);
  transform: translateY(-1px);
}

.download-link:active {
  transform: translateY(0);
}

.show-changes-btn {
  background: var(--bg-surface);
  color: var(--brand-blue);
  border: 1.5px solid var(--brand-blue);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-base);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.show-changes-btn:hover {
  background: var(--brand-blue);
  color: white;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.25);
}

.show-changes-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}

.lc-btn-undo {
  background: var(--bg-surface);
  color: var(--color-danger);
  border: 1.5px solid var(--color-danger);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-base);
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

.lc-btn-undo:hover {
  background: var(--color-danger);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 83, 80, 0.25);
}

.lc-btn-undo:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.2);
}

/* 6. BULK BILLING BAR */
#bulk-billing-bar input {
  padding: var(--space-2);
  border: 1px solid #ffcc80;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: var(--font-base);
  transition: all var(--transition-fast);
}

#bulk-billing-bar input:focus {
  outline: none;
  border-color: #fb8c00;
  box-shadow: 0 0 0 3px rgba(251, 140, 0, 0.15);
}

#btn-apply-bulk:hover {
  background: #ef6c00 !important;
  box-shadow: 0 2px 8px rgba(230, 81, 0, 0.3);
  transform: translateY(-1px);
}

/* 7. ACCESSIBILITY & POLISH */
/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Smooth scrolling */
* {
  scroll-behavior: smooth;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* NOTIF1 — make the Activity Feed bell badge impossible to miss when there's
   unread console activity: a pulsing red glow ring + a tinted/active bell.
   Toggled by notifications.js (_updateBadge). Honors reduced-motion above. */
@keyframes lcNotifPulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65); }
  70%  { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
#lcNotifBellBadge.lc-pulse {
  animation: lcNotifPulse 1.5s ease-out infinite;
  background: #ef4444;
  box-shadow: 0 0 6px 1px rgba(239, 68, 68, 0.8);
}
#lcNotifBell.lc-has-unread {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fef2f2;
}

/* NOTIF1 — when there's unread activity, RING the (solid) bell: a quick side-to-side
   swing pivoting from the top hook, then a rest before it rings again — draws the eye
   like a real bell. Honors reduced-motion via the global rule above. */
@keyframes lcBellRing {
  0%   { transform: rotate(0); }
  4%   { transform: rotate(16deg); }
  10%  { transform: rotate(-14deg); }
  16%  { transform: rotate(11deg); }
  22%  { transform: rotate(-8deg); }
  28%  { transform: rotate(5deg); }
  34%  { transform: rotate(-2deg); }
  40%  { transform: rotate(0); }
  100% { transform: rotate(0); }   /* rest between rings */
}
#lcNotifBell.lc-has-unread svg {
  animation: lcBellRing 2.4s ease-in-out infinite;
  transform-origin: top center;    /* pivot from the hook, not the middle */
  will-change: transform;
}

/* NOTIF1 — self-contained Activity Feed slide-over. Fully independent of the
   order modal's .order-user-drawer/.active system so the header bell controls
   it ALONE and the order modal can never reveal it. Toggled by .lc-open. */
.lc-activity-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 88vw;
  background: #ffffff;
  box-shadow: -8px 0 24px rgba(2, 6, 23, 0.18);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 100040;
  display: flex;
  flex-direction: column;
}
.lc-activity-drawer.lc-open {
  transform: translateX(0);
}
