/* ========================================
   SubnetPlanner Theme System
   Complete CSS Custom Properties Implementation
   ======================================== */

/* ========================================
   LIGHT MODE (Default)
   ======================================== */
:root {
  /* Color System - Background & Foreground */
  --background: #ffffff;
  --foreground: #0a0a0a;
  
  /* Primary Colors */
  --primary: #171717;
  --primary-foreground: #fafafa;
  
  /* Secondary Colors */
  --secondary: #f5f5f5;
  --secondary-foreground: #171717;
  
  /* Muted Colors */
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  
  /* Accent Colors */
  --accent: #f5f5f5;
  --accent-foreground: #171717;
  
  /* Card Colors */
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  
  /* Popover Colors */
  --popover: #ffffff;
  --popover-foreground: #0a0a0a;
  
  /* Border & Input */
  --border: #e5e5e5;
  --input: #e5e5e5;
  --ring: #f15a24;
  
  /* Destructive (Error States) */
  --destructive: #e7000b;
  --destructive-foreground: #fafafa;
  
  /* Chart Colors - Data Visualization - AFRINIC Theme */
  --chart-1: #ffccbc;  /* Light Orange - for utilization bars */
  --chart-2: #f15a24;  /* AFRINIC Orange - for allocated subnets */
  --chart-3: #d8400d;  /* Darker Orange - for active elements */
  --chart-4: #333333;  /* Dark Grey - for emphasis */
  --chart-5: #000000;  /* Black - for contrast */
  
  /* Typography */
  --font-sans: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  /* Spacing & Borders */
  --radius: 0.625rem;
  --spacing: 0.25rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
  --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 2px 4px -1px hsl(0 0% 0% / 0.10);
  --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 4px 6px -1px hsl(0 0% 0% / 0.10);
}

/* ========================================
   DARK MODE
   ======================================== */
.dark {
  /* Color System - Background & Foreground */
  --background: #0a0a0a;
  --foreground: #fafafa;
  
  /* Primary Colors */
  --primary: #e5e5e5;
  --primary-foreground: #171717;
  
  /* Secondary Colors */
  --secondary: #262626;
  --secondary-foreground: #e5e5e5;
  
  /* Muted Colors */
  --muted: #1a1a1a;
  --muted-foreground: #a1a1a1;
  
  /* Accent Colors */
  --accent: #262626;
  --accent-foreground: #e5e5e5;
  
  /* Card Colors */
  --card: #171717;
  --card-foreground: #fafafa;
  
  /* Popover Colors */
  --popover: #171717;
  --popover-foreground: #fafafa;
  
  /* Border & Input */
  --border: #282828;
  --input: #343434;
  --ring: #e5e5e5;
  
  /* Destructive (Error States) */
  --destructive: #ff6467;
  --destructive-foreground: #fafafa;
  
  /* Chart Colors - AFRINIC Theme */
  --chart-1: #ffccbc;
  --chart-2: #f15a24;
  --chart-3: #d8400d;
  --chart-4: #333333;
  --chart-5: #000000;
}

/* ========================================
   TAILWIND v4 THEME INTEGRATION
   @theme inline directive
   ======================================== */
@theme inline {
  /* Colors */
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  
  /* Border Radius */
  --radius-lg: var(--radius);
  --radius-md: calc(var(--radius) - 2px);
  --radius-sm: calc(var(--radius) - 4px);
  
  /* Shadows */
  --shadow-sm: var(--shadow-sm);
  --shadow-md: var(--shadow-md);
  --shadow-lg: var(--shadow-lg);
}

/* ========================================
   BASE STYLES
   ======================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   PAGE LAYOUT
   ======================================== */
.page {
  display: block;
  min-height: 100vh;
}

.page.hidden {
  display: none;
}

.page.active {
  display: flex;
}

/* ========================================
   COMPONENT STYLES
   ======================================== */

/* Network/Project Type Cards */
.network-type-card {
  cursor: pointer;
  position: relative;
  background-color: var(--card);
  color: var(--card-foreground);
  border-color: var(--border);
}

.network-type-card:hover {
  transform: translateY(-2px);
  background-color: var(--accent);
  border-color: var(--chart-2);
  box-shadow: var(--shadow-md);
}

.network-type-card:active {
  transform: translateY(0);
}

.network-type-card.selected {
  border-color: var(--chart-2);
  background-color: color-mix(in srgb, var(--chart-2) 5%, var(--card));
}

/* Buttons */
button {
  font-family: var(--font-sans);
  cursor: pointer;
  transition-property: background-color, border-color, color, transform, box-shadow, opacity;
  transition-duration: 200ms;
  transition-timing-function: ease-in-out;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Input Fields */
input,
textarea,
select {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  border-color: var(--input);
  transition: border-color 200ms, box-shadow 200ms;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 20%, transparent);
}

/* Code/Monospace Elements */
code,
pre {
  font-family: var(--font-mono);
  background-color: var(--muted);
  color: var(--foreground);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.125rem 0.375rem;
  font-size: 0.875em;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Smooth transitions for interactive elements */
.transition-colors {
  transition-property: background-color, border-color, color;
  transition-duration: 200ms;
  transition-timing-function: ease-in-out;
}

.transition-shadow {
  transition-property: box-shadow;
  transition-duration: 200ms;
  transition-timing-function: ease-in-out;
}

.transition-all {
  transition-property: all;
  transition-duration: 200ms;
  transition-timing-function: ease-in-out;
}

/* Focus states for accessibility */
*:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ========================================
   CUSTOM COMPONENT STYLES
   ======================================== */

/* Selected State for Network Type Cards (Page 1) */
.network-type-card.selected {
  border-color: var(--chart-2) !important;
  background-color: var(--accent) !important;
  position: relative;
}

.network-type-card.selected::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background-color: var(--chart-2);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-size: 16px;
  background-position: center;
  background-repeat: no-repeat;
}

/* Selected State for Location Type Buttons (Page 2) */
.location-type-btn.selected {
  border-color: var(--chart-3) !important;
  background-color: var(--accent) !important;
  position: relative;
}

.location-type-btn.selected::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background-color: var(--chart-3);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}

/* Selected State for IP Version Cards (Page 1.5) */
.ip-version-card.selected {
  border-color: var(--chart-2) !important;
  background-color: var(--accent) !important;
  position: relative;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--chart-2) 20%, transparent);
}

.ip-version-card.selected::after {
  content: '';
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  background-color: var(--chart-2);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-size: 18px;
  background-position: center;
  background-repeat: no-repeat;
}

/* Subnet Card Styles */
.subnet-card {
  margin-bottom: 8px;
}

.subnet-card .children-container {
  margin-top: 8px;
  padding-left: 0;
}

.subnet-card .expand-btn svg {
  transition: transform 0.2s ease;
}

.subnet-card .expand-btn svg.rotate-90 {
  transform: rotate(90deg);
}

/* Results Table Row Styles */
.results-row .children-container {
  margin-top: 0;
  padding-left: 0;
}

.results-row .children-container.hidden {
  display: none;
}

.results-row .expand-toggle-btn svg {
  transition: transform 0.2s ease;
}

.results-row .expand-toggle-btn svg.rotate-90 {
  transform: rotate(90deg);
}

/* Modal Animations */
.fixed.inset-0.z-50 {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fixed.inset-0.z-50 > div {
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Hide left column on mobile/tablet */
@media (max-width: 1024px) {
  .page > div:first-child {
    display: none !important;
  }
  
  .page > div:last-child {
    width: 100% !important;
  }
}

/* Touch-friendly targets on mobile */
@media (max-width: 640px) {
  button,
  .network-type-card {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ========================================
   DARK MODE INITIALIZATION
   ======================================== */

/* Prevent flash of unstyled content */
html:not(.dark):not(.light) {
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

/* ========================================
   CHEATSHEET MODAL STYLES
   ======================================== */

/* Modal backdrop animation */
#cheatsheet-modal .absolute.inset-0.bg-black\/60 {
  animation: backdropFadeIn 0.3s ease-out;
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal content animation */
#cheatsheet-modal .bg-background.border.border-border.rounded-2xl {
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: scale(0.95) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Cheatsheet content scrollbar styling */
#cheatsheet-content::-webkit-scrollbar {
  width: 8px;
}

#cheatsheet-content::-webkit-scrollbar-track {
  background-color: var(--muted);
  border-radius: 4px;
}

#cheatsheet-content::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

#cheatsheet-content::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted-foreground);
}

/* Cheatsheet table styling enhancement */
#cheatsheet-content table {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 8px;
  overflow: hidden;
}

#cheatsheet-content table th {
  background-color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  font-size: 0.75rem;
}

#cheatsheet-content table td {
  border-bottom: 1px solid var(--border);
}

#cheatsheet-content table tbody tr:last-child td {
  border-bottom: none;
}

#cheatsheet-content table tbody tr:hover {
  background-color: var(--accent);
}

