/* =============================================================================
   PORTAL LAYOUT STYLES
   Extracted from portal.html.erb to enable caching
   ============================================================================= */

/* Override DaisyUI success color to green (was in inline styles) */
:where(:root),
:root:has(input.theme-controller[value=trenly]:checked),
[data-theme="trenly"] {
  --color-success: oklch(55% 0.15 155) !important;
}

/* Override brand theme colors (DaisyUI 5 + Tailwind v4 doesn't read tailwind.config.js) */
[data-theme="brand"] {
  --color-base-100: oklch(100% 0 0) !important;
  --color-base-200: oklch(96% .012 270) !important;
  --color-base-300: oklch(93% .015 270) !important;
  --color-base-content: oklch(25% .02 270) !important;
  --color-primary: oklch(34% .16 305) !important;  /* Deep purple - same as light theme */
  --color-primary-content: oklch(98% 0 0) !important;
  --color-info: oklch(88.2% .059 254.128) !important;
  --color-info-content: oklch(27.8% .033 256.848) !important;
}

/* Font size variables */
:root {
  --ct-font-size-base: 1rem;
  --ct-font-size-lg: 1.125rem;
  --ct-font-size-sm: 0.875rem;
  --condition-report-surface-lavender-50: #fcf9ff;
  --condition-report-surface-lavender-100: #fbf8ff;
  --condition-report-surface-lavender-200: #f8f6ff;
  --condition-report-surface-lavender-300: #fefbfd;
  --condition-report-surface-lavender-400: #fffafb;
  --condition-report-surface-lavender-500: #fcfbff;
}

/* Mobile font size adjustments */
@media (max-width: 991.98px) {
  :root {
    --ct-font-size-base: 1.1rem !important;
    --ct-font-size-lg: 1.25rem !important;
    --ct-font-size-sm: 1rem !important;
  }

  html {
    font-size: 16px !important;
  }

  body {
    font-size: var(--ct-font-size-base) !important;
  }

  .card-title {
    font-size: 1.25rem !important;
  }

  .nav-link {
    font-size: var(--ct-font-size-base) !important;
  }

  .dropdown-item {
    font-size: var(--ct-font-size-base) !important;
  }

  .btn {
    font-size: var(--ct-font-size-base) !important;
  }

  .small, small {
    font-size: var(--ct-font-size-sm) !important;
  }
}

/* =============================================================================
   SIDEBAR LAYOUT - Main Content Area
   ============================================================================= */

html {
  height: 100%;
}

body {
  background-color: oklch(var(--b1));
  min-height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

#wrapper.sidebar-layout {
  display: flex;
  margin: 0 !important;
  padding: 0;
  position: relative;
  top: 0;
  left: 0;
  flex: 1;
}

.main-content {
  flex: 1;
  margin-left: 280px;
  min-width: 0;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  margin-top: 0;
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  overflow: hidden !important;
}

.content-page {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  margin: 0;
  background-color: oklch(var(--b1));
}

/* Turbo frame needs width since we removed .content wrapper */
turbo-frame#content {
  display: block;
  width: 100%;
}

/* Portal Footer - pinned at bottom of main-content */
.portal-footer {
  width: 100%;
  flex-shrink: 0;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(88, 28, 135, 0.06) 0%, #ffffff 65%);
  border-top: 1px solid oklch(var(--b3));
}


/* Hide turbo stream source elements from flex layout */
turbo-cable-stream-source {
  display: none !important;
}

/* Exclude modal containers from body flex layout */
body > div[data-controller],
body > turbo-frame#modal,
body > #modal-container,
body > #crud-drawer-container {
  position: fixed;
}

@media (max-width: 1024px) {
  .content-page {
    padding: 1rem 1rem 0 1rem;
  }
}

@media (max-width: 640px) {
  .content-page {
    padding: 0.5rem 0.5rem 0 0.5rem;
  }
}


/* =============================================================================
   MPR CTA BUTTON (Dashboard header)
   ============================================================================= */

.mpr-cta-link {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: oklch(var(--p) / 0.08);
  border: 1px solid oklch(var(--p) / 0.18);
  border-radius: 8px;
  color: oklch(var(--p));
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mpr-cta-link:hover {
  background: oklch(var(--p) / 0.14);
  border-color: oklch(var(--p) / 0.3);
  color: oklch(var(--p));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px oklch(var(--p) / 0.12);
}

.mpr-cta-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: oklch(var(--p));
  color: oklch(var(--pc));
  border-radius: 9999px;
  line-height: 1.5;
  animation: mpr-pulse 3s ease-in-out infinite;
}

@keyframes mpr-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* =============================================================================
   MOBILE HEADER - Glass Morphism
   ============================================================================= */

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  z-index: 1040;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
}

/* Light theme mobile header */
[data-theme="light"] .mobile-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Dark theme mobile header - glass effect */
[data-theme="dark"] .mobile-header {
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Corporate theme mobile header */
[data-theme="corporate"] .mobile-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Brand theme mobile header - navy glass */
[data-theme="brand"] .mobile-header {
  background: rgba(10, 25, 41, 0.9);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(6, 182, 212, 0.15);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* =============================================================================
   MOBILE MENU TOGGLE
   ============================================================================= */

.mobile-menu-toggle {
  width: 38px;
  height: 38px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.mobile-menu-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  transform: scale(1.02);
}

.mobile-menu-toggle.active {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
}

.mobile-menu-toggle i {
  font-size: 1.125rem;
  color: #0f172a;
  transition: opacity 0.2s ease, transform 0.3s ease;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.mobile-menu-toggle i.fa-times {
  transform: translate(-50%, -50%) rotate(0deg);
}

.mobile-menu-toggle.active i {
  color: #dc2626;
}

/* Dark theme toggle */
[data-theme="dark"] .mobile-menu-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .mobile-menu-toggle i {
  color: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .mobile-menu-toggle.active {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .mobile-menu-toggle.active i {
  color: #ef4444;
}

/* Brand theme toggle */
[data-theme="brand"] .mobile-menu-toggle {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.2);
}

[data-theme="brand"] .mobile-menu-toggle:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
}

[data-theme="brand"] .mobile-menu-toggle i {
  color: rgba(255, 255, 255, 0.95);
}

[data-theme="brand"] .mobile-menu-toggle.active {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.3);
}

[data-theme="brand"] .mobile-menu-toggle.active i {
  color: #ef4444;
}

/* =============================================================================
   MOBILE LOGO
   ============================================================================= */

.mobile-logo {
  flex: 1;
  display: flex;
  justify-content: center;
}

.mobile-logo-img {
  height: 22px;
  width: auto;
  opacity: 0.95;
}

/* Mobile logo visibility - default (dark theme) */
.mobile-logo-img.logo-light {
  display: block;
}

.mobile-logo-img.logo-dark {
  display: none;
}

/* Light and corporate themes - show dark logo */
[data-theme="light"] .mobile-logo-img.logo-light,
[data-theme="corporate"] .mobile-logo-img.logo-light {
  display: none;
}

[data-theme="light"] .mobile-logo-img.logo-dark,
[data-theme="corporate"] .mobile-logo-img.logo-dark {
  display: block;
}

/* Dark and brand themes - show light logo */
[data-theme="dark"] .mobile-logo-img.logo-light,
[data-theme="brand"] .mobile-logo-img.logo-light {
  display: block;
}

[data-theme="dark"] .mobile-logo-img.logo-dark,
[data-theme="brand"] .mobile-logo-img.logo-dark {
  display: none;
}

/* Trenly theme - show dark logo */
[data-theme="trenly"] .mobile-logo-img.logo-light {
  display: none !important;
}

[data-theme="trenly"] .mobile-logo-img.logo-dark {
  display: block !important;
}

.mobile-spacer {
  width: 40px;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 1024px) {
  .mobile-header {
    display: flex;
  }

  /* Hide mobile header when sidebar is open */
  body.sidebar-open .mobile-header {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding-top: 60px;
  }

  body.sidebar-open .main-content {
    padding-top: 0;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1029;
  animation: fadeIn 0.3s ease;
}

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

/* Force sidebar to show on mobile when open */
@media (max-width: 1024px) {
  body .sidebar-nav.mobile-open {
    left: 0 !important;
    transform: translateX(0) !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    z-index: 1050 !important;
  }
}

/* =============================================================================
   UTILITY STYLES
   ============================================================================= */

/* Custom spinner animation to prevent drift */
.fa-custom-spin {
  animation: fa-custom-spin-animation 1s infinite linear;
}

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

/* PII Masking Styles */
.masked {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  cursor: default;
  font-family: monospace;
  letter-spacing: 0.1em;
}
