/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0066cc;
  --secondary: #666;
  --danger: #cc0000;
  --warning: #ff9900;
  --success: #00aa00;
  --light-bg: #f5f5f5;
  --border: #ddd;
  --text: #333;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f2f5;
  color: var(--text);
  line-height: 1.6;
}

.container-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Role Selection */
#roleSelection {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #004c99 100%);
}

.role-selector {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  text-align: center;
}

.role-selector h1 {
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 28px;
}

.role-selector .subtitle {
  color: var(--secondary);
  margin: 20px 0 40px;
  font-size: 14px;
}

.role-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.role-btn {
  background: var(--light-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 30px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.role-btn:hover {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.role-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.role-name {
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 5px;
  color: var(--text);
}

.role-desc {
  font-size: 12px;
  color: var(--secondary);
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header h1 {
  font-size: 24px;
  color: var(--primary);
  margin: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.role-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  gap: 10px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid var(--border);
  padding: 0 30px;
  gap: 0;
}

.nav-btn {
  background: none;
  border: none;
  padding: 15px 20px;
  cursor: pointer;
  color: var(--secondary);
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 14px;
}

.nav-btn:hover {
  color: var(--primary);
}

.nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Content Tabs */
.tab-content {
  display: none;
  padding: 30px;
  flex: 1;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-card.alert {
  border-left-color: var(--danger);
}

.stat-label {
  color: var(--secondary);
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary);
}

.stat-card.alert .stat-value {
  color: var(--danger);
}

/* Sections */
.section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.section h3 {
  margin-bottom: 15px;
  color: var(--primary);
  font-size: 18px;
}

/* Inspection List */
.inspection-list {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.inspection-item {
  border-bottom: 1px solid var(--border);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.inspection-item:last-child {
  border-bottom: none;
}

.inspection-item:hover {
  background: var(--light-bg);
}

.inspection-info {
  flex: 1;
}

.inspection-site {
  font-weight: bold;
  color: var(--text);
  margin-bottom: 5px;
}

.inspection-date {
  font-size: 12px;
  color: var(--secondary);
}

.inspection-meta {
  display: flex;
  gap: 15px;
  font-size: 13px;
  margin-top: 5px;
}

.inspection-param {
  display: flex;
  gap: 5px;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.status-submitted {
  background: #e8f0ff;
  color: var(--primary);
}

.status-pending_supervisor {
  background: #fff3e0;
  color: var(--warning);
}

.status-approved {
  background: #e8f5e9;
  color: var(--success);
}

.status-rejected {
  background: #ffebee;
  color: var(--danger);
}

.critical {
  color: var(--danger);
  font-weight: bold;
}

.warning {
  color: var(--warning);
  font-weight: bold;
}

.good {
  color: var(--success);
  font-weight: bold;
}

/* Filter Bar */
.filter-bar {
  margin-bottom: 20px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  cursor: pointer;
}

/* Forms */
#inspectionForm {
  background: white;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.threshold-info {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 4px;
}

.warning {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.warning.hidden {
  display: none;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #0052a3;
}

.btn-secondary {
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #990000;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #008000;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

/* Alerts */
.anomaly-alert {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 4px;
  padding: 12px;
  margin: 15px 0;
  color: #856404;
  font-size: 14px;
}

.anomaly-alert.hidden {
  display: none;
}

/* Approval List */
.approval-list {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.approval-item {
  border-bottom: 1px solid var(--border);
  padding: 20px;
}

.approval-item:last-child {
  border-bottom: none;
}

.approval-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.approval-actions {
  display: flex;
  gap: 10px;
}

.approval-comment {
  margin-top: 10px;
  padding: 10px;
  background: var(--light-bg);
  border-radius: 4px;
  font-size: 13px;
}

/* Reports */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.report-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.report-section h3 {
  margin-bottom: 15px;
  font-size: 16px;
}

.completion-chart {
  background: var(--light-bg);
  border-radius: 4px;
  height: 30px;
  overflow: hidden;
  margin-bottom: 10px;
}

.chart-bar {
  background: linear-gradient(90deg, var(--primary), #0052a3);
  height: 100%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.status-summary {
  font-size: 14px;
}

.status-summary div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.status-summary div:last-child {
  border-bottom: none;
}

.trend-chart {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  min-height: 200px;
}

.loading {
  text-align: center;
  color: var(--secondary);
  padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .nav-tabs {
    overflow-x: auto;
    padding-left: 0;
  }

  .nav-btn {
    white-space: nowrap;
  }

  .role-buttons {
    grid-template-columns: 1fr;
  }

  .inspection-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}
