/* GeniusComply Dashboard Styles */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--duration-short) ease-out,
              color var(--duration-short) ease-out;
}

/* Layout */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--duration-short) ease-out,
              border-color var(--duration-short) ease-out;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.logo {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* API Key Input Group */
.api-key-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  padding: var(--space-sm) var(--space-xl) var(--space-sm) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 280px;
  outline: none;
  transition: border-color var(--duration-short) ease-out;
}

.input-wrapper input:focus {
  border-color: var(--primary);
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
}

.toggle-visibility {
  position: absolute;
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-small);
  padding: 2px;
  line-height: 1;
}

.toggle-visibility:hover {
  color: var(--text);
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  transition: all var(--duration-short) ease-out;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
}

.btn-accent {
  background: var(--accent);
  color: var(--text);
}

.btn-accent:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-body);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: all var(--duration-short) ease-out;
}

.btn-icon:hover {
  background: var(--surface-alt);
}

/* Main Content */
.main {
  padding: var(--space-xl) 0 var(--space-3xl);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-lg);
  opacity: 0.4;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text);
}

.empty-state p {
  color: var(--text-muted);
  font-size: var(--text-body);
  margin-bottom: var(--space-lg);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* Section */
.section {
  margin-bottom: var(--space-xl);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text);
}

/* Overview Cards */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: background-color var(--duration-short) ease-out,
              border-color var(--duration-short) ease-out;
}

.card-label {
  font-size: var(--text-small);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-sm);
}

.card-value {
  font-family: var(--font-display);
  font-size: var(--text-display-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: var(--space-sm);
}

.card-value.score-pass { color: var(--success); }
.card-value.score-conditional { color: var(--warning); }
.card-value.score-fail { color: var(--error); }

.card-sub {
  font-size: var(--text-small);
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: 9999px;
  font-size: var(--text-caption);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.4;
}

.badge-pass {
  background: var(--primary-light);
  color: var(--success);
}

.badge-conditional {
  background: var(--accent-light);
  color: var(--warning);
}

.badge-fail {
  background: #FDEAEA;
  color: var(--error);
}

[data-theme="dark"] .badge-fail {
  background: #3D2020;
}

.badge-error {
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* Module Assessment Table */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background-color var(--duration-short) ease-out,
              border-color var(--duration-short) ease-out;
}

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

.table-wrapper th {
  font-size: var(--text-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.table-wrapper td {
  font-size: var(--text-small);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

.table-wrapper tr:hover td {
  background: var(--surface-alt);
}

.td-module {
  font-weight: 600;
  color: var(--text);
}

.td-regulation {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  color: var(--text-muted);
}

.td-score {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: 600;
}

.td-issues {
  font-size: var(--text-caption);
  color: var(--text-muted);
}

/* Quick Actions */
.actions-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Usage Stats */
.usage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.usage-stat {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.usage-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--text);
}

.usage-stat-label {
  font-size: var(--text-small);
  color: var(--text-muted);
}

/* Alert */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-small);
  margin-bottom: var(--space-md);
  display: none;
}

.alert.visible {
  display: block;
}

.alert-error {
  background: #FDEAEA;
  color: var(--error);
  border: 1px solid var(--error);
}

[data-theme="dark"] .alert-error {
  background: #3D2020;
}

.alert-info {
  background: #E3F2FD;
  color: var(--info);
  border: 1px solid var(--info);
}

[data-theme="dark"] .alert-info {
  background: #1A2A3D;
}

/* JSON output */
.json-output {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  color: var(--text);
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  display: none;
  margin-top: var(--space-md);
}

.json-output.visible {
  display: block;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-lg) 0;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-small);
}

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

.footer a:hover {
  text-decoration: underline;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

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

/* Responsive */
@media (max-width: 768px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
  }

  .input-wrapper input {
    width: 100%;
    min-width: 0;
  }

  .api-key-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .actions-row {
    flex-direction: column;
  }

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

  .table-wrapper {
    overflow-x: auto;
  }

  .table-wrapper table {
    min-width: 600px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-md);
  }

  .card-value {
    font-size: var(--text-display);
  }
}
