/* CSS Variables */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border-radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Dashboard Layout */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border-radius: var(--border-radius);
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-card);
  padding: 25px;
  border-radius: var(--border-radius);
  text-align: center;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-card.high-risk .stat-value {
  color: var(--danger);
}

.stat-card.moderate-risk .stat-value {
  color: var(--warning);
}

/* Filters */
.filters {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group label {
  color: var(--text-secondary);
}

select {
  padding: 10px 15px;
  border-radius: var(--border-radius);
  border: 1px solid var(--bg-card);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--border-radius);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: #c73e54;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1000px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 20px;
}

.card h2 {
  margin-bottom: 15px;
  font-size: 1.2rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--bg-secondary);
  padding-bottom: 10px;
}

.shipments-card {
  grid-column: span 2;
}

@media (max-width: 1000px) {
  .shipments-card {
    grid-column: span 1;
  }
}

/* Table */
.table-container {
  overflow-x: auto;
}

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

th, td {
  padding: 12px 15px;
  text-align: left;
}

th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
}

/* Risk Badge */
.risk-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.risk-badge.high {
  background: rgba(231, 76, 60, 0.2);
  color: var(--danger);
}

.risk-badge.moderate {
  background: rgba(243, 156, 18, 0.2);
  color: var(--warning);
}

.risk-badge.low {
  background: rgba(39, 174, 96, 0.2);
  color: var(--success);
}

/* Detail Button */
.detail-btn {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.detail-btn:hover {
  background: var(--accent);
  color: white;
}

/* Charts */
.chart-card {
  min-height: 300px;
}

.chart-card canvas {
  max-height: 250px;
}

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

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-card);
  padding: 30px;
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Risk Breakdown in Modal */
.risk-breakdown {
  margin-top: 20px;
}

.risk-factor {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.risk-factor-label {
  width: 120px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.risk-factor-bar {
  flex: 1;
  height: 20px;
  background: var(--bg-secondary);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 10px;
}

.risk-factor-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
  transition: width 0.3s;
}

.risk-factor-value {
  width: 40px;
  text-align: right;
  font-weight: 600;
}

/* Shipment Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.info-item {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 6px;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 500;
}
