/* Shared UI Components */

/* Section styling */
.section {
  margin-bottom: 30px;
  padding: 20px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.section h2 {
  margin-top: 0;
  color: #f0ad4e;
  display: inline-block;
  padding-bottom: 10px;
  border-bottom: 2.4px solid #8b4513;
}

.section input[type="file"] {
  margin-left: 20px;
  margin-top: 15px;
  margin-bottom: 15px;
}

.section pre {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 5px;
  overflow: auto;
  color: #f8f8f8;
}

.section table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.section th,
.section td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section th {
  background-color: rgba(240, 173, 78, 0.2);
  color: #fff;
}

/* Shared Table Styling (Explicit class) */
.section-table {
  width: 100%;
  table-layout: fixed; /* Forces consistent column widths for layout stability */
  border-collapse: collapse;
  margin-top: 15px;
}

.section-table th,
.section-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow-wrap: break-word;
}

.section-table th {
  background-color: rgba(240, 173, 78, 0.2);
  color: #fff;
}

.section-table tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Buttons */
.secondary-btn {
  background-color: transparent;
  border: 1px solid #f0ad4e;
  color: #f0ad4e;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.secondary-btn:hover {
  background-color: #f0ad4e;
  color: #fff;
}

/* Disabled button style */
button:disabled,
.secondary-btn:disabled,
.view-toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* View toggle buttons */
.view-toggle {
  margin: 15px 0;
}

.view-toggle-btn {
  padding: 8px 15px;
  border: 1px solid #f0ad4e;
  background-color: transparent;
  color: #f0ad4e;
  cursor: pointer;
  margin-right: 5px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.view-toggle-btn.active,
.view-toggle-btn:hover {
  background-color: #f0ad4e;
  color: #fff;
}

/* Financial Signifiers */
.positive {
  color: #5cb85c; /* A shade of green */
}

.negative {
  color: #d9534f; /* A shade of red */
}

/* Accessibility Mode */
.accessibility-mode .positive::before {
  content: "▲ ";
  font-size: 0.8em;
}

.accessibility-mode .negative::before {
  content: "▼ ";
  font-size: 0.8em;
}

/* Timeframe selector styling (Moved from dashboard.css) */
.timeframe-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeframe-selector label {
  font-size: 0.9em;
  color: #fff;
}

.timeframe-selector select {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: #1a6b10;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
  min-width: 150px;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 30px;
}

.timeframe-selector select:focus {
  outline: 2px solid #f0ad4e;
  outline-offset: 2px;
  border-color: #f0ad4e;
}

/* Add styling for the dropdown arrow on different browsers */
.timeframe-selector select::-ms-expand {
  display: none;
}

/* Responsive design for timeframe selector */
@media (max-width: 768px) {
  .timeframe-selector {
    width: 100%;
    justify-content: space-between;
  }

  .timeframe-selector select {
    min-width: auto;
    flex: 1;
  }
}

/* Switch Toggle Component */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #5cb85c;
}

input:focus + .slider {
  box-shadow: 0 0 1px #5cb85c;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  :root {
    --mobile-shell-padding: 14px;
    --mobile-section-padding: 14px;
    --mobile-section-gap: 16px;
    --mobile-control-height: 40px;
    --mobile-control-padding-x: 12px;
    --mobile-control-padding-y: 8px;
    --mobile-control-gap: 10px;
    --mobile-header-gap: 8px;
    --mobile-table-cell-padding: 8px;
  }

  .section {
    margin-bottom: var(--mobile-section-gap);
    padding: var(--mobile-section-padding);
  }

  .section h2 {
    padding-bottom: var(--mobile-header-gap);
    margin-bottom: 0;
  }

  .section input[type="file"] {
    width: 100%;
    margin-left: 0;
    margin-top: 12px;
    margin-bottom: 12px;
    box-sizing: border-box;
  }

  .section pre,
  .section table,
  .section-table {
    margin-top: var(--mobile-control-gap);
  }

  .section pre {
    padding: 12px;
  }

  .section th,
  .section td,
  .section-table th,
  .section-table td {
    padding: var(--mobile-table-cell-padding);
  }

  .secondary-btn,
  .view-toggle-btn,
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  select,
  textarea {
    min-height: var(--mobile-control-height);
    padding: var(--mobile-control-padding-y) var(--mobile-control-padding-x);
    box-sizing: border-box;
  }

  .secondary-btn,
  .view-toggle-btn {
    padding-left: var(--mobile-control-padding-x);
    padding-right: var(--mobile-control-padding-x);
    line-height: 1.2;
  }

  .view-toggle {
    margin: var(--mobile-control-gap) 0;
  }

  .timeframe-selector {
    gap: var(--mobile-control-gap);
  }

  .timeframe-selector label {
    white-space: nowrap;
  }
}
