/**
 * DX Cluster Web Application - Modern UI Framework
 * Beautiful, responsive design for ham radio operators
 * 
 * @author Kilo Code
 * @version 1.0.0
 */

/* CSS Custom Properties (Variables) */
:root {
  /* Color Palette - Ham Radio Inspired */
  --primary-color: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --secondary-color: #059669;
  --secondary-light: #10b981;
  --accent-color: #dc2626;
  --accent-light: #ef4444;
  
  /* Neutral Colors */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Dark Theme Colors */
  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-surface-light: #334155;
  --dark-text: #f1f5f9;
  --dark-text-muted: #cbd5e1;
  
  /* Status Colors */
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --info: #0284c7;
  
  /* Spot Status Colors */
  --new-dxcc: #ef4444;
  --new-band: #22c55e;
  --new-mode: #3b82f6;
  --worked: #f59e0b;
  --confirmed: #6b7280;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  
  /* Spacing */
  --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;
  --space-10: 2.5rem;
  --space-12: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--gray-900);
  background-color: var(--gray-50);
  transition: var(--transition);
}

/* Dark Theme */
[data-theme="dark"] {
  --text-primary: var(--dark-text);
  --text-secondary: var(--dark-text-muted);
  --bg-primary: var(--dark-bg);
  --bg-secondary: var(--dark-surface);
  --bg-tertiary: var(--dark-surface-light);
  --border-color: var(--gray-700);
}

[data-theme="dark"] body {
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

/* Light Theme (Default) */
[data-theme="light"], :root {
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --bg-primary: var(--white);
  --bg-secondary: var(--gray-50);
  --bg-tertiary: var(--gray-100);
  --border-color: var(--gray-200);
}

/* Layout Components */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Card Component */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

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

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* Button Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary-color);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--secondary-color);
  color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-light);
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-color);
  color: var(--white);
}

.btn-danger {
  background: var(--error);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: 1rem;
}

/* Form Components */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* Table Components */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
}

.table th,
.table td {
  padding: 2px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.1;
}

/* Specific column widths */
.table th:nth-child(1), .table td:nth-child(1) { width: 72px; } /* Time - 20% wider */
.table th:nth-child(2), .table td:nth-child(2) { width: 80px; } /* Callsign */
.table th:nth-child(3), .table td:nth-child(3) { width: 80px; } /* Frequency - 15% wider */
.table th:nth-child(4), .table td:nth-child(4) { width: 46px; } /* Band - 15% wider */
.table th:nth-child(5), .table td:nth-child(5) { width: 58px; } /* Mode - 15% wider */
.table th:nth-child(6), .table td:nth-child(6) { width: 80px; } /* Spotter */
.table th:nth-child(7), .table td:nth-child(7) { min-width: 200px; } /* Comment */

.table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.table tbody tr.spot-new-dxcc {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--new-dxcc);
}

.table tbody tr.spot-new-band {
  background: rgba(34, 197, 94, 0.1);
  border-left: 4px solid var(--new-band);
}

.table tbody tr.spot-new-mode {
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--new-mode);
}

.table tbody tr.spot-worked {
  background: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--worked);
}

.table tbody tr.spot-confirmed {
  background: rgba(107, 114, 128, 0.1);
  border-left: 4px solid var(--confirmed);
}

/* Navigation */
.navbar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

.navbar-nav {
  display: flex;
  gap: var(--space-6);
  list-style: none;
}

.navbar-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--primary-color);
}

/* Status Indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.status-connected {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.status-disconnected {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.status-connecting {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

/* Terminal Component */
.terminal {
  background: var(--gray-900);
  color: #00ff00;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  border-radius: var(--radius);
  overflow: hidden;
}

.terminal-header {
  background: var(--gray-800);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-700);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.terminal-body {
  padding: var(--space-4);
  height: 300px;
  overflow-y: auto;
}

.terminal-input {
  background: transparent;
  border: none;
  color: #00ff00;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  width: 100%;
  outline: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-3);
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  .navbar-nav {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .card-body {
    padding: var(--space-4);
  }
  
  .table th,
  .table td {
    padding: var(--space-2) var(--space-3);
    font-size: 0.75rem;
  }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Loading Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    z-index: 1001;
    max-width: 400px;
    width: 90%;
    margin: 0 auto;
}

.modal-content .card {
    margin: 0;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    z-index: 1000;
    margin-top: var(--space-2);
}

.dropdown-item {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

/* Button Block */
.btn-block {
    display: block;
    width: 100%;
}