/**
 * earnings.css
 * Styling for the earnings page with theme compatibility
 */

/* ----- ROOT VARIABLES ----- */
:root {
  /* Shared colors for both themes */
  --yellow-color: #ffd700;
  --green-color: #32cd32;
  --light-green-color: #90ee90;
  --red-color: #ff5555;
  --accent-color: #00dfff;
  --accent-color-rgb: 0, 223, 255;
  --bg-color: #000;
  --card-header-bg: #000;
}

/* Theme-specific variables */
html.bitcoin-theme {
  --primary-color: #f2a900;
  --primary-color-rgb: 242, 169, 0;
  --border-color: #333;
  --primary-gradient-end: #bf7d00; /* Darker orange */
}

html.deepsea-theme {
  --primary-color: #0088cc;
  --primary-color-rgb: 0, 136, 204;
  --border-color: #224;
  --primary-gradient-end: #006699; /* Darker blue */
}

/* ----- LAYOUT COMPONENTS ----- */
.earnings-section {
  margin: 2rem 0;
}

.earnings-section h2 {
  color: var(--primary-color);
  padding: 0.5rem;
  font-weight: bold;
  font-family: var(--header-font);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  position: relative;
}

.earnings-section h2::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.05),
    rgba(0, 0, 0, 0.05) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1;
}

.earnings-actions {
  margin-bottom: 0.5rem;
}

.download-btn {
  display: inline-block;
  padding: 4px 8px;
  font-family: var(--terminal-font);
  font-size: 0.9rem;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  text-decoration: none;
  transition: all 0.2s ease;
}

.download-btn:hover {
  background-color: var(--primary-color);
  color: var(--bg-color);
}

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

.dashboard-container {
  position: relative;
  z-index: 0;
}

.dashboard-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.05),
    rgba(0, 0, 0, 0.05) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: -1;
}

/* Notice banner for API errors */
.error-banner {
  background-color: rgba(255, 0, 0, 0.7);
  color: #fff;
  text-align: center;
  padding: 0.5rem;
  margin-bottom: 1rem;
  font-weight: bold;
  animation: pulse-highlight 2s infinite;
}

/* ----- CARD STYLING ----- */
.stat-card {
  color: white;
  padding: 1rem;
  border: 1px solid var(--primary-color);
  box-shadow: 0 0 10px rgba(var(--primary-color-rgb), 0.3);
  position: relative;
  background-color: var(--bg-color);
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(var(--primary-color-rgb), 0.5);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1;
}

.stat-card h2 {
  padding: 0.5rem;
  color: var(--primary-color);
  font-size: 1.2rem;
  margin: -1rem -1rem 0.5rem -1rem;
  text-transform: uppercase;
  font-weight: bold;
  font-family: var(--header-font);
  position: relative;
  z-index: 2;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
}

.stat-unit {
  font-size: 1rem;
  color: var(--text-color);
  margin-left: 0.25rem;
  position: relative;
  z-index: 2;
}

.stat-secondary {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: rgba(255, 255, 255, 0.8);
  position: relative;
  z-index: 2;
}

.stat-time {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--accent-color);
  position: relative;
  z-index: 2;
}

/* ----- TABLE STYLING ----- */
.table-container {
  overflow-x: auto;
  margin: 1rem 0;
  background-color: var(--bg-color);
  padding: 0.5rem;
  border: 1px solid var(--primary-color);
  box-shadow: 0 0 10px rgba(var(--primary-color-rgb), 0.2);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.table-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1;
}

.earnings-table {
  width: 100%;
  border-collapse: collapse;
  position: relative;
  z-index: 2;
}

.earnings-table th,
.earnings-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.earnings-table th {
  background-color: var(--card-header-bg);
  color: var(--primary-color);
  font-family: var(--header-font);
  text-transform: uppercase;
  font-size: 0.9rem;
}

.earnings-table tr td[colspan] {
  text-align: center;
  padding: 2rem;
  color: var(--text-color);
  font-style: italic;
}

/* ----- COLOR CODING FOR DATA ----- */
/* Yellow color - BTC/sats values */
#unpaid-sats,
#total-paid-sats,
.earnings-table td:nth-child(4),
#unpaid-btc,
#total-paid-btc,
.earnings-table td:nth-child(3) {
  color: var(--yellow-color);
}

/* Green color - Earnings/profits */
#total-paid-usd,
#total-paid-fiat,
.earnings-table td:nth-child(5) {
  color: var(--green-color);
}

/* Red color - Fees/costs */
.earnings-fee,
.earnings-cost {
  color: var(--red-color) !important;
}

/* Blue color - Dates */
.earnings-table td:nth-child(1) {
  color: var(--accent-color);
}

/* ----- STATUS INDICATORS ----- */
.status-label {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

.status-confirmed {
  background-color: rgba(75, 181, 67, 0.15);
  color: var(--green-color);
}

.status-pending {
  background-color: rgba(247, 147, 26, 0.15);
  color: var(--yellow-color);
}

.status-processing {
  background-color: rgba(52, 152, 219, 0.15);
  color: var(--accent-color);
}

/* ----- LINKS & INTERACTIVE ELEMENTS ----- */
.tx-link {
  color: var(--accent-color);
  text-decoration: none;
  letter-spacing: 1px;
  text-decoration: underline;
  transition: all 0.2s ease;
}

.tx-link:hover {
  text-decoration: underline;
  text-shadow: 0 0 5px rgba(var(--accent-color-rgb), 0.7);
}

/* ----- UTILITY CLASSES ----- */
.arrow {
  display: inline-block;
  font-weight: bold;
  margin-left: 0.5rem;
}

.currency-symbol {
  display: inline-block;
  margin-right: 2px;
}

.metric-value {
  color: var(--text-color);
  font-weight: bold;
}

.card-body strong {
  color: var(--primary-color);
  margin-right: 0.25rem;
}

.card-body p {
  margin: 0.25rem 0;
  line-height: 1.2;
}

/* Pool luck indicators */
.very-lucky {
  color: var(--green-color) !important;
  font-weight: bold !important;
}

.lucky {
  color: var(--light-green-color) !important;
}

.normal-luck {
  color: var(--yellow-color) !important;
}

.unlucky {
  color: var(--red-color) !important;
}

/* ----- USER SETTINGS INFO ----- */
.settings-info {
  display: flex;
  justify-content: flex-end;
  font-size: 0.9em;
  color: #888;
}

.setting-item {
  margin-left: 20px;
}

.setting-item strong {
  color: var(--accent-color);
}

/* ----- ANIMATIONS ----- */
@keyframes bounceUp {
  0%,
  50%,
  100% {
    transform: translateY(0);
  }

  25%,
  75% {
    transform: translateY(-2px);
  }
}

@keyframes bounceDown {
  0%,
  50%,
  100% {
    transform: translateY(0);
  }

  25%,
  75% {
    transform: translateY(2px);
  }
}

@keyframes pulse-highlight {
  0%,
  100% {
    background-color: rgba(var(--primary-color-rgb), 0.1);
  }

  50% {
    background-color: rgba(var(--primary-color-rgb), 0.3);
  }
}

.bounce-up {
  animation: bounceUp 1s infinite;
}

.bounce-down {
  animation: bounceDown 1s infinite;
}

.new-payment {
  animation: pulse-highlight 2s infinite;
}

/* ----- RESPONSIVE STYLES ----- */
/* Tablets and smaller desktops */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .earnings-table th,
  .earnings-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  .status-label {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
  }

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

  .tx-link {
    font-size: 0.8rem;
  }

  .settings-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-item {
    margin-left: 0;
    margin-bottom: 5px;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  /* Card-like table layout for small screens */
  .earnings-table thead {
    display: none;
  }

  .earnings-table,
  .earnings-table tbody,
  .earnings-table tr {
    display: block;
    width: 100%;
  }

  .earnings-table tr {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    padding: 8px;
  }

  .earnings-table td {
    display: flex;
    padding: 6px 3px;
    border: none;
    border-bottom: 1px solid var(--border-color);
  }

  .earnings-table td:last-child {
    border-bottom: none;
  }

  /* Responsive labels for table cells */
  .earnings-table td::before {
    content: attr(data-label);
    font-weight: bold;
    width: 40%;
    color: var(--primary-color);
    margin-right: 5%;
  }

  /* Table-specific cell labels */
  #payment-history-table td:nth-child(1)::before {
    content: "Date: ";
  }

  #payment-history-table td:nth-child(2)::before {
    content: "₿: ";
  }

  #payment-history-table td:nth-child(3)::before {
    content: "Sats: ";
  }

  #payment-history-table td:nth-child(4)::before {
    content: "TX: ";
  }

  #payment-history-table td:nth-child(5)::before {
    content: "Status: ";
  }

  #monthly-summary-table td:nth-child(1)::before {
    content: "Month: ";
  }

  #monthly-summary-table td:nth-child(2)::before {
    content: "Payments: ";
  }

  #monthly-summary-table td:nth-child(3)::before {
    content: "₿: ";
  }

  #monthly-summary-table td:nth-child(4)::before {
    content: "Sats: ";
  }

  #monthly-summary-table td:nth-child(5)::before {
    content: "Fiat: ";
  }

  /* Fix truncated transaction links */
  .tx-link {
    word-break: break-all;
    font-size: 0.75rem;
  }
}

/* Landscape orientation adjustments for short screens */
@media (orientation: landscape) and (max-height: 500px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
