﻿/* Pets Calculator V2.3 - Fresh Water Light */

.pets-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  animation: fadeIn 0.6s ease-out;
  width: 100%;
}

@media (min-width: 1024px) {
  .pets-layout {
    grid-template-columns: 280px 1fr 200px;
    align-items: start;
  }
}

/* Revert separate layout columns */
.layout-center,
.layout-right {
  display: contents;
  /* Treat as if they don't exist */
}

/* Fallback for smaller desktops (standard 2 column) */
@media (min-width: 900px) and (max-width: 1199px) {
  .pets-layout {
    grid-template-columns: 300px 1fr;
  }

  /* Wrap right column to bottom or side? 
       Actually, since we grouped center and right, if we use 2 cols:
       Left (Aside) | (Center + Right)
       But Center and Right are separate divs now. 
       So we need a way to stack them in Col 2.
    */
  .layout-right {
    grid-column: 2;
  }
}

/* --- Left Sidebar: Profile & Config --- */

.pet-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: var(--glass-heavy);
  padding: 1.5rem;
  /* Standardized to match right column */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.pet-avatar {
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, rgba(255, 255, 255, 0.5) 70%);
  border: 3px solid #fff;
  border-radius: 50%;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 10px 20px rgba(6, 182, 212, 0.15);
}

.pet-avatar::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, var(--primary) 25%, transparent 50%);
  animation: spin 4s linear infinite;
  opacity: 0.4;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.pet-avatar img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  z-index: 2;
}

.search-box {
  width: 100%;
  position: relative;
  margin-bottom: 1.5rem;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  z-index: 100;
  list-style: none;
  margin-top: 5px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.suggestions-dropdown li {
  padding: 0.8rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.2s;
}

.suggestions-dropdown li:hover {
  background: #ecfeff;
  color: var(--primary);
  padding-left: 1.5rem;
}

/* Tabs */
.config-tabs {
  display: flex;
  width: 100%;
  background: rgba(0, 0, 0, 0.05);
  /* Light gray for light mode */
  border-radius: 50px;
  padding: 4px;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem;
  border-radius: 40px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

/* Manual Input Alignment */
.manual-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.manual-row .stat-label {
  margin-bottom: 0;
  width: 50px;
  /* Fixed width for labels */
  flex-shrink: 0;
}

.compact-input {
  flex-grow: 1;
  padding: 0.5rem;
  height: 36px;
}

/* Grade Selection Grid */
.grade-panel {
  background: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}

.grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.grade-label {
  width: 30px;
  font-weight: bold;
  color: var(--text-muted);
}

.grade-options {
  display: flex;
  gap: 4px;
}

.grade-radio {
  display: none;
}

.grade-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.grade-radio:checked+.grade-btn {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* --- Right Content: Stats & Predictions --- */

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::before {
  content: '';
  width: 6px;
  height: 24px;
  background: var(--primary);
  border-radius: 2px;
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #ffffff;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--primary);
  opacity: 0.8;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-bar-container {
  height: 6px;
  background: #f1f5f9;
  margin-top: 0.5rem;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--primary);
}

/* Prediction Table - Clean White */
.data-table-container {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-card);
}

.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
  min-width: 800px;
}

.modern-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.modern-table td {
  background: #f8fafc;
  padding: 1rem;
  color: var(--text-main);
  font-family: 'Space Grotesk', monospace;
  font-weight: 500;
}

.modern-table tr td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  font-weight: bold;
  color: var(--primary);
  background: #ecfeff;
}

.modern-table tr td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Elements Element Attributes */
.elements-grid {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.element-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.element-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Mobile Responsive */
@media (max-width: 768px) {

  /* === GLOBAL VIEWPORT LOCK === */
  /* Force the page to NEVER exceed viewport width */
  html,
  body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .app-container {
    width: 100% !important;
    max-width: 100vw !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    overflow-x: hidden !important;
  }

  .pets-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Force all moli-cards to respect viewport */
  .moli-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: auto;
    /* Let cards scroll internally if needed */
  }

  /* Right section container */
  section {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  /* Optimize Profile Card for Mobile */
  .pet-profile-card {
    padding: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    /* CRITICAL: Prevent internal overflow from pushing page width */
  }

  /* Force ALL children inside card to respect width */
  .pet-profile-card * {
    max-width: 100%;
    box-sizing: border-box;
  }

  .pet-avatar {
    width: 70px;
    height: 70px;
    margin-bottom: 0.5rem;
  }

  /* Tabs: Allow shrink/wrap */
  .config-tabs {
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    gap: 0.25rem;
  }

  .tab-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
  }

  /* Shrink Grade Buttons */
  .grade-panel {
    padding: 0.75rem;
  }

  .grade-btn {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
  }

  .grade-label {
    width: 22px;
    font-size: 0.8rem;
  }

  .grade-options {
    gap: 2px;
  }

  /* Compact Inputs */
  .manual-row {
    gap: 0.25rem;
    width: 100%;
    flex-wrap: wrap;
    /* Safety wrap for very narrow screens */
  }

  .manual-row .moli-input {
    min-width: 0;
    flex: 1;
  }

  .manual-row .stat-label {
    font-size: 0.75rem;
    width: 35px;
  }

  /* Compact Inputs */
  .manual-row {
    gap: 0.5rem;
  }

  .manual-row .stat-label {
    font-size: 0.8rem;
    width: 40px;
  }

  .data-table-container {
    padding: 0.5rem;
    /* FIX: Removed negative margins causing body overflow */
    width: 100%;
    border-radius: var(--radius-sm);
  }

  /* Allow horizontal scroll ONLY for PREDICTION table (internal scroll) */
  .modern-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    /* Prevent wrapping inside cells */
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .elements-grid {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .element-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }

  /* --- Comparison List Mobile: Card View (No Scrolling!) --- */
  .comparison-list {
    display: block;
    width: 100%;
  }

  .comparison-list table {
    min-width: 0;
    display: block;
    border: none;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
  }

  .comparison-list thead {
    display: none;
  }

  .comparison-list tbody {
    display: block;
  }

  /* Each Row becomes a Card */
  .comparison-list tr {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  /* First Cell: Header Info */
  .comparison-list tbody th {
    width: 100%;
    display: block;
    border-right: none;
    border-bottom: 1px solid #f1f5f9;
    background: #ecfeff;
    padding: 1rem;
    text-align: center;
  }

  /* Data Cells: 2 Columns */
  .comparison-list tbody td {
    width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid #f8fafc;
    border-right: 1px solid #f8fafc;
    font-size: 1.1rem;
  }

  /* Inject Headers */
  .comparison-list tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.2rem;
  }
}

/* Comparison List Styles */
.comparison-list table {
  width: 100%;
  margin-bottom: 1rem;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.comparison-list th,
.comparison-list td {
  padding: 0.8rem 0.5rem;
  /* Increased padding */
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.comparison-list thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.comparison-list tbody th {
  background: #ecfeff;
  color: var(--primary);
  font-weight: bold;
  text-align: left;
  padding-left: 1rem;
  border-right: 1px solid #f1f5f9;
  min-width: 120px;
}

.comparison-list tbody td {
  font-family: 'Space Grotesk', monospace;
  font-size: 1.1rem;
  /* Larger value text */
  font-weight: 600;
  color: var(--text-main);
}

.comparison-list p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* --- Accordion System --- */
.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: var(--glass-heavy);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: all 0.3s ease;
}

.accordion-header {
  padding: 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.4);
  transition: background 0.2s;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.6);
}

.accordion-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
  opacity: 0;
}

.accordion-item.active .accordion-body {
  max-height: 2000px;
  /* Arbitrary large height */
  opacity: 1;
}

/* Ensure Matrix table scrolls within accordion */
.accordion-body .data-table-container {
  max-height: 600px;
  /* Limit inner scroll height if needed */
  overflow-y: auto;
}

/* === Settings Sidebar (Right Panel) === */
.settings-sidebar {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: var(--glass-heavy);
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  z-index: 10;
  width: 150px;
  min-width: 150px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  margin-bottom: 0.25rem;
}

.strategy-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.strategy-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.strategy-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.strategy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.strategy-btn input[type="radio"] {
  display: none;
}

.strategy-btn:hover {
  transform: scale(1.1);
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

.strategy-btn:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(6, 182, 212, 0.4);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.points-remaining {
  font-weight: 400;
  color: var(--secondary);
}

.points-remaining .points {
  width: 30px;
  background: transparent;
  border: none;
  color: var(--secondary);
  font-weight: bold;
  text-align: center;
  font-size: 0.7rem;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.setting-item label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  width: 30px;
  flex-shrink: 0;
}

.setting-item .compact-input {
  flex: 1;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  text-align: center;
  border-radius: var(--radius-sm);
}

/* Mobile: Settings sidebar becomes collapsible FAB-style button */
@media (max-width: 1023px) {
  .settings-sidebar {
    position: fixed;
    top: auto;
    bottom: 10px;
    right: 10px;
    left: auto;
    transform: none;
    width: auto;
    min-width: 100px;
    max-width: 90%;
    max-height: 60vh;
    border-radius: var(--radius-lg);
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease;
  }

  /* Collapsed state - small pill button */
  .settings-sidebar .sidebar-title {
    padding: 0.6rem 1.25rem;
    margin: 0;
    border-bottom: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
    border-radius: var(--radius-lg);
    white-space: nowrap;
  }

  .settings-sidebar .sidebar-title::after {
    content: '▲';
    font-size: 0.65rem;
    transition: transform 0.3s ease;
  }

  /* Hide content by default */
  .settings-sidebar .strategy-group,
  .settings-sidebar .settings-section {
    display: none;
    padding: 0.75rem 1rem;
  }

  /* Expanded state - center on screen */
  .settings-sidebar.expanded {
    position: fixed;
    top: auto;
    bottom: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
  }

  .settings-sidebar.expanded .sidebar-title {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .settings-sidebar.expanded .sidebar-title::after {
    transform: rotate(180deg);
  }

  .settings-sidebar.expanded .strategy-group,
  .settings-sidebar.expanded .settings-section {
    display: flex;
  }

  /* Strategy buttons in a row */
  .settings-sidebar .strategy-buttons {
    flex-direction: row;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }

  .settings-sidebar .strategy-btn {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
  }

  /* Settings grid - 2 columns on mobile */
  .settings-sidebar .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .settings-sidebar .setting-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
  }

  .settings-sidebar .setting-item label {
    width: 25px;
    flex-shrink: 0;
    font-size: 0.7rem;
  }

  .settings-sidebar .setting-item .compact-input {
    flex: 1;
    min-width: 0;
    padding: 0.3rem;
    font-size: 0.75rem;
  }

  /* Equipment grid - more compact */
  .settings-sidebar .equipment-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}