/* ==========================================================================
   APPLE LIQUID GLASS DESIGN SYSTEM (Premium Dark Mode)
   ========================================================================== */
:root {
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Core Colors */
  --bg-color: #0d0d12;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  
  /* Apple Glass Variables */
  --glass-bg: rgba(28, 28, 35, 0.45);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-highlight: rgba(255, 255, 255, 0.25);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  
  /* Accent Colors (Muted, premium Apple-style) */
  --accent-color: #32d74b; /* iOS Green */
  --accent-blue: #0a84ff; /* iOS Blue */
  --accent-red: #ff453a; /* iOS Red */
  
  /* Transitions */
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.15);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --- Ambient Mesh Gradient Background --- */
.mesh-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background-color: #0d0d12;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(50, 215, 75, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(10, 132, 255, 0.12) 0%, transparent 50%);
  filter: blur(80px);
  pointer-events: none;
}

/* ==========================================================================
   GLASSMORPHISM BASE CLASS (Liquid Glass)
   ========================================================================== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--spring);
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==========================================================================
   HEADER COMPONENT
   ========================================================================== */
.main-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 24px;
  z-index: 10;
}

.header-logo-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 44px;
  width: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-info h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-info .tagline {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.glass-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 12px;
  font-family: var(--font-family-sans);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  outline: none;
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.02);
}

.glass-btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.btn-primary:hover {
  background: #f0f0f0;
}

.btn-primary.active {
  background: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.btn-secondary {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

/* ==========================================================================
   CANVAS GRID SYSTEM (Desktop)
   ========================================================================== */
.canvas-workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.carousel-container {
  width: 100%;
}

.canvas-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, minmax(240px, auto)) auto;
  gap: 16px;
}

.canvas-block {
  display: flex;
  flex-direction: column;
  padding: 20px;
  z-index: 2;
}

.canvas-block:hover {
  border-color: var(--glass-border-highlight);
}

/* Grid Spanning */
.col-1 { grid-column: 1; }
.col-2 { grid-column: 2; }
.col-3 { grid-column: 3; }
.col-4 { grid-column: 4; }
.col-5 { grid-column: 5; }

.row-1 { grid-row: 1; }
.row-2 { grid-row: 2; }
.row-3 { grid-row: 3; }

.row-1-2 { grid-row: 1 / span 2; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

/* Highlight Value Proposition */
.highlight-panel {
  background: rgba(10, 132, 255, 0.08); /* Subtle blue tint */
  border: 1px solid rgba(10, 132, 255, 0.3);
}

/* ==========================================================================
   BLOCK CONTENT
   ========================================================================== */
.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  z-index: 3;
}

.block-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.block-icon {
  font-size: 18px;
  opacity: 0.8;
}

.block-body {
  flex-grow: 1;
  z-index: 3;
}

.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-list li {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  border: 0.5px solid transparent;
  transition: all 0.2s var(--ease);
}

.item-list li:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.item-list li p {
  flex-grow: 1;
}

/* Delete item button */
.delete-btn {
  background: none;
  border: none;
  color: var(--accent-red);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.edit-active .delete-btn {
  opacity: 0.7;
  pointer-events: auto;
}

.edit-active .delete-btn:hover {
  opacity: 1;
}

/* Plus button for editing */
.add-item-trigger {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  width: 100%;
  padding: 10px;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: none;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.edit-active .add-item-trigger {
  display: flex;
}

.add-item-trigger:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.block-footer {
  display: flex;
  justify-content: flex-start;
  margin-top: 16px;
  z-index: 3;
}

.expand-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}

.expand-btn:hover {
  text-decoration: underline;
}

/* Persona Badge */
.persona-badge {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(10, 132, 255, 0.1);
  border: 1px solid rgba(10, 132, 255, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-blue);
  justify-content: flex-start;
}

.persona-avatar-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* ==========================================================================
   FINANCIAL SIMULATOR
   ========================================================================== */
.simulator-panel {
  padding: 24px 30px;
}

.sim-header {
  margin-bottom: 24px;
}

.sim-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.sim-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
}

.sim-inputs {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
}

.slider-val {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
}

/* Apple-style range slider */
.apple-slider {
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.apple-slider::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sim-outputs {
  display: flex;
  gap: 12px;
}

.metric-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  border-radius: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.margin-box {
  background: rgba(50, 215, 75, 0.08);
  border-color: rgba(50, 215, 75, 0.2);
}

.metric-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.text-green { color: var(--accent-color); }
.text-red { color: #ff6961; }

/* ==========================================================================
   APPLE NATIVE DIALOGS (MODALS)
   ========================================================================== */
.apple-dialog {
  margin: auto;
  border: 1px solid var(--glass-border);
  background: rgba(28, 28, 35, 0.7);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
  border-radius: 24px;
  max-width: 600px;
  width: 90%;
  color: var(--text-primary);
  outline: none;
  
  /* Entrance animation */
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--spring), display 0.3s allow-discrete;
}

.apple-dialog[open] {
  opacity: 1;
  transform: scale(1);
}

@starting-style {
  .apple-dialog[open] {
    opacity: 0;
    transform: scale(0.95);
  }
}

.apple-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s var(--ease), display 0.3s allow-discrete;
}

.apple-dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  .apple-dialog[open]::backdrop {
    opacity: 0;
  }
}

.dialog-drag-handle {
  display: none;
}

.dialog-content {
  padding: 30px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dialog-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.icon-btn-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.icon-btn-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.dialog-body {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.dialog-body h3, .dialog-body h4 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 20px 0 10px 0;
}

.dialog-body h3:first-child {
  margin-top: 0;
}

.dialog-body ul {
  padding-left: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Persona Dialog Specifics */
.persona-dialog-layout {
  max-width: 700px;
}

.persona-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 30px;
}

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

.persona-avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.persona-core-info h3 {
  font-size: 20px;
  margin: 0;
}

.persona-core-info .role {
  font-size: 13px;
  color: var(--accent-blue);
  font-weight: 500;
}

.persona-quote {
  font-style: italic;
  font-size: 14px;
  margin-top: 20px;
  color: var(--text-tertiary);
}

.details-section h4 {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

/* Mini Dialog Forms */
.mini-dialog { max-width: 400px; }

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.apple-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font-family-sans);
  font-size: 15px;
  outline: none;
  min-height: 80px;
  resize: vertical;
  transition: all 0.2s var(--ease);
}

.apple-input:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.4);
}

.w-100 { width: 100%; justify-content: center; }

/* ==========================================================================
   MOBILE RESPONSIVE (THE CAROUSEL & BOTTOM SHEET)
   ========================================================================== */
@media (max-width: 1200px) {
  .canvas-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .col-1, .col-2, .col-3, .col-4, .col-5, .span-2, .span-3 { grid-column: span 1; grid-row: auto; }
  .row-1-2 { grid-row: auto; }
}

@media (max-width: 768px) {
  .app-container {
    padding: 16px 12px;
    gap: 16px;
  }
  
  .main-header {
    flex-direction: column;
    gap: 16px;
    border-radius: 20px;
  }

  .header-controls {
    width: 100%;
  }
  
  .glass-btn {
    flex: 1;
    justify-content: center;
  }

  /* HORIZONTAL CAROUSEL FOR MOBILE (Scroll Snapping) */
  .carousel-container {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  
  .carousel-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }

  .canvas-grid {
    display: flex; /* Override grid */
    gap: 12px;
    width: max-content; /* Allow horizontal expansion */
  }

  .canvas-block {
    width: 85vw; /* Almost full screen width cards */
    scroll-snap-align: center;
    border-radius: 24px;
    height: 60vh;
    overflow-y: auto;
  }

  /* Sim Layout */
  .sim-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .sim-outputs {
    flex-direction: column;
  }

  .persona-grid {
    grid-template-columns: 1fr;
  }

  /* iOS BOTTOM SHEET MODAL */
  .apple-dialog {
    margin: 0;
    width: 100%;
    max-width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    max-height: 85vh;
    overflow-y: auto;
    
    /* Sliding animations */
    transform: translateY(100%);
    transition: transform 0.4s var(--spring), opacity 0.4s ease, display 0.4s ease allow-discrete;
  }
  
  .apple-dialog[open] {
    transform: translateY(0);
    opacity: 1;
  }
  
  @starting-style {
    .apple-dialog[open] {
      transform: translateY(100%);
      opacity: 0;
    }
  }

  .dialog-drag-handle {
    display: block;
    width: 36px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2.5px;
    margin: 12px auto 0 auto;
  }

  .dialog-content {
    padding: 16px 24px 40px 24px;
  }
}
