/* Typography Setup — fonts.css is now included in bundle.css */
/* @import url("./fonts.css"); */

/* Import Unified Component Styles — now in bundle.css */
/* @import url("./unified-styles.css"); */

/* ================================
   POOOL - Main CSS
   Base styles for the application
   ================================ */

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

body {
  font-family: 'TT Norms Pro', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* ================================
   App Layout Structure
   ================================ */

/* Main App Body */
.app-body {
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  min-height: 100vh;
}

/* App Wrapper - Contains Sidebar + Content */
.app-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Container */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 256px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e8e9eb;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Main Content Area */
.app-content {
  margin-left: 256px;
  width: calc(100% - 256px);
  min-height: 100vh;
  background: #fafafa;
  position: relative;
}

/* For pages without sidebar */
#app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

#main-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0;
}

/* ================================
   Unified Dashboard Page Layout
   Used for pages without page-specific CSS
   ================================ */

/* Core main content layout - consistent across all dashboard pages */
.dashboard-main {
  width: calc(100% - 256px);
  min-height: 100vh;
  margin-left: 256px;
  padding: 48px 24px 64px 24px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 0;
  box-sizing: border-box;
}

/* Inner container - constrains content to consistent width */
.dashboard-container {
  width: 100%;
  max-width: 1096px;
  margin: 0;
}

@media (max-width: 768px) {
  .dashboard-main {
    width: 100%;
    margin-left: 0;
    padding: 16px;
    padding-top: 80px;
  }
}

/* ================================
   Standard Page Header Pattern
   Icon + Title row (used by support, 
   and any other dashboard-main pages)
   ================================ */
.support-page-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.support-page-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.support-page-title {
  font-family: 'TT Norms Pro', sans-serif;
  font-style: normal;
  font-weight: 700;
  font-size: 36px;
  line-height: 44px;
  letter-spacing: -0.02em;
  color: var(--page-title-color);
  margin: 0;
}

.support-page-subtitle {
  font-family: 'TT Norms Pro', sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-secondary);
  margin: 0;
}

/* ================================
   Typography
   ================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'TT Norms Pro', sans-serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--page-title-color);
}

h1 {
  font-size: 32px;
  line-height: 40px;
}

h2 {
  font-size: 24px;
  line-height: 32px;
}

h3 {
  font-size: 20px;
  line-height: 28px;
}

h4 {
  font-size: 16px;
  line-height: 24px;
}

p {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-secondary);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  filter: brightness(0.85);
}

/* ================================
   Buttons
   ================================ */

button {
  font-family: 'TT Norms Pro', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  border: none;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--primary-color);
}

.btn-primary:hover {
  filter: brightness(0.85);
}

.btn-secondary {
  background: #ffffff;
  color: var(--page-title-color);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #e8e9eb;
}

.btn-secondary:hover {
  background: #f8f9fc;
  border-color: #d1d5db;
}

/* ================================
   Forms
   ================================ */

input,
textarea,
select {
  font-family: 'TT Norms Pro', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid #e8e9eb;
  border-radius: 8px;
  background: #ffffff;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 0, 255, 0.1);
}

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

/* ================================
   Cards
   ================================ */

.card {
  /* Sophisticated Apple HIG frosted glass with physical depth */
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.85) 100%);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 
      0 4px 6px -2px rgba(0, 0, 0, 0.02),
      0 12px 32px -4px rgba(0, 0, 0, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 1),
      inset 0 -1px 2px rgba(0, 0, 0, 0.01);
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
  will-change: transform, backdrop-filter;
  transform: translateZ(0);
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.45) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 24px 24px 0 0;
  z-index: 0;
}

.card > * {
  position: relative;
  z-index: 1;
}

/* ================================
   Utility Classes
   ================================ */

.container {
  width: 100%;
  max-width: 1144px;
  margin: 0 auto;
  padding: 0 24px;
}

.flex {
  display: flex;
}

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

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid {
  display: grid;
}

.hidden {
  display: none !important;
}

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

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mt-4 {
  margin-top: 32px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.mb-4 {
  margin-bottom: 32px;
}

.p-1 {
  padding: 8px;
}

.p-2 {
  padding: 16px;
}

.p-3 {
  padding: 24px;
}

.p-4 {
  padding: 32px;
}

/* ================================
   HTMX Indicators
   ================================ */

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Loading States */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e8e9eb;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ================================
   Alpine.js Utilities
   ================================ */

[x-cloak] {
  display: none !important;
}

/* ================================
   Scrollbar Styling
   ================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f8f9fc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ================================
   Responsive Design
   ================================ */

@media (max-width: 1440px) {
  .app-content {
    width: calc(100% - 256px);
  }
}

@media (max-width: 1024px) {
  .app-sidebar {
    width: 240px;
  }

  .app-content {
    margin-left: 240px;
    width: calc(100% - 240px);
  }
}

@media (max-width: 768px) {
  .app-wrapper {
    flex-direction: column;
  }

  .app-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #e8e9eb;
  }

  .app-content {
    margin-left: 0;
    width: 100%;
  }
}

/* ================================
   Transitions & View Transitions API
   ================================ */

/* Removed global transition rule that was interfering with specific component animations */
/* Components should define their own transition rules for better control */

/* ── Cross-document View Transitions (SPA-like page navigation) ── */

/* OPT-IN: Enable cross-document view transitions on every page.
   Both the departing and arriving page must declare this rule
   for the browser to run a view transition between them. */
@view-transition {
    navigation: auto;
}

@supports (view-transition-name: none) {
  ::view-transition,
  ::view-transition-group(*),
  ::view-transition-image-pair(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    pointer-events: none;
  }

  /* Sidebar stays perfectly static during page transitions.
     IMPORTANT: Only ONE element may have a given view-transition-name.
     Use the outermost wrapper to avoid duplicates when .sidebar is nested inside it. */
  #dynamic-sidebar-container {
    view-transition-name: sidebar;
  }

  /* Main content area animates between pages */
  .ds-main {
    view-transition-name: main-content;
  }

  /* ── Sidebar: no animation (stays pinned) ── */
  ::view-transition-old(sidebar),
  ::view-transition-new(sidebar) {
    animation: none;
  }

  /* ── Main content: subtle fade + slide ── */
  ::view-transition-old(main-content) {
    animation: vt-slide-out 220ms cubic-bezier(0.4, 0, 0.2, 1) both;
  }

  ::view-transition-new(main-content) {
    animation: vt-slide-in 280ms cubic-bezier(0, 0, 0.2, 1) both;
  }

  /* ── Root fallback (entire page cross-fade) ── */
  ::view-transition-old(root) {
    animation: vt-fade-out 180ms ease-out both;
  }

  ::view-transition-new(root) {
    animation: vt-fade-in 220ms ease-in both;
  }

  @keyframes vt-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
  }

  @keyframes vt-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  @keyframes vt-slide-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(6px); }
  }

  @keyframes vt-slide-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Reduce motion: respect user preference ── */
  @media (prefers-reduced-motion: reduce) {
    ::view-transition-old(main-content),
    ::view-transition-new(main-content),
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation-duration: 0.01ms !important;
    }
  }
}

/* ================================
   Z-Index Scale
   ================================ */

.z-0 {
  z-index: 0;
}

.z-10 {
  z-index: 10;
}

.z-20 {
  z-index: 20;
}

.z-30 {
  z-index: 30;
}

.z-40 {
  z-index: 40;
}

.z-50 {
  z-index: 50;
}

.z-100 {
  z-index: 100;
}
