
/* CSS Variables for Theme Management */
:root {
  /* Light mode variables */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --text-primary: #000000;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --container-bg: #ffffff;
  --input-border: #d1d5db;
  --input-bg: #ffffff;
  --button-bg: #3b82f6;
  --button-hover: #2563eb;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --border-color: #d1d5db;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --glass-bg: rgba(0, 0, 0, 0.05);
  --glass-border: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  /* Dark mode variables */
  --bg-primary: #000000;
  --bg-secondary: #0f172a;
  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --container-bg: #1e293b;
  --input-border: #334155;
  --input-bg: #1e293b;
  --button-bg: #3b82f6;
  --button-hover: #2563eb;
  --accent-color: #8b5cf6;
  --accent-hover: #7c3aed;
  --border-color: #334155;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
}

/* Light mode specific overrides */
body[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --text-primary: #000000;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --input-bg: #ffffff;
  --input-border: #d1d5db;
}

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

html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  /* Prevent text size adjust after orientation changes in iOS */
  -webkit-text-size-adjust: 100%;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Better tap highlighting for mobile */
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

body {
  font-family: 'Orbitron', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
  margin: 0;
  padding: 0;
  display: flex;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  justify-content: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  align-items: flex-start;
  -webkit-box-align: start;
  -webkit-align-items: flex-start;
  -ms-flex-align: start;
  height: 100vh;
  height: -webkit-fill-available; /* Mobile Safari */
  width: 100%;
  max-width: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* For iOS smooth scrolling */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Make sure mobile Chrome has proper scroll behavior */
@media screen and (max-width: 768px) {
  body, html {
    position: relative;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* App Container */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.container {
  width: 100vw;
  max-width: 100%;
  height: 100vh;
  padding: 20px;
  background-color: var(--container-bg);
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Typography */
h1 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h1, h2 {
  font-size: 2rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-primary);
}

input, .form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--container-bg);
  color: var(--text-primary);
  font-size: 16px;
  font-family: 'Orbitron', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.2s ease;
  /* Cross-browser appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input::placeholder, .form-input::placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] input::placeholder, 
[data-theme="dark"] .form-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] input::placeholder, 
[data-theme="light"] .form-input::placeholder {
  color: #9ca3af;
}

input:focus, .form-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button Styles */
button {
  width: 100%;
  padding: 12px 24px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-family: 'Orbitron', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.2s ease;
  /* Cross-browser appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Better touch targets for mobile */
  min-height: 44px;
  /* Prevent text overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Fix for older Edge buttons */
  position: relative;
}

button:hover {
  background-color: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Custom Button Styles */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: none;
  color: white;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Neo-futuristic Button */
.neo-button {
  background: linear-gradient(145deg, #6200ee, #9b5de5);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 30px;
  font-family: 'Orbitron', sans-serif;
  font-weight: bold;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  z-index: 1;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(107, 45, 179, 0.3);
}

.neo-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(107, 45, 179, 0.4);
}

.neo-button:active {
  transform: translateY(1px);
}

.neo-button::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(30deg);
  z-index: -1;
  transition: transform 0.5s ease;
}

.neo-button:hover::before {
  transform: rotate(0deg);
}

/* Message Styles */
.error, .error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fecaca;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.success-message {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Main Page */
.main-page {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Glass Effects */
.gradient-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.glass-effect {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Journal Styles */
.journal-container {
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #9b5de5 #f0f0f0;
}

.journal-container.dark {
  scrollbar-width: thin;
  scrollbar-color: #6b2db3 #2a2a2a;
}

.journal-container::-webkit-scrollbar {
  width: 12px;
}

.journal-container::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 10px;
}

.journal-container.dark::-webkit-scrollbar-track {
  background: #2a2a2a;
  border-radius: 10px;
}

.journal-container::-webkit-scrollbar-thumb {
  background-color: #9b5de5;
  border-radius: 10px;
  border: 2px solid #f0f0f0;
}

.journal-container.dark::-webkit-scrollbar-thumb {
  background-color: #6b2db3;
  border-radius: 10px;
  border: 2px solid #2a2a2a;
}

.journal-entries {
  max-height: calc(100vh - 350px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #9b5de5 #f0f0f0;
}

.dark .journal-entries {
  scrollbar-color: #6b2db3 #2a2a2a;
}

/* Dark Mode */
body.dark-mode {
  background-color: #121212;
}

/* Search Styles */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.logo {
  font-size: 36px;
  font-weight: bold;
}

#mode-toggle {
  padding: 5px 15px;
  background-color: #f0f0f0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s, color 0.3s;
}

#mode-toggle:hover {
  background-color: #e0e0e0;
}

.search-container {
  text-align: center;
}

.search-box {
  display: flex;
  justify-content: center;
  align-items: center;
}

#search-input {
  width: 500px;
  padding: 12px 15px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 25px 0 0 25px;
  background-color: #ffffff;
  color: #000000;
  outline: none;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

#search-button {
  padding: 12px 20px;
  font-size: 16px;
  background-color: #1a73e8;
  color: #ffffff;
  border: none;
  border-radius: 0 25px 25px 0;
  cursor: pointer;
  transition: background-color 0.3s;
  animation: pulse 1s linear infinite, glowing 2s ease-in-out infinite;
}

#search-button:hover {
  background-color: #1557b0;
}

/* Results */
.results-container {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  padding: 20px;
  overflow: auto;
}

.result, .result-item {
  margin-bottom: 20px;
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.result-title {
  color: #1a0dab;
  font-size: 18px;
  margin-bottom: 5px;
  text-decoration: none;
}

.result-title:hover {
  text-decoration: underline;
}

.result-url {
  color: #006621;
  font-size: 14px;
  margin-bottom: 5px;
}

.result-description {
  color: #545454;
  font-size: 14px;
  line-height: 1.5;
}

.result-item a {
  color: #1a0dab;
  text-decoration: none;
}

.result-item a:hover {
  text-decoration: underline;
}

/* Dark Mode Search Styles */
body.dark-mode #mode-toggle {
  background-color: #333;
  color: #ffffff;
}

body.dark-mode #mode-toggle:hover {
  background-color: #444;
}

body.dark-mode #search-input {
  background-color: #333;
  border-color: #555;
  color: #ffffff;
}

body.dark-mode #search-button {
  background-color: #8ab4f8;
}

body.dark-mode #search-button:hover {
  background-color: #6b9bf5;
}

body.dark-mode .result-item a {
  color: #8ab4f8;
}

/* Special Results */
.bjj-result p {
  max-height: none !important;
  overflow: visible !important;
  -webkit-line-clamp: unset !important;
  display: block !important;
}

/* Hover Effects */
.shimmer-effect {
  background: linear-gradient(90deg, 
    rgba(255,255,255,0) 0%, 
    rgba(255,255,255,0.2) 50%, 
    rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.card-hover:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 18px 30px rgba(0,0,0,0.25);
}

.stat-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 15px 30px rgba(0,0,0,0.3);
  z-index: 5;
}

.rp-container .gauge-background:hover {
  transform: scale(1.02);
  box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.rp-container .risk-value:hover {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

/* Gauge Elements */
.gauge-segments {
  position: relative;
  overflow: hidden;
}

.gauge-segments::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
  animation: gauge-pulse 3s infinite;
  pointer-events: none;
}

/* Loading Spinner */
.loading-spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 2px solid white;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

/* Button Pulse Effect */
.button-pulse {
  animation: button-pulse 0.8s cubic-bezier(0.66, 0, 0, 1);
}

.save-button:active, .reset-button:active {
  transform: scale(0.95) !important;
  transition: transform 0.1s;
}

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

@keyframes pulse {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

@keyframes glowing {
  0% { box-shadow: 0 0 5px rgba(155, 93, 229, 0.5); }
  50% { box-shadow: 0 0 20px rgba(155, 93, 229, 0.8), 0 0 30px rgba(155, 93, 229, 0.5); }
  100% { box-shadow: 0 0 5px rgba(155, 93, 229, 0.5); }
}

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

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

@keyframes floatIn {
  0% { transform: translateY(20px) scale(0.95); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

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

@keyframes gauge-pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes ripple {
  0% { transform: scale(0); opacity: 1; }
  80% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes button-pulse {
  0% { box-shadow: 0 0 0 0 rgba(107, 45, 179, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(107, 45, 179, 0); }
  100% { box-shadow: 0 0 0 0 rgba(107, 45, 179, 0); }
}

@keyframes success-indicator {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* Responsive Design */
@media (max-width: 480px) {
  .container {
    margin: 0;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
  }

  input, button {
    font-size: 16px;
    width: 100%;
  }

  .form-group {
    margin-bottom: 10px;
  }

  .journal-entries {
    max-height: calc(100vh - 280px);
  }

  label {
    font-size: 14px;
  }

  h1, h2 {
    font-size: 1.5rem;
  }

  .search-box {
    flex-direction: column;
    border-radius: 8px;
  }

  #search-button {
    width: 100%;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .container {
    margin: 5px;
    padding: 15px;
  }

  .journal-entries {
    max-height: calc(100vh - 320px);
  }

  h1, h2 {
    font-size: 1.8rem;
  }
}

@media (max-width: 600px) {
  .search-box {
    flex-direction: column;
    border-radius: 8px;
  }

  #search-button {
    width: 100%;
  }
}
