/* --- UNIVERSAL DESIGN SYSTEM --- */
:root {
  --color-background: #0a192f;
  --color-surface: #172a45;
  --color-surface-light: #2a3f5e;
  --color-text-primary: #f5f5f5;
  --color-text-secondary: #8892b0;
  --color-primary: #00a86b;
  --color-primary-hover: #00bf7a;
  --color-warning: #ffc107;
  --color-critical: #d32f2f;
  --color-approved: #00a86b;
  --color-pending: #ffc107;
  --color-border: #2a3f5e;
  --font-primary: "Inter", sans-serif;
  --font-monospace: "Roboto Mono", monospace;
  --transition-speed: 0.3s ease;
  --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  --border-radius: 8px;
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 80px;
}

/* --- RESET & GLOBAL STYLES --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  font-family: var(--font-primary);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-size: 16px;
  overflow-x: hidden;
}
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-speed);
}
a:hover {
  color: var(--color-primary-hover);
}
.monospace {
  font-family: var(--font-monospace);
  color: var(--color-text-secondary);
}
.hidden {
  display: none !important;
}

/* --- MAIN APP LAYOUT --- */
#veritas-app {
  display: flex;
  height: 100vh;
}
#app-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* --- 1. SIDEBAR / NAVIGATION --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed), transform var(--transition-speed);
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 1000;
}
.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}
.sidebar.collapsed .logo-full,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-details {
  display: none;
}
.sidebar.collapsed .logo {
  font-size: 2rem;
  padding: 0;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}
.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform var(--transition-speed);
}
.sidebar-toggle:hover {
  color: var(--color-text-primary);
}
.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}
.nav-menu {
  list-style: none;
  padding: 1rem 0;
  flex-grow: 1;
}
.nav-item a {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-item a:hover {
  background-color: var(--color-background);
  color: var(--color-text-primary);
}
.nav-item.active a {
  color: var(--color-text-primary);
  border-left-color: var(--color-primary);
  background-color: var(--color-background);
}
.nav-item i {
  width: 30px;
  font-size: 1.1rem;
  margin-right: 1rem;
  text-align: center;
}
.sidebar.collapsed .nav-item i {
  margin-right: 0;
}
.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.user-profile img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.user-details {
  display: flex;
  flex-direction: column;
}
.user-name {
  font-weight: 600;
}
.user-role {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}
.logout-btn {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
}
.mobile-menu-toggle {
  display: none;
}

/* --- 2. MAIN CONTENT & PAGES --- */
.main-container {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed);
}
.page {
  display: none;
  padding: 2rem;
  animation: fadeIn 0.5s ease;
}
.page.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.main-header h2 {
  font-size: 2rem;
  font-weight: 700;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.search-bar {
  position: relative;
}
.search-bar i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
}
.search-bar input {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  color: var(--color-text-primary);
  font-family: var(--font-primary);
  font-size: 1rem;
  width: 300px;
}
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.btn-primary {
  background-color: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

/* Claims Table */
.claims-table-container {
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  overflow-x: auto;
}
.claims-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}
.claims-table th,
.claims-table td {
  padding: 1.25rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.claims-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.claims-table tbody tr {
  cursor: pointer;
  transition: background-color var(--transition-speed);
}
.claims-table tbody tr:hover {
  background-color: var(--color-surface-light);
}
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.pending {
  background-color: rgba(255, 193, 7, 0.1);
  color: var(--color-pending);
}
.status-badge.approved {
  background-color: rgba(0, 168, 107, 0.1);
  color: var(--color-approved);
}
.risk-score-cell {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.risk-bar {
  height: 8px;
  border-radius: 4px;
  background-color: var(--color-surface-light);
  width: 100px;
}
.high-risk-bar {
  background: var(--color-critical);
  height: 100%;
  border-radius: 4px;
}
.medium-risk-bar {
  background: var(--color-warning);
  height: 100%;
  border-radius: 4px;
}
.low-risk-bar {
  background: var(--color-primary);
  height: 100%;
  border-radius: 4px;
}

/* Reports Page */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.stat-card {
  background-color: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
}
.stat-card .stat-title {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.stat-card .stat-change {
  font-size: 0.9rem;
}
.stat-change.positive {
  color: var(--color-approved);
}
.stat-change.negative {
  color: var(--color-critical);
}
.chart-container {
  background-color: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  height: 40vh;
}

/* Settings Page */
.settings-layout {
  display: flex;
  gap: 2rem;
  flex-direction: column;
}
.settings-card {
  background-color: var(--color-surface);
  padding: 2rem;
  border-radius: var(--border-radius);
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}
.form-group input,
.form-group textarea {
  width: 100%;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  color: var(--color-text-primary);
  font-size: 1rem;
  font-family: var(--font-primary);
}
.form-actions {
  margin-top: 2rem;
  text-align: right;
}

/* --- 3. AUDIT REPORT PANEL / VIEW --- */
.audit-report-panel {
  width: 450px;
  background-color: var(--color-background);
  border-left: 1px solid var(--color-border);
  padding: 2rem;
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  transform: translateX(100%);
  transition: transform var(--transition-speed);
  z-index: 1001;
}
.audit-report-panel.open {
  transform: translateX(0);
}
.panel-content {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.close-panel-btn {
  position: absolute;
  top: -10px;
  right: 0;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}
.report-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.risk-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.risk-summary .risk-label {
  font-size: 1.2rem;
  font-weight: 600;
}
.risk-summary h2 {
  font-size: 3rem;
  font-weight: 700;
}
.report-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}
.btn-secondary {
  background-color: var(--color-surface-light);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}
.finding-item {
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}
.finding-item.critical {
  border-left-color: var(--color-critical);
}
.finding-item.warning {
  border-left-color: var(--color-warning);
}
.finding-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.finding-header h6 {
  font-size: 1rem;
}
.icon-critical {
  color: var(--color-critical);
}
.icon-warning {
  color: var(--color-warning);
}
.finding-item p {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* --- 4. NEW CLAIM MODAL --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-content {
  background-color: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 700px;
  box-shadow: var(--shadow-md);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.close-modal-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.modal-content h2 {
  margin-bottom: 2rem;
}
.form-step {
  display: none;
}
.form-step.active {
  display: block;
  animation: fadeIn 0.5s;
}
.form-step-indicator {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}
.indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-surface-light);
  transition: background-color var(--transition-speed);
}
.indicator-dot.active {
  background-color: var(--color-primary);
}
.form-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--border-radius);
  padding: 3rem;
  margin-top: 1.5rem;
  text-align: center;
  cursor: pointer;
}
.drop-zone i {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 1200px) {
  .audit-report-panel {
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .main-container {
    margin-left: 0;
  }
  .main-header {
    padding-top: 0;
    margin-bottom: 1rem;
  }
  .main-header h2 {
    font-size: 1.5rem;
  }
  .page {
    padding: 1rem;
  }
  .mobile-menu-toggle {
    display: block;
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.5rem;
    z-index: 5;
  }
  .header-actions .search-bar {
    display: none;
  }

  /* Claims Cards for Mobile */
  .claims-table-container {
    background: none;
  }
  .claims-table {
    display: block;
  }
  .claims-table thead {
    display: none;
  }
  .claims-table tbody,
  .claims-table tr,
  .claims-table td {
    display: block;
  }
  .claims-table tr {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    padding: 1.5rem;
  }
  .claims-table td {
    padding: 0.5rem 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .claims-table td:first-child {
    font-size: 1.2rem;
    font-weight: 700;
    display: block;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
  }
  .claims-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-secondary);
  }
  .claims-table td:last-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .risk-score-cell {
    width: 100%;
  }
  .risk-bar {
    width: 100%;
  }

  /* Audit Report Mobile */
  .audit-report-panel {
    width: 100%;
    z-index: 2000;
  }
}
