/* Base Styles */
* {
  box-sizing: border-box;
}
body {
  font-family: Arial, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  margin: 0;
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}
.container {
  width: 100%;
  margin: auto;
  background: linear-gradient(145deg, #333, #444);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  transition: background 0.3s, box-shadow 0.3s;
}
.container:hover {
  /* Remove transform scale */
}
h1, h2, h3, h4 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 0.5em;
}

/* Flex layout for left & right panels */
.flex-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* Left panel is narrower (15%) and right panel is the rest */
.left-panel {
  flex: 0 0 15%;
}
.right-panel {
  flex: 1 1 auto;
}

/* Row for calculators side by side */
.calc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* A box around each sub-calculator in the row */
.calculator-box {
  background: #444;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 10px;
  flex: 1 1 auto;
  min-width: 120px;
}

/* Input styling */
.input-group {
  margin-bottom: 15px;
}
label {
  display: block;
  margin-bottom: 6px;
  font-weight: bold;
  color: #ccc;
}
.number-input {
  display: flex;
  align-items: center;
}
.number-input button {
  width: 30px;
  height: 30px;
  font-size: 1.2em;
  border: none;
  background-color: #007bff;
  color: white;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 3px;
  transition: background-color 0.3s;
  touch-action: manipulation;
}
.number-input button:active {
  background-color: #0056b3;
}
.number-input input {
  text-align: center;
  flex: 1;
  font-size: 0.95em;
  padding: 6px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #444;
  color: #e0e0e0;
}

/* Canvas (chart) styling */
/*
canvas {
  width: 100%;
  height: 300px;
  background: #333;
}
*/

/* Added margin to prevent income chart from overlapping content */
#incomeChart {
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

#dailyYieldChart {
  display: block;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
  clear: both;
  height: 300px !important;
}

/* Summary section (within coin tracker or main summary) */
.summary-section {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #555;
  background: #444;
  border-radius: 4px;
  font-size: 0.95em;
  transition: background 0.3s, border-color 0.3s;
}
.summary-section p {
  margin: 5px 0;
}

/* Transfer Section */
.transfer-section {
  margin: 20px 0;
  padding: 10px;
  border: 1px solid #777;
  background: #555;
  border-radius: 4px;
}
.transfer-section select {
  width: 100%;
  padding: 5px;
  margin-bottom: 10px;
  border-radius: 4px;
}

/* Collapsible Container & Headers */
.collapsible-container {
  margin-top: 0;
  padding: 10px;
  border: 1px solid #777;
  background: #555;
  border-radius: 4px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.collapsible {
  flex: 1 1 45%;
  margin-bottom: 10px;
}
.collapsible-header {
  background-color: #444;
  padding: 4px 8px;
  border: 1px solid #555;
  margin-top: 0;
  cursor: pointer;
  user-select: none;
}
.collapsible-body {
  background-color: #333;
  border: 1px solid #555;
  border-radius: 4px;
  margin-top: 5px;
  padding: 10px;
  display: none;
}
.collapsible-body.visible {
  display: block;
}
.collapsible-body .calc-row {
  align-items: flex-start;
}

/* Specific styling for the Convert Assets section */
.convert-assets-section {
  margin: 20px 0;
  border: 1px solid #444;
  border-radius: 5px;
}

.convert-assets-section .collapsible-header {
  background-color: #2a2a2a;
  color: #fff;
  font-weight: bold;
  padding: 8px 12px;
}

.convert-assets-section .collapsible-body {
  border-top: none;
  margin-top: 0;
}

/* Bar summary */
#barSummary {
  margin-bottom: 10px;
  padding: 10px;
  text-align: center;
  font-size: 1em;
  background: #444;
  border: 1px solid #555;
  border-radius: 4px;
  transition: background 0.3s, border-color 0.3s;
}

/* Table styling */
.table-section {
  margin-top: 40px;
  overflow: visible;
  max-height: none;
  clear: both;         /* ensure the table is placed below the chart */
  position: relative;
  z-index: 1;          /* appear on top (stack) if needed */
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
table, th, td {
  border: 1px solid #555;
}
th, td {
  padding: 8px;
  text-align: center;
}
th {
  background-color: #555;
}

/* Coin Tracker styling */
.coin-tracker {
  margin-bottom: 20px;
  border: 1px solid #777;
  border-radius: 4px;
}
.coin-tracker-header {
  background-color: #666;
  padding: 5px;
  cursor: pointer;
}
.coin-tracker .coin-summary {
  margin-top: 10px;
}
.coin-tracker button.deleteTracker {
  margin-left: 10px;
  background: #d9534f;
  border: none;
  color: white;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.coin-tracker button.deleteTracker:hover {
  background: #c9302c;
}
.deleteRowBtn {
  background: #d9534f;
  border: none;
  color: white;
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 4px;
}
.deleteRowBtn:hover {
  background: #c9302c;
}

/* Accessibility: focus styles */
button:focus, input:focus, select:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .flex-container {
    flex-direction: column;
  }
  .left-panel, .right-panel {
    flex: 1 1 100%;
  }
  .calc-row {
    flex-direction: column;
  }
  .calculator-box {
    margin-bottom: 10px;
  }
  body {
    padding: 10px;
  }
  .container {
    padding: 10px;
  }
  canvas {
    height: auto;
  }
  .table-section {
    overflow-x: auto;
  }
}

/* Table and summary container layout */
.table-summary-container {
  display: flex;
  margin-bottom: 10px;
}
.table-summary-container table {
  flex: 1;
}
.coin-summary {
  background: #555;
  border: 1px solid #666;
  padding: 10px;
  width: 200px;
  margin-left: 15px;
  margin-top: 0;
}
.coin-summary h4 {
  margin-top: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid #777;
  padding-bottom: 5px;
  font-size: 1rem;
}
/* For mobile devices, stack the layout */
@media (max-width: 768px) {
  .table-summary-container {
    flex-direction: column;
  }
  .coin-summary {
    width: 100%;
    margin-left: 0;
    margin-top: 10px;
  }
}
/* Table wrapper for positioning context */
.table-wrapper {
  position: relative;
  margin-bottom: 20px;
}

/* New inline yield projection styling */
.inline-yield-projection {
  margin-top: 5px;
  font-size: 0.85rem;
  white-space: nowrap;
  color: #aaf;
  line-height: 1.2;
}

.inline-yield-projection small {
  display: block;
  padding-top: 2px;
  border-top: 1px dotted #666;
}

/* Add row button styling */
.add-row-btn {
  margin-top: 5px;
  margin-bottom: 0;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-block;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .table-summary-container {
    flex-direction: column;
  }
  .coin-summary {
    width: 100%;
    margin-left: 0;
    margin-top: 10px;
  }
  .table-wrapper {
    margin-bottom: 0;
  }
  .add-row-btn {
    width: 100%;
    margin-top: 10px;
  }
}

#graphBox {
  overflow: visible; /* Allow elements to expand beyond the container */
  position: static; /* Ensure it doesn't trap child elements */
}

/* Remove or comment out specific canvas styling */
/*
#investedChart, #incomeChart {
  margin-bottom: 20px;
}

#investedChart {
  height: 300px !important;
  margin-bottom: 40px;
}

#dailyYieldChart {
  display: block;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
  clear: both;
  height: 300px !important;
}
*/

/* Update charts-flex to be more specific and override other styles */
#graphBox.charts-flex {
  display: block; /* Changed from flex */
  margin-bottom: 2rem;
  min-height: 600px;
  width: 100%;
}

#graphBox.charts-flex canvas {
  width: 100% !important;
  max-width: 100%; /* Allow to take full width */
  height: 600px !important; /* Make taller */
  background: #181818;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  display: block;
  margin: 0 auto;
}

/* Fullscreen chart mode */
.chart-fullscreen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw; /* Fullscreen width */
  height: 90vh; /* Fullscreen height */
  z-index: 9999; /* Ensure it appears above everything */
  background-color: #222; /* Optional: Add a background color */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5); /* Optional: Add a shadow */
  border-radius: 8px; /* Optional: Add rounded corners */
  transition: transform 0.3s ease-in-out; /* Smooth transition */
}

/* Loading Spinner */
.loading-spinner {
  display: none; /* hidden by default */
  position: fixed;
  left: 50%;
  top: 50%;
  padding: 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

/* Optional: add a simple spinner animation */
.loading-spinner::after {
  content: "";
  display: inline-block;
  margin-left: 8px;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 1s linear infinite;
}

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

#investedChart, #dailyYieldChart {
  display: block; /* Changed from inline-block */
  width: 100% !important; /* Full width when displayed */
  height: auto; /* Maintain aspect ratio */
  margin: 0; /* Remove margin */
  max-height: 600px; /* Make charts taller */
}

#incomeChart {
  display: block;
  width: 100% !important;
  height: auto;
  max-height: 600px;
  margin: 0 auto;
}
