/* ===== Reports Page Styles ===== */
/* Using the same color variables as the main admin panel */

/* ===== Filters Section ===== */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
@media (max-width: 600px) {
  .content-header {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }
}

.filters-section {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--shadow);
  margin-bottom: 2rem;

  transition: background var(--transition), border-color var(--transition);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.9rem;
}

.filter-group select,
.filter-group input {
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none; /* Remove default browser styling */
  -webkit-appearance: none;
  -moz-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='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem; /* Make room for the arrow */
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(133, 214, 255, 0.1);
}

.filter-group select option {
  background: var(--card-bg);
  color: var(--text-color);
  padding: 0.5rem;
}

/* ===== Statistics Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(133, 214, 255, 0.1);
  color: var(--primary);
}

.stat-content {
  flex: 1;
}

.stat-content h3 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--primary);
}

.stat-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 500;
}

/* ===== Charts Section ===== */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
  transition: all var(--transition);
}

.chart-container {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--shadow);
  transition: background var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
}

.chart-container[style*="display: none"] {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}


.chart-container h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0 0 1rem 0;
  text-align: center;
}

.chart-container canvas {
  max-width: 100%;
  max-height: 20rem; /* Increased height for better visibility */
  display: block;
  margin: 0 auto;
  width: auto; /* Allow Chart.js aspect ratio to control width */
}


/* ===== Report Section ===== */
.report-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--shadow);
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

.report-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--shadow);
  overflow-x: auto; /* Allow horizontal scrolling if needed */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.tab-btn {
  flex: 1;
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-bottom: 3px solid transparent;
  min-width: 80px; /* Minimum width to prevent too much shrinking */
  text-align: center;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(133, 214, 255, 0.05);
}

.tab-content {
  display: none;
  padding: 1.5rem;
}

.tab-content.active {
  display: block;
}

/* ===== Data Table ===== */
.data-table-container {
  overflow-x: auto;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  margin: 1rem 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 12px var(--shadow);
}

.data-table thead {
  background: rgba(0, 238, 255, 0.1);
}

.data-table th,
.data-table td {
  padding: 1rem 1rem 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}

.data-table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Status badges in table */
.status-badge {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.5px;
}

.status-badge.completed,
.status-badge.success {
  background: rgba(14, 203, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.status-badge.pending {
  background: rgba(240, 185, 11, 0.15);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.status-badge.failed,
.status-badge.error {
  background: rgba(246, 70, 93, 0.15);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.status-badge.processing {
  background: rgba(0, 238, 255, 0.15);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.5px;
}

.type-badge.buy {
  background: rgba(14, 203, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.type-badge.sell {
  background: rgba(246, 70, 93, 0.15);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

/* Profit/Loss colors */
.positive {
  color: var(--accent-green);
  font-weight: 600;
}

.negative {
  color: var(--accent-red);
  font-weight: 600;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
}

/* ===== Export Modal ===== */
.export-options {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.export-options .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.export-options .form-group label {
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.9rem;
}

.export-options .form-group select {
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.export-options .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(133, 214, 255, 0.1);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  /* Filters Section */
  .filters-section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group select,
  .filter-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Statistics Grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .stat-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .stat-content h3 {
    font-size: 1.5rem;
  }

  .stat-content p {
    font-size: 0.85rem;
  }

  /* Charts Section - Enhanced Mobile Layout */
  .charts-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 0 -0.5rem 2rem -0.5rem; /* Better margins for mobile */
    padding: 0 0.5rem;
  }

  .chart-container {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--shadow);
    margin: 0; /* Remove any default margins */
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto; /* Allow horizontal scrolling if chart is too wide */
    position: relative;
  }

  .chart-container h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: left; /* Better alignment on mobile */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chart-container canvas {
    max-width: 100%;
    max-height: 17rem; /* Increased height for mobile */
    margin: 0 auto;
    display: block;
    width: 100% !important; /* Ensure full width utilization on mobile */
    box-sizing: border-box;
  }

  /* Trading Summary */
  .summary-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 0 -0.5rem 1.5rem -0.5rem;
    padding: 0 0.5rem;
  }

  .summary-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .summary-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .summary-content h4 {
    font-size: 1.3rem;
  }

  .summary-content p {
    font-size: 0.8rem;
  }

  /* Report Section */
  .report-section {
    margin: 0 -0.5rem;
    border-radius: 0;
  }

  .report-tabs {
    /* Keep horizontal layout on mobile */
    background: rgba(0, 0, 0, 0.3);
  }

  .tab-btn {
    padding: 0.875rem 0.75rem; /* Slightly smaller padding for mobile */
    font-size: 0.85rem; /* Smaller font for mobile */
    flex: 1; /* Ensure equal width */
    text-align: center; /* Center text on mobile */
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tab-content {
    padding: 1.25rem;
  }

  /* Data Tables */
  .data-table-container {
    margin: 0.75rem 0;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    font-size: 0.85rem;
    min-width: 600px; /* Ensure minimum width for scrolling */
  }

  .data-table th,
  .data-table td {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }

  .data-table th {
    font-size: 0.8rem;
    font-weight: 700;
  }

  /* Modal improvements */
  .modal-content {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  .modal-header {
    padding: 1.25rem;
  }

  .modal-body {
    padding: 1.25rem;
  }

  /* Export modal */
  .export-options {
    gap: 1rem;
  }

  .export-options .form-group select {
    width: 100%;
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 0.875rem;
  }

  .stat-content h3 {
    font-size: 1.2rem;
  }

  .stat-content p {
    font-size: 0.8rem;
  }

  /* Charts for very small screens */
  .chart-container {
    padding: 1rem;
    margin: 0 -0.25rem; /* Reduce margins further */
  }

  .chart-container h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .chart-container canvas {
    max-height: 14rem; /* Increased height for very small screens */
    max-width: 100%;
    margin: 0 auto;
    display: block;
    width: 100% !important;
    box-sizing: border-box;
  }

  /* Trading Summary */
  .summary-stats {
    grid-template-columns: 1fr;
    gap: 0.875rem;
    margin: 0 -0.5rem 1.5rem -0.5rem;
    padding: 0 0.5rem;
  }

  .summary-card {
    padding: 0.875rem;
    gap: 0.625rem;
  }

  .summary-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .summary-content h4 {
    font-size: 1.1rem;
  }

  .summary-content p {
    font-size: 0.75rem;
  }

  .data-table {
    font-size: 0.8rem;
  }

  .status-badge,
  .type-badge {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  /* Filters Section */
  .filters-section {
    padding: 0.875rem;
    margin: 0 -0.5rem 1.25rem -0.5rem;
    border-radius: 0;
  }

  .filter-row {
    gap: 0.875rem;
  }

  .filter-group label {
    font-size: 0.85rem;
  }

  .filter-group select,
  .filter-group input {
    padding: 0.75rem 0.875rem;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Statistics Grid */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
    margin: 0 -0.5rem 1.5rem -0.5rem;
    padding: 0 0.5rem;
  }

  .stat-card {
    padding: 0.875rem;
    gap: 0.625rem;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .stat-content h3 {
    font-size: 1.2rem;
  }

  .stat-content p {
    font-size: 0.8rem;
  }

  /* Charts Section - Enhanced for Small Screens */
  .charts-section {
    gap: 1.25rem;
    margin: 0 -0.5rem 1.75rem -0.5rem;
    padding: 0 0.5rem;
  }

  .chart-container {
    padding: 1rem;
    border-radius: 12px;
  }

  .chart-container h3 {
    font-size: 1rem;
    margin-bottom: 0.875rem;
  }

  .chart-container canvas {
    max-width: 100%;
    height: 250px !important; /* Fixed height for small screens */
  }

  /* Report Section */
  .report-section {
    margin: 0 -0.5rem;
    border-radius: 0;
  }

  .tab-btn {
    padding: 0.75rem 0.5rem; /* Smaller padding for very small screens */
    font-size: 0.8rem; /* Smaller font */
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Allow flex shrinking */
  }

  .tab-content {
    padding: 1rem;
  }

  /* Data Tables */
  .data-table {
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.375rem;
    font-size: 0.75rem;
  }

  .data-table-container {
    margin: 0.625rem 0;
  }

  /* Status and Type Badges */
  .status-badge,
  .type-badge {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  /* Modal improvements for small screens */
  .modal-content {
    margin: 0.5rem;
    width: calc(100% - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-header h2 {
    font-size: 1.2rem;
  }

  .modal-body {
    padding: 1rem;
  }

  /* Export modal */
  .export-options .form-group select {
    padding: 0.75rem 0.875rem;
  }

  /* Button improvements */
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  /* Toast positioning */
  .toast {
    left: 1rem;
    right: 1rem;
    width: auto;
  }

  /* Trading summary mobile adjustments */
  .summary-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
  }

  .summary-card {
    padding: 1.125rem;
    gap: 0.875rem;
  }

  .summary-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .summary-content h4 {
    font-size: 1.375rem;
  }

  .summary-content p {
    font-size: 0.825rem;
  }
}

@media (max-width: 360px) {
  /* Ultra small screens */
  .filters-section {
    padding: 0.75rem;
    margin: 0 -0.25rem 1rem -0.25rem;
  }

  .charts-section {
    margin: 0 -0.25rem 1.5rem -0.25rem;
    padding: 0 0.25rem;
    gap: 1rem;
  }

  .chart-container {
    padding: 0.875rem;
  }

  .chart-container h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
  }

  .chart-container canvas {
    height: 200px !important; /* Smaller height for very small screens */
  }

  .stats-grid {
    margin: 0 -0.25rem 1.25rem -0.25rem;
    padding: 0 0.25rem;
  }

  .report-section {
    margin: 0 -0.25rem;
  }

  .tab-btn {
    padding: 0.625rem 0.375rem; /* Very small padding for ultra-small screens */
    font-size: 0.75rem; /* Smallest font */
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .tab-content {
    padding: 0.875rem;
  }

  .data-table-container {
    margin: 0.5rem 0;
  }

  .modal-content {
    margin: 0.25rem;
    width: calc(100% - 0.5rem);
  }

  /* Trading summary mobile adjustments */
  .summary-stats {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .summary-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .summary-icon {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .summary-content h4 {
    font-size: 1.25rem;
  }

  .summary-content p {
    font-size: 0.8rem;
  }
}

/* ===== Trading Summary ===== */
.trading-summary {
  margin-bottom: 2rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.summary-card {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform var(--transition), box-shadow var(--transition);
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.summary-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(133, 214, 255, 0.1);
  color: var(--primary);
}

.summary-content {
  flex: 1;
}

.summary-content h4 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--primary);
}

.summary-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 500;
}

/* ===== Mobile Modal Adjustments ===== */
@media (max-width: 768px) {
  #exportModal .modal-content {
    max-height: 95vh;
    width: 95%;
    margin: 2.5vh auto;
  }
}

/* ===== Modal Form Controls ===== */
.modal .form-group select,
.modal .form-group input {
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
  -moz-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='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
  width: 100%;
  box-sizing: border-box;
}

.modal .form-group select:focus,
.modal .form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(133, 214, 255, 0.1);
}

.modal .form-group select option {
  background: var(--card-bg);
  color: var(--text-color);
  padding: 0.5rem;
}

/* ===== Refresh Button Styles ===== */
#refreshReportsBtn {
  transition: all 0.3s ease;
}

#refreshReportsBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--shadow) !important;
  color: var(--text-muted) !important;
}

#refreshReportsBtn:disabled i.fa-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}