/* main.css - Main Application Styles */

/* ============================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ============================================ */

:root {
  /* ── Unified LPO Color System ────────────────────────────────────────── */
  --fa-primary: #283655;
  --fa-primary-hover: #1e2a43;
  --fa-primary-light: #3d4f73;
  --fa-primary-surface: #ebeef3;
  --fa-primary-10: rgba(40, 54, 85, 0.1);
  --fa-primary-20: rgba(40, 54, 85, 0.2);

  --fa-bg: #FFFFFF;
  --fa-bg-alt: #f8f9fb;
  --fa-text-on-primary: #FFFFFF;
  --fa-text-primary: #283655;
  --fa-text-secondary: #4a5568;
  --fa-text-muted: #718096;

  --fa-accent: #DFA774;
  --fa-accent-hover: #d4955f;
  --fa-accent-light: #e8bf9a;
  --fa-accent-surface: #fdf5ed;
  --fa-accent-10: rgba(223, 167, 116, 0.1);

  --fa-gradient-primary: linear-gradient(135deg, #283655 0%, #1e2a43 100%);
  --fa-gradient-surface: linear-gradient(135deg, #f8f9fb 0%, #ebeef3 100%);

  /* Semantic colors (unchanged) */
  --fa-success: #28a745;
  --fa-success-bg: #d4edda;
  --fa-warning: #f59e0b;
  --fa-warning-bg: #fff3cd;
  --fa-error: #dc2626;
  --fa-error-bg: #f8d7da;
  --fa-info: #283655;
  --fa-info-bg: #ebeef3;

  /* ── Z-Index Management System ───────────────────────────────────────── */
  --z-index-base: 1;
  --z-index-dropdown: 100;
  --z-index-sticky: 200;
  --z-index-fixed: 300;
  --z-index-modal-backdrop: 400;
  --z-index-modal: 500;
  --z-index-tooltip: 600;
  --z-index-notification: 700;
  --z-index-header: 1000;
  --z-index-dropdown-content: 1000;
  --z-index-profile-dropdown: 9998;
  --z-index-profile-dropdown-content: 9999;
  --z-index-maximum: 10000;
}

/* ============================================
   ACCESSIBILITY: Skip link (visible on focus)
   ============================================ */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: var(--z-index-maximum);
  padding: 0.75rem 1rem;
  background: #333;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 4px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ============================================
   UTILITY: visibility (no inline style in JS — project rule)
   ============================================ */
.is-hidden {
  display: none !important;
}

#loading-indicator.loading-hidden {
  display: none !important;
}

#main-content.main-visible {
  display: block !important;
  visibility: visible !important;
  min-height: 60vh;
}

.error-container {
  padding: 20px;
  text-align: center;
}

/* ============================================
   GLOBAL RESET & BASE STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--fa-text-primary);
  background-color: var(--fa-bg-alt);
  min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--fa-primary);
}

h1 {
  font-size: 2.5rem;
}
h2 {
  font-size: 2rem;
}
h3 {
  font-size: 1.75rem;
}
h4 {
  font-size: 1.5rem;
}
h5 {
  font-size: 1.25rem;
}
h6 {
  font-size: 1rem;
}

p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

a {
  color: var(--fa-accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--fa-accent-hover);
  text-decoration: underline;
}

/* ============================================
   LAYOUT CONTAINERS
   ============================================ */

.main-container {
  min-height: calc(100vh - 140px); /* Account for header + footer */
  padding: 20px 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-fluid {
  width: 100%;
  padding: 0 20px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 100px;
  line-height: 1;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

/* Button Variants */
.btn-primary {
  background-color: var(--fa-primary);
  color: white;
  border: 2px solid var(--fa-primary);
}

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

.btn-secondary {
  background-color: var(--fa-accent);
  color: var(--fa-primary);
  border: 2px solid var(--fa-accent);
}

.btn-secondary:hover {
  background-color: var(--fa-accent-hover);
  border-color: var(--fa-accent-hover);
  color: var(--fa-primary);
}

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

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

.btn-danger {
  background-color: #f44336;
  color: white;
  border: 2px solid #f44336;
}

.btn-danger:hover {
  background-color: #d32f2f;
  border-color: #d32f2f;
  color: white;
}

.btn-warning {
  background-color: #ff9800;
  color: white;
  border: 2px solid #ff9800;
}

.btn-warning:hover {
  background-color: #f57c00;
  border-color: #f57c00;
  color: white;
}

.btn-success {
  background-color: var(--fa-success);
  color: white;
  border: 2px solid var(--fa-success);
}

.btn-info {
  background-color: var(--fa-primary);
  color: white;
  border: 2px solid var(--fa-primary);
}

/* Button Sizes */
.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
  min-width: 80px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
  min-width: 120px;
}

.btn-block {
  width: 100%;
  display: block;
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--fa-primary);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: #fff;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--fa-primary);
  box-shadow: 0 0 0 3px var(--fa-primary-10);
}

.form-control:invalid {
  border-color: #f44336;
}

.form-control:disabled {
  background-color: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

/* Password Toggle */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input[type='password'],
.password-wrapper input[type='text'] {
  flex: 1;
  padding-right: 2.5rem;
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #666;
  font-size: 16px;
}

.toggle-password:hover {
  color: var(--fa-accent);
}

/* ============================================
   CARDS & PANELS
   ============================================ */

.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.card-header {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.card-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--fa-primary);
}

.card-body {
  flex: 1;
}

.card-footer {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #eee;
}

/* ============================================
   GRID SYSTEMS
   ============================================ */

.grid {
  display: grid;
  gap: 20px;
}

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

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-responsive {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* ============================================
   FLEX UTILITIES
   ============================================ */

.d-flex {
  display: flex;
}
.flex-column {
  flex-direction: column;
}
.flex-row {
  flex-direction: row;
}
.justify-content-center {
  justify-content: center;
}
.justify-content-between {
  justify-content: space-between;
}
.justify-content-around {
  justify-content: space-around;
}
.align-items-center {
  align-items: center;
}
.align-items-start {
  align-items: flex-start;
}
.align-items-end {
  align-items: flex-end;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1;
}

/* ============================================
   SPACING UTILITIES
   ============================================ */

.m-0 {
  margin: 0;
}
.m-1 {
  margin: 0.25rem;
}
.m-2 {
  margin: 0.5rem;
}
.m-3 {
  margin: 1rem;
}
.m-4 {
  margin: 1.5rem;
}
.m-5 {
  margin: 3rem;
}

.p-0 {
  padding: 0;
}
.p-1 {
  padding: 0.25rem;
}
.p-2 {
  padding: 0.5rem;
}
.p-3 {
  padding: 1rem;
}
.p-4 {
  padding: 1.5rem;
}
.p-5 {
  padding: 3rem;
}

/* Directional spacing */
.mt-3 {
  margin-top: 1rem;
}
.mb-3 {
  margin-bottom: 1rem;
}
.ml-3 {
  margin-left: 1rem;
}
.mr-3 {
  margin-right: 1rem;
}

.pt-3 {
  padding-top: 1rem;
}
.pb-3 {
  padding-bottom: 1rem;
}
.pl-3 {
  padding-left: 1rem;
}
.pr-3 {
  padding-right: 1rem;
}

/* ============================================
   TEXT UTILITIES
   ============================================ */

.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}

.text-primary {
  color: var(--fa-primary);
}
.text-secondary {
  color: var(--fa-accent);
}
.text-success {
  color: var(--fa-success);
}
.text-danger {
  color: var(--fa-error);
}
.text-warning {
  color: var(--fa-warning);
}
.text-info {
  color: var(--fa-primary);
}
.text-muted {
  color: var(--fa-text-muted);
}

.font-weight-normal {
  font-weight: 400;
}
.font-weight-bold {
  font-weight: 600;
}

/* ============================================
   DISPLAY UTILITIES
   ============================================ */

.d-none {
  display: none !important;
}
.d-block {
  display: block !important;
}
.d-inline {
  display: inline !important;
}
.d-inline-block {
  display: inline-block !important;
}

/* ============================================
   LOADING & SPINNERS
   ============================================ */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.loading-spinner i {
  font-size: 2rem;
  animation: spin 1s linear infinite;
}

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loader-spinner {
  text-align: center;
}

.loader-spinner i {
  font-size: 2rem;
  color: var(--fa-primary);
  margin-bottom: 10px;
}

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

/* ============================================
   ANIMATIONS
   ============================================ */

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

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

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

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

/* ============================================
   ERROR HANDLING
   ============================================ */

.noscript-warning {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  text-align: center;
  padding: 20px;
}

.error-banner {
  background: #f44336;
  color: white;
  padding: 20px;
  text-align: center;
  border-radius: 8px;
  margin: 20px;
}

.error-content {
  max-width: 600px;
  margin: 0 auto;
}

.error-content h3 {
  margin-bottom: 10px;
  color: white;
}

.retry-button {
  background: white;
  color: #f44336;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 15px;
  font-weight: 500;
}

.retry-button:hover {
  background: #f5f5f5;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  h1 {
    font-size: 2rem;
  }
  h2 {
    font-size: 1.75rem;
  }
  h3 {
    font-size: 1.5rem;
  }

  .card {
    padding: 16px;
    margin-bottom: 15px;
  }
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .btn-block {
    width: 100%;
    margin-bottom: 10px;
  }

  .main-container {
    padding: 10px 0;
  }
}

/* ============================================
   VISIBILITY UTILITIES
   (Moved from legacy navigation.css)
   ============================================ */

.force-visible {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.force-hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Auth-dependent element visibility */
[data-auth-required].auth-visible,
[data-user-only].auth-visible,
[data-admin-only].auth-visible { display: block !important; }
[data-auth-required].auth-hidden,
[data-user-only].auth-hidden,
[data-admin-only].auth-hidden { display: none !important; }
[data-guest-only].guest-visible { display: block !important; }
[data-guest-only].guest-hidden { display: none !important; }

.nav-element-visible { display: inline-block !important; }
.nav-element-hidden { display: none !important; }

.user-info-visible { display: block !important; }
.user-info-hidden { display: none !important; }

/* Upgrade modal */
#upgrade-modal.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
#upgrade-modal.modal-overlay.show { display: flex !important; }
.upgrade-modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  max-width: 400px;
  text-align: center;
}
.upgrade-modal-actions { margin: 1rem 0; }
.upgrade-modal-btn-cancel {
  margin-right: 1rem;
  padding: 0.5rem 1rem;
  background: #ccc;
  border: none;
  border-radius: 4px;
}
.upgrade-modal-btn-upgrade {
  padding: 0.5rem 1rem;
  background: var(--fa-accent);
  color: var(--fa-primary);
  border: none;
  border-radius: 4px;
}
