/* File: static/css/main.css */
/* Crisis Prevention Platform - Main Styles */

/* ===== CUSTOM PROPERTIES ===== */
:root {
  /* Light mode colors */
  --color-primary: #0A192F;
  --color-accent: #007BFF;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-light-bg: #F8FAFC;
  --color-white: #FFFFFF;
  
  /* Dark mode colors */
  --color-dark-primary: #0f172a;
  --color-dark-secondary: #1e293b;
  --color-dark-card: #334155;
  --color-dark-border: #475569;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 16px;
  --line-height-base: 1.6;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border radius */
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: var(--font-size-base);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left var(--transition-slow);
}

.btn:hover::before {
  left: 100%;
}

.btn:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border: 2px solid var(--color-accent);
}

.btn-secondary:hover {
  background: var(--color-accent);
  color: white;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-success));
  transform: scaleX(0);
  transition: transform var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.card:hover::before {
  transform: scaleX(1);
}

/* ===== ANIMATIONS ===== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

/* ===== FORMS ===== */
.form-input {
  width: 100%;
  padding: var(--spacing-md);
  border: 2px solid #e5e7eb;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  transition: all var(--transition-base);
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-input::placeholder {
  color: #9ca3af;
}

/* ===== NAVIGATION ===== */
.nav-link {
  position: relative;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-base);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: all var(--transition-base);
  transform: translateX(-50%);
}

.nav-link:hover::after {
  width: 80%;
}

/* ===== MODALS ===== */
.modal-backdrop {
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== GRADIENTS ===== */
.gradient-hero {
  background: linear-gradient(135deg, var(--color-accent) 0%, #1e40af 50%, #1e3a8a 100%);
  position: relative;
}

.gradient-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.05"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.05"/><circle cx="50" cy="10" r="1" fill="white" opacity="0.03"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  pointer-events: none;
}

/* ===== FEATURE ICONS ===== */
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: var(--color-light-bg);
  border-radius: var(--border-radius-lg);
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  transition: all var(--transition-base);
}

.feature-icon:hover {
  transform: rotate(5deg) scale(1.1);
  background: var(--color-accent);
  color: white;
}

/* ===== SCROLL INDICATOR ===== */
.scroll-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-success));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.1s ease-out;
  z-index: 1000;
}

/* ===== LOADING STATES ===== */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ===== STATUS INDICATORS ===== */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-md);
  font-size: 0.875rem;
  font-weight: 500;
}

.status-indicator.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.status-indicator.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.status-indicator.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet and Mobile - Simplified breakpoint */
@media (max-width: 1024px) {
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }
  
  .btn {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 0.875rem;
  }
}

/* Mobile Only - Essential fixes */
@media (max-width: 640px) {
  /* Demo results mobile fixes */
  #demo-results {
    padding: 1rem !important;
    margin: 0.5rem !important;
    max-width: calc(100vw - 2rem) !important;
    overflow-x: hidden;
  }
  
  /* Fix label containers breaking out of bounds */
  .text-xs.bg-blue-100,
  .text-xs.bg-red-100,
  .text-xs.bg-orange-100,
  .text-xs.bg-green-100 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
    font-size: 0.6rem !important;
    padding: 2px 4px !important;
    line-height: 1.2;
  }
  
  /* Authority positioning labels */
  .bg-gradient-to-r.from-purple-100.to-blue-100,
  .bg-gradient-to-r.from-green-100.to-blue-100 {
    white-space: normal;
    word-wrap: break-word;
    max-width: 120px;
    font-size: 0.65rem !important;
    padding: 3px 6px !important;
  }
  
  /* Mobile form optimizations */
  .form-input {
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 0.875rem !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }
  
  .form-input:focus {
    outline: none !important;
    border-color: #007BFF !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
    transform: scale(1.02) !important;
    transition: all 0.2s ease !important;
  }
  
  /* Score breakdown mobile */
  .grid.grid-cols-2.md\\:grid-cols-4 {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  
  /* Company info grid mobile */
  .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  
  /* Text wrapping for long technical terms */
  .text-primary,
  .text-gray-600,
  .text-gray-700 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  /* Header text mobile sizing */
  h4.font-bold.text-lg {
    font-size: 1rem !important;
    line-height: 1.3 !important;
  }
  
  h5.font-bold {
    font-size: 0.9rem !important;
    line-height: 1.3 !important;
  }
  
  /* Risk score circle mobile */
  .w-28.h-28 {
    width: 5rem !important;
    height: 5rem !important;
  }
  
  .w-32.h-32 {
    width: 6rem !important;
    height: 6rem !important;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .text-3xl {
    font-size: 1.5rem !important;
  }
  
  .text-2xl {
    font-size: 1.25rem !important;
  }
  
  .text-xl {
    font-size: 1.1rem !important;
  }
  
  /* Authority position badges - extra small */
  .text-xs {
    font-size: 0.55rem !important;
  }
}

/* Landscape mobile adjustments */
@media (max-width: 1024px) and (orientation: landscape) {
  #demo-results {
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

*:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

/* Consultation CTA button mobile fix */
@media (max-width: 376px) {
  #consultation-cta-btn {
    max-width: 100%;
    padding: 0.75rem 1rem !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    text-align: center !important;
    display: block !important;
  }
}
