/* ========================================
   SwiftForms Dashboard — Dark Theme
   Matches SwiftSite.ai brand
   ======================================== */

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

:root {
  --bg-primary: #08080D;
  --bg-alt: #0D0D14;
  --bg-elevated: #18181F;
  --bg-surface: #1F1F28;
  --bg-surface-hover: #2A2A35;
  --text-primary: #F2F2F8;
  --text-secondary: #9898AE;
  --text-muted: #62627A;
  --accent: #FF6B2B;
  --accent-hover: #FF8A55;
  --accent-dark: #CC4A10;
  --border-color: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --red: #EF4444;
  --green: #22C55E;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-width: 240px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg-surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-alt);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 150ms ease;
  text-decoration: none;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--bg-surface);
  color: var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-user {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Main Content --- */
.main-with-sidebar {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

.main-full {
  padding: 2rem;
  min-height: 100vh;
}

/* --- Auth --- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 4rem);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 1rem;
}

.auth-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.accent { color: var(--accent); }

.auth-alt-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-alt-link a {
  color: var(--accent);
  text-decoration: none;
}

.auth-alt-link a:hover {
  text-decoration: underline;
}

/* --- Flash Messages --- */
.flash-messages {
  margin-bottom: 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid;
}

.flash-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.flash-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.breadcrumb {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.breadcrumb:hover { color: var(--text-secondary); }

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin: 0 0.25rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.btn-sm:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

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

/* --- Cards --- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.card-form {
  max-width: 560px;
}

/* --- Forms Grid --- */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.form-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 150ms ease;
}

.form-card:hover {
  border-color: var(--border-strong);
}

.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.form-card-header h3 {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
}

.form-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.form-card-id {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.form-card-id code {
  font-size: 0.75rem;
}

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

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-accent {
  background: rgba(255, 107, 43, 0.15);
  color: var(--accent);
}

/* --- Form Inputs --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 150ms ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 43, 0.1);
}

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

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-error {
  display: block;
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 0.25rem;
}

/* --- Data Table --- */
.table-container {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}

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

.data-table tr:hover {
  background: var(--bg-surface);
}

.data-table tr.unread td {
  background: rgba(255, 107, 43, 0.03);
}

.submission-link {
  color: var(--text-primary);
  text-decoration: none;
}

.submission-link:hover {
  color: var(--accent);
}

/* --- Status Dots --- */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-accent { background: var(--accent); }
.dot-muted { background: var(--text-muted); opacity: 0.4; }

/* --- Detail Grid --- */
.detail-grid {
  display: flex;
  flex-direction: column;
}

.detail-row {
  display: flex;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  flex-shrink: 0;
  width: 140px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: capitalize;
}

.detail-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  word-break: break-word;
}

/* --- Code Block --- */
.code-block {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.code-block code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  color: var(--accent);
  word-break: break-all;
}

.code-block .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.code-block-large {
  padding: 1rem;
}

.code-block-large pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Setup Steps --- */
.setup-steps {
  padding-left: 1.25rem;
}

.setup-steps li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.setup-steps li code {
  font-size: 0.8125rem;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* --- Utilities --- */
.text-muted { color: var(--text-muted); }
.inline-form { display: inline; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

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

  .main-with-sidebar {
    margin-left: 0;
    padding: 1.25rem;
  }

  .page-header {
    flex-direction: column;
  }

  .forms-grid {
    grid-template-columns: 1fr;
  }

  .detail-row {
    flex-direction: column;
    gap: 0.25rem;
  }

  .detail-label {
    width: auto;
  }
}
