/*!
 * SailingTracer Centralized Branding System
 * Complete CSS framework with variables, utility classes, and components
 * Load with: <link rel="stylesheet" href="/static/brand/brand.css">
 */

/* Import design tokens from variables.css */
@import url('./variables.css');

/* ===== TYPOGRAPHY SCALE ===== */
.text-xs { font-size: 12px; line-height: 1.4; }
.text-sm { font-size: 14px; line-height: 1.5; }
.text-base { font-size: 16px; line-height: 1.5; }
.text-lg { font-size: 18px; line-height: 1.4; }
.text-xl { font-size: 20px; line-height: 1.3; }
.text-2xl { font-size: 24px; line-height: 1.2; }

/* Font weights */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ===== TEXT COLOR CLASSES ===== */
.text-primary { color: var(--text-color); }
.text-accent { color: var(--accent-color); }
.text-success { color: var(--start-button-color); }
.text-danger { color: var(--stop-button-color); }
.text-muted { color: rgba(224, 224, 224, 0.7); }

/* ===== BUTTON SYSTEM ===== */
.button {
  background: var(--button-bg);
  color: var(--text-color);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;                      /* Touch-friendly height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.button:hover {
  background: var(--button-hover-bg);
}

.button:active {
  transform: scale(0.98);                /* Subtle press feedback */
}

.button:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Button Variants */
.button-primary {
  background: var(--accent-color);
  color: white;
}

.button-primary:hover {
  background: #35a89d;                   /* Slightly darker teal */
}

.button-success {
  background: var(--start-button-color);
  color: white;
}

.button-danger {
  background: var(--stop-button-color);
  color: white;
}

.button-ghost {
  background: transparent;
  border: 1px solid var(--border-color);
}

.button-ghost:hover {
  background: var(--button-bg);
  border-color: var(--accent-color);
}

/* ===== GLASSMORPHIC DESIGN PATTERNS ===== */
.glass-panel {
  background: var(--glass-bg);           /* Semi-transparent background */
  backdrop-filter: blur(10px);           /* Backdrop blur effect */
  -webkit-backdrop-filter: blur(10px);   /* Safari compatibility */
  border: 1px solid rgba(255, 255, 255, 0.18); /* Subtle light border */
  border-radius: 12px;                   /* Rounded corners */
  box-shadow: none;                      /* No shadow - glass effect */
}

.glass-floating {
  position: fixed;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 12px 16px 16px;
}

.glass-item {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.glass-item:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--accent-color);
  transform: translateY(-2px);           /* Subtle lift effect */
}

/* ===== MODAL & POPUP SYSTEM ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);        /* 70% opacity backdrop */
  z-index: 10000;                        /* Always above content */
  display: flex;                         /* Flexbox centering */
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease forwards;
}

.modal-overlay {
  display: none;                         /* Hidden by default */
}

.modal-overlay.open {
  display: flex;                         /* Show when open */
}

.modal-content {
  background: var(--popup-bg);
  padding: 25px 30px;
  border-radius: 10px;
  width: 450px;
  max-width: 90vw;                       /* Responsive width */
  max-height: 80vh;                      /* Prevent viewport overflow */
  overflow-y: auto;                      /* Scroll for long content */
  box-shadow: 0 6px 20px var(--shadow-color);
  animation: slideIn 0.3s ease forwards;
  position: relative;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-weight: 500;
  color: var(--accent-color);            /* Teal accent for headers */
  text-align: center;
  font-size: 20px;
}

/* ===== FORM ELEMENTS ===== */
.form-input {
  background: var(--control-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  min-height: 44px;
  transition: border-color 0.2s ease;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(61, 193, 182, 0.2);
}

.form-label {
  color: var(--text-color);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  display: block;
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

/* ===== LIST ITEMS & CARDS ===== */
.list-item {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.list-item:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.98);
}

.list-item strong {
  color: var(--accent-color);            /* Highlight important text */
}

/* Card Component */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: var(--spacing-lg);
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  color: var(--accent-color);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.card-content {
  color: var(--text-color);
  line-height: 1.5;
}

/* ===== SPACING UTILITIES ===== */
/* Padding utilities */
.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

/* Margin utilities */
.m-xs { margin: var(--spacing-xs); }
.m-sm { margin: var(--spacing-sm); }
.m-md { margin: var(--spacing-md); }
.m-lg { margin: var(--spacing-lg); }
.m-xl { margin: var(--spacing-xl); }

/* Gap utilities (for flexbox/grid) */
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* ===== ACCESSIBILITY & FOCUS ===== */
.focus-visible:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Touch target minimum size */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { 
    opacity: 0; 
    transform: scale(0.9); 
  }
  to { 
    opacity: 1; 
    transform: scale(1); 
  }
}

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

/* Transition utilities */
.transition-fast { transition: all 0.15s ease; }
.transition-normal { transition: all 0.2s ease; }
.transition-slow { transition: all 0.3s ease; }

/* Hover effects */
.hover-lift:hover {
  transform: translateY(-2px);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.active-press:active {
  transform: scale(0.98);
}

/* ===== LAYOUT UTILITIES ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (min-width: 640px) {
  .container { padding: 0 24px; }
}

@media (min-width: 1024px) {
  .container { padding: 0 32px; }
}

@media (max-width: 768px) {
  .touch-target {
    min-height: 44px;                    /* iOS guidelines */
    padding: 10px 12px;
  }
  
  .modal-content {
    width: 90%;
    padding: 15px;
  }
  
  .modal-content h2 {
    font-size: 18px;                     /* Smaller on mobile */
  }
  
  .button {
    padding: 12px 16px;                  /* Larger touch area */
  }
  
  .text-responsive {
    font-size: 16px;                     /* Prevent zoom on focus */
  }
}

/* ===== LOGO HELPER CLASSES ===== */
.logo-standard {
  background-image: var(--logo-standard);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.logo-white {
  background-image: var(--logo-white);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Logo as IMG src helpers - use with JavaScript */
.js-logo-standard::after {
  content: var(--logo-standard-url);
  display: none;
}

.js-logo-white::after {
  content: var(--logo-white-url);
  display: none;
}

/* ===== MARITIME GRID BACKGROUND ===== */
/* Navigation chart-style grid background for consistent maritime identity */

/* Div-based maritime grid background - use with <div class="maritime-grid-background"></div> */
.maritime-grid-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
  /* Navigation chart style grid - every 3rd line (150px) is thicker */
  background-image: 
    /* Major grid lines every 150px (3 * 50px) - thicker like navigation chart coordinates */
    linear-gradient(rgba(255, 255, 255, 0.15) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.15) 2px, transparent 2px),
    /* Minor grid lines every 50px - subtle like chart subdivisions */
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 
    150px 150px, /* Major coordinate lines every 3rd line */
    150px 150px,
    50px 50px,   /* Minor subdivision lines */
    50px 50px;
  animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.25; }
}

/* Ensure pages have proper positioning context for the maritime grid */
.maritime-page-container {
  position: relative;
  min-height: 100vh;
  width: 100%;
}

/* Ensure html and body extend to full document height */
html {
  height: 100%;
  position: relative; /* Provide positioning context for HTML-level grid */
}

body {
  min-height: 100%;
  position: relative;
}

/* For HTML-level grid placement (Keycloak themes) - ensure proper coverage */
html > .maritime-grid-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

/* ===== GLOBAL LOADING ANIMATION ===== */
/* Fullscreen loading overlay for page transitions */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(30, 30, 30, 0.95);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.loading-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

/* Spinning loader animation */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(61, 193, 182, 0.2);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Optional loading text */
.loading-text {
  position: absolute;
  bottom: calc(50% - 60px);
  color: var(--accent-color);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }
  
  .loading-text {
    font-size: 12px;
  }
}

/* ===== STAGGERED CARD ANIMATIONS ===== */
/* Entrance animation for session cards - fade in + slide up */
@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.session-card-enter {
  animation: cardEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
}

/* Subtle hover enhancement */
.session-card-enter:hover {
  animation-play-state: running;
}
