/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Sticky Header Wrapper */
.sticky-header-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
  background: var(--gray-900);
  color: white;
  padding: 1rem 2rem;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo a {
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
}

.logo a:hover {
  text-decoration: none;
}

.header-info {
  font-size: 0.875rem;
  color: var(--gray-300);
}

/* Navigation */
.nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 2rem;
}

.nav-list {
  max-width: 1400px;
  margin: 0 auto;
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

.nav-list a {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--gray-700);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-list a:hover {
  color: var(--primary);
  text-decoration: none;
}

.nav-list a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Content */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 200px);
}

/* Footer */
.footer {
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
  padding: 1.5rem 2rem;
  text-align: center;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.footer-content p {
  margin: 0.25rem 0;
}

/* Loading */
.loading {
  text-align: center;
  padding: 4rem;
  color: var(--gray-500);
}

/* Cards */
.card {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--gray-900);
}

/* Grid */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.8rem;
}

th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-700);
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:hover {
  background: var(--gray-50);
}

tr.clickable-row:hover {
  background: var(--gray-100);
}

td.text-left {
  font-size: 0.8rem;
}

/* Dashboard specific table styles */
.dashboard-grid-2 .table-wrap {
  max-height: 450px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  font-weight: 500;
}

.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* Button Small */
.btn-sm {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--primary);
  color: white;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-sm:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

/* Stats */
.stat-card {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* Filters */
.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Page Header with Filter */
.page-header-with-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header-with-filter .page-title {
  margin-bottom: 0;
}

/* Date Filter Buttons */
.date-filter-buttons {
  display: flex;
  gap: 0.5rem;
}

.date-filter-btn {
  padding: 0.5rem 1rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s;
}

.date-filter-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.date-filter-btn.active {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

.date-filter-btn.active:hover {
  background: #0056b3;
  border-color: #0056b3;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.875rem;
  color: var(--gray-700);
}

select, input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Page Title */
.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--gray-900);
}

/* Info Grid - Compact layout for basic information */
.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  border: 1px solid var(--gray-200);
}

.info-item-full {
  grid-column: 1 / -1;
}

.info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 0.875rem;
  color: var(--gray-900);
  word-break: break-word;
}

.info-value code {
  font-size: 0.8125rem;
}

.info-value a {
  color: var(--primary);
  text-decoration: none;
}

.info-value a:hover {
  text-decoration: underline;
}

/* Empty State */
.empty {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
}

/* Loading Modal */
.loading-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  background: white;
  padding: 2rem 3rem;
  border-radius: 0.5rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading-message {
  font-size: 1rem;
  color: var(--gray-700);
  margin: 0;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Capture Status Header */
.capture-status-header {
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.capture-status-label {
  font-weight: 500;
  color: var(--gray-700);
}

.capture-time {
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* Attachments */
.attachments-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  border: 1px solid var(--gray-200);
  transition: all 0.2s;
}

.attachment-item:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.attachment-item.error {
  background: #fef2f2;
  border-color: #fecaca;
}

.attachment-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-filename {
  font-weight: 500;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-meta {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.attachment-meta.error {
  color: var(--danger);
}

.attachment-actions {
  flex-shrink: 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--primary);
  background: var(--gray-50);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Preview */
.preview-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  border: 1px solid var(--gray-200);
}

.preview-toolbar span {
  font-weight: 500;
  color: var(--gray-700);
}

.preview-toolbar > div {
  display: flex;
  gap: 0.5rem;
}

.preview-iframe {
  width: 100%;
  height: 600px;
  border: 1px solid var(--gray-200);
  border-radius: 0.375rem;
  background: white;
}

/* Dashboard Styles */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid var(--gray-200);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  font-weight: 500;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.category-chart {
  padding: 0.25rem 0;
}

.category-item {
  margin-bottom: 1rem;
}

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

.category-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.375rem;
  font-size: 0.8rem;
}

.category-name {
  font-weight: 600;
  color: var(--gray-700);
}

.category-count {
  color: var(--gray-500);
}

.category-bar {
  height: 0.625rem;
  background: var(--gray-100);
  border-radius: 0.25rem;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.6s ease;
  border-radius: 0.25rem;
}

.stats-list {
  margin-bottom: 0;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-item-label {
  color: var(--gray-700);
  font-weight: 500;
  font-size: 0.875rem;
}

.stat-item-value {
  font-weight: 600;
  font-size: 0.875rem;
}

.stat-success {
  color: var(--success);
}

.stat-pending {
  color: var(--warning);
}

.stat-failed {
  color: var(--danger);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  background: var(--gray-50);
  border-radius: 0.375rem;
  transition: background 0.2s;
}

.ranking-item:hover {
  background: var(--gray-100);
}

.ranking-number {
  width: 2rem;
  height: 2rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.ranking-content {
  flex: 1;
  min-width: 0;
}

.ranking-name {
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.125rem;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-category {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.ranking-count {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

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

.badge-danger {
  background: var(--danger);
  color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid-3 {
    grid-template-columns: 1fr;
  }

  .dashboard-grid-2 {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 0.875rem;
  }

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

  .stat-label {
    font-size: 0.75rem;
  }
}

/* Mobile Card View for Biddings */
.biddings-cards {
  display: none;
  gap: 1rem;
  padding: 0.5rem;
}

.bidding-card {
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.2s;
}

.bidding-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.bidding-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.bidding-card-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.bidding-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.bidding-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.bidding-card-info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.bidding-card-info-label {
  font-weight: 500;
  color: var(--gray-500);
  min-width: 60px;
}

.bidding-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

.bidding-card-dates {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.bidding-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .table-wrap {
    display: none !important;
  }

  .biddings-cards {
    display: block !important;
  }

  .page-header-with-filter {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .date-filter-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .date-filter-btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
  }

  .filters {
    flex-direction: column;
    padding: 0 0.5rem;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group input,
  .filter-group select {
    width: 100%;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .card {
    border-radius: 0.5rem;
  }
}
