/* Admin Dashboard CSS */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2rem;
  color: #2c3e50;
  margin-bottom: 8px;
}

.header .subtitle {
  color: #7f8c8d;
  font-size: 1rem;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Cards */
.card {
  background: white;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 25px;
}

.card h2 {
  font-size: 1.5rem;
  color: #2c3e50;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h2 {
  margin-bottom: 0;
}

/* Status Grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.status-item {
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #3498db;
}

.status-label {
  font-size: 0.875rem;
  color: #7f8c8d;
  margin-bottom: 5px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status-value {
  font-size: 1.125rem;
  color: #2c3e50;
  font-weight: 600;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-success {
  background: #d4edda;
  color: #155724;
}

.status-warning {
  background: #fff3cd;
  color: #856404;
}

.status-error {
  background: #f8d7da;
  color: #721c24;
}

.status-info {
  background: #d1ecf1;
  color: #0c5460;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: white;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #3498db;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-success {
  background: #27ae60;
}

.btn-success:hover {
  background: #229954;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn .icon {
  font-size: 1rem;
}

/* Cron Jobs */
.cron-job-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 15px;
  background: #fafafa;
}

.cron-job-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 15px;
}

.cron-job-header h3 {
  font-size: 1.125rem;
  color: #2c3e50;
  margin: 0;
}

.cron-job-description {
  font-size: 0.875rem;
  color: #7f8c8d;
}

.cron-job-date-range {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  padding: 15px;
  background: #f0f4f8;
  border-radius: 6px;
  margin-bottom: 15px;
}

.date-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9375rem;
  font-weight: 500;
}

.date-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.quick-select-group {
  display: flex;
  gap: 6px;
}

.btn-tiny {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.cron-job-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.cron-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cron-status .duration {
  font-size: 0.875rem;
  color: #7f8c8d;
}

.days-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f0f4f8;
  border-radius: 6px;
  border: 1px solid #d0d7de;
}

.days-input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c3e50;
  margin: 0;
  white-space: nowrap;
}

.days-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9375rem;
  width: 70px;
  text-align: center;
  font-weight: 600;
}

.days-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.cron-job-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.detail-item {
  padding: 8px 0;
  font-size: 0.9375rem;
  color: #555;
}

.detail-item strong {
  color: #2c3e50;
}

.error-message {
  color: #e74c3c;
  background: #fadbd8;
  padding: 10px;
  border-radius: 4px;
  margin-top: 10px;
}

/* Tables */
.table-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 15px;
  background: #fafafa;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.table-header h3 {
  font-size: 1.125rem;
  color: #2c3e50;
  font-family: 'Courier New', monospace;
}

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

.stat-item {
  text-align: left;
}

.stat-label {
  font-size: 0.875rem;
  color: #7f8c8d;
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 1.125rem;
  color: #2c3e50;
  font-weight: 600;
}

/* Quality Checks */
.quality-check-item {
  border-left: 4px solid #e0e0e0;
  padding: 12px 15px;
  margin-bottom: 10px;
  background: #fafafa;
  border-radius: 4px;
}

.check-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.check-name {
  font-weight: 600;
  color: #2c3e50;
}

.check-message {
  font-size: 0.9375rem;
  color: #555;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

/* Table Filters */
.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding: 20px 25px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c3e50;
}

.filter-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9375rem;
  min-width: 150px;
}

.filter-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Table Container */
.table-container {
  flex: 1;
  overflow: auto;
  padding: 25px;
}

#table-data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

#table-data th {
  background: #f8f9fa;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 1;
}

#table-data td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
}

#table-data tr:hover {
  background: #f8f9fa;
}

#table-data pre {
  margin: 0;
  font-size: 0.8125rem;
  max-width: 300px;
  overflow: auto;
  background: #f4f4f4;
  padding: 5px;
  border-radius: 3px;
}

.null-value {
  color: #95a5a6;
  font-style: italic;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-top: 1px solid #e0e0e0;
}

#pagination-info {
  font-size: 0.9375rem;
  color: #555;
}

/* Logs Container */
.logs-container {
  flex: 1;
  overflow: auto;
  padding: 25px;
}

.log-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
  background: #fafafa;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.log-date {
  font-size: 0.9375rem;
  color: #7f8c8d;
}

.log-details {
  font-size: 0.9375rem;
  color: #555;
}

.log-details div {
  margin-bottom: 5px;
}

/* States */
.loading,
.empty-state,
.error-state {
  text-align: center;
  padding: 40px;
  color: #7f8c8d;
  font-size: 1rem;
}

.error-state {
  color: #e74c3c;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #2c3e50;
  color: white;
  padding: 15px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  min-width: 300px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: #27ae60;
}

.toast-error {
  background: #e74c3c;
}

.toast-warning {
  background: #f39c12;
}

.toast-info {
  background: #3498db;
}

/* LTV Estimates Section */
.ltv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 20px;
}

.ltv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ltv-table th {
  background: #f8f9fa;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 2px solid #dee2e6;
}

.ltv-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: middle;
}

.ltv-table tr:hover {
  background: #f8f9fa;
}

.ltv-table .product-name {
  font-family: 'Courier New', monospace;
  font-size: 0.8125rem;
  color: #555;
}

.ltv-table .ltv-value {
  font-weight: 600;
  color: #27ae60;
  font-size: 0.9375rem;
}

.ltv-table .notes-cell {
  max-width: 200px;
  font-size: 0.8125rem;
  color: #7f8c8d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ltv-table .date-cell {
  font-size: 0.8125rem;
  color: #7f8c8d;
  white-space: nowrap;
}

.ltv-table .actions-cell {
  white-space: nowrap;
}

.ltv-table .actions-cell .btn {
  margin-right: 5px;
}

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.type-initial {
  background: #d4edda;
  color: #155724;
}

.type-upsell {
  background: #d1ecf1;
  color: #0c5460;
}

.country-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e9ecef;
  color: #495057;
}

.country-default {
  background: #fff3cd;
  color: #856404;
}

.ltv-count {
  margin-top: 15px;
  font-size: 0.875rem;
  color: #7f8c8d;
  text-align: right;
}

.btn-danger {
  background: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
}

/* LTV Modal */
.ltv-modal-content {
  max-width: 500px;
}

.ltv-form {
  padding: 25px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 6px;
}

.form-group small {
  display: block;
  font-size: 0.75rem;
  color: #7f8c8d;
  margin-top: 4px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9375rem;
}

.form-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

.form-actions .btn {
  flex: 1;
}

/* Fill LTV Section */
.fill-ltv-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
}

.fill-ltv-info {
  padding: 0 15px 15px;
  color: #666;
}

.fill-ltv-log {
  margin: 15px;
  padding: 15px;
  background: #1a1a2e;
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.fill-ltv-log h4 {
  color: #fff;
  margin: 0 0 10px 0;
  font-size: 0.9rem;
}

.fill-ltv-log pre {
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#fill-ltv-preview {
  margin: 15px;
  padding: 15px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
}

#fill-ltv-preview h4 {
  margin: 0 0 15px 0;
}

#fill-ltv-preview-content {
  max-height: 400px;
  overflow-y: auto;
}

#fill-ltv-preview-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#fill-ltv-preview-content th,
#fill-ltv-preview-content td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  text-align: left;
}

#fill-ltv-preview-content th {
  background: #f8f9fa;
  font-weight: 600;
}

#fill-ltv-preview-content tr:hover {
  background: #f8f9fa;
}

#fill-ltv-preview-content .ltv-value {
  font-weight: 600;
  color: #27ae60;
}

#fill-ltv-preview-content .fallback {
  color: #e67e22;
  font-style: italic;
}

/* Segmented LTV Section */
.segmented-ltv-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
}

.segmented-ltv-info {
  padding: 0 15px 15px;
  color: #666;
}

.segmented-ltv-summary {
  margin: 0 15px 15px;
  padding: 12px 15px;
  background: #f5f7ff;
  border: 1px solid #e1e7ff;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #2c3e50;
}

.segmented-ltv-summary .summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.segmented-ltv-summary .summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.segmented-ltv-summary .summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.04em;
}

.segmented-ltv-summary .summary-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.segmented-ltv-table-wrap {
  margin: 0 15px 15px;
  overflow-x: auto;
}

.segmented-ltv-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #fff;
}

.segmented-ltv-table-wrap th,
.segmented-ltv-table-wrap td {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  text-align: right;
}

.segmented-ltv-table-wrap th:first-child,
.segmented-ltv-table-wrap td:first-child {
  text-align: left;
}

.segmented-ltv-table-wrap th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
}

.segmented-ltv-table-wrap .muted {
  color: #9ca3af;
  font-size: 0.78rem;
  margin-left: 6px;
  white-space: nowrap;
}

.segmented-ltv-table-wrap .total-row {
  background: #eef2ff;
  font-weight: 600;
}

/* Segmented LTV dimension sections */
.segmented-ltv-dimension-section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e5e7eb;
}

.segmented-ltv-dimension-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.segmented-ltv-dimension-section h3 {
  font-size: 0.95rem;
  color: #1e293b;
  margin: 0 0 10px 0;
  padding: 0;
  font-weight: 600;
}

/* Cron Job Categories */
.cron-category {
  margin-bottom: 25px;
}

.cron-category:last-child {
  margin-bottom: 0;
}

.cron-category-title {
  font-size: 1rem;
  color: #2c3e50;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cron-category-jobs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 15px;
}

.cron-job-item.cron-job-simple {
  padding: 15px;
}

.cron-job-item.cron-job-simple .cron-job-header {
  margin-bottom: 10px;
}

.cron-job-item.cron-job-simple .cron-job-header h4 {
  font-size: 0.9375rem;
}

.cron-job-item .cron-job-header h4 {
  font-size: 1rem;
  color: #2c3e50;
  margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header {
    padding: 20px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 15px;
  }

  .status-grid,
  .cron-job-details,
  .table-stats {
    grid-template-columns: 1fr;
  }

  .table-filters {
    flex-direction: column;
  }

  .filter-input {
    width: 100%;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .cron-job-header,
  .table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .cron-job-actions {
    width: 100%;
    flex-direction: column;
  }

  .cron-job-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .days-input-group {
    width: 100%;
    justify-content: space-between;
  }

  .days-input {
    width: 100px;
  }

  .cron-category-jobs {
    grid-template-columns: 1fr;
  }
}

/* Profit Estimation Section */
.profit-estimation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  margin-bottom: 15px;
}

.profit-estimation-info {
  margin-bottom: 20px;
  color: #7f8c8d;
}

.profit-summary {
  margin-bottom: 25px;
}

.profit-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.profit-summary-item {
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #3498db;
}

.profit-summary-item:nth-child(4) {
  border-left-color: #27ae60;
}

.profit-summary-item:nth-child(5) {
  border-left-color: #9b59b6;
}

.profit-summary-label {
  font-size: 0.8rem;
  color: #7f8c8d;
  margin-bottom: 5px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.profit-summary-value {
  font-size: 1.1rem;
  color: #2c3e50;
  font-weight: 600;
}

.profit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.profit-table th {
  background: #f8f9fa;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 2px solid #dee2e6;
}

.profit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
}

.profit-table tr:hover {
  background: #f8f9fa;
}

.profit-table .totals-row td {
  border-top: 2px solid #333;
}
