/* =========================================
 * SECUREMESSAGES 2026 DESIGN SYSTEM
 * Based on Modern UI Design Patterns
 * ========================================= */

/* =========================================
 * CORE THEME VARIABLES
 * ========================================= */
:root {
  /* Tinted Backgrounds (No Pure Black/White) */
  --bg-base: #0a0e27;
  --bg-surface: #131836;
  --bg-surface-highlight: #1c2345;
  --bg-elevated: #252b52;

  /* Text */
  --text-primary: #fafbfc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* 2026 Cyber Palette */
  --neon-cyan: #00f5ff;
  --neon-coral: #ff006e;
  --electric-purple: #764ba2;
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Spacing Scale (8pt Grid) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;

  /* Typography */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --border-focus: var(--neon-cyan);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Light mode overrides */
[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-highlight: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-light: rgba(0, 0, 0, 0.1);
  --neon-cyan: #0891b2;
  --electric-purple: #7c3aed;
}

[data-theme="light"] .site-header {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

/* =========================================
 * GLOBAL 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 {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
}

/* =========================================
 * TYPOGRAPHY PHYSICS
 * Negative tracking for large headlines
 * ========================================= */
h1,
h2,
h3 {
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: 2.5rem;
}
h2 {
  font-size: 2rem;
}
h3 {
  font-size: 1.5rem;
}
h4 {
  font-size: 1.25rem;
  font-weight: 600;
}
h5 {
  font-size: 1rem;
  font-weight: 600;
}

.section-tag {
  color: var(--neon-cyan);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: var(--space-1);
  display: block;
}

.text-secondary {
  color: var(--text-secondary);
}
.text-muted {
  color: var(--text-muted);
}
.text-success {
  color: var(--success);
}
.text-error {
  color: var(--error);
}
.text-center {
  text-align: center;
}

small,
.small {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-surface-highlight);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

/* =========================================
 * LAYOUT
 * ========================================= */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.container-narrow {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.container-xs {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* =========================================
 * HEADER - Fixed Navigation
 * ========================================= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(
    180deg,
    var(--bg-surface) 0%,
    rgba(19, 24, 54, 0.95) 100%
  );
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-3);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-text {
  color: var(--text-primary);
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
}

.brand-icon svg,
.brand-icon iconify-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
  color: white;
}

/* Icon System - Iconify */
iconify-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: -0.125em;
}

.btn iconify-icon,
.tab iconify-icon,
.nav-tab iconify-icon,
.chip iconify-icon,
label iconify-icon,
summary iconify-icon,
h5 iconify-icon {
  margin-right: 0.375em;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.125em;
  fill: currentColor;
  flex-shrink: 0;
}

.icon-sm {
  width: 1em;
  height: 1em;
}
.icon-lg {
  width: 1.5em;
  height: 1.5em;
}
.icon-xl {
  width: 2em;
  height: 2em;
}

/* Status Icons */
.status-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid;
}

.status-icon svg,
.status-icon iconify-icon {
  width: 32px;
  height: 32px;
  font-size: 32px;
}

.status-icon.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.status-icon.error {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--error);
  color: var(--error);
}

.status-icon.info {
  background: rgba(0, 245, 255, 0.15);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.status-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
  color: var(--warning);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle iconify-icon {
  font-size: 20px;
  transition: transform 0.3s ease;
}

.theme-toggle:hover {
  background: var(--bg-surface-highlight);
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

.theme-toggle:hover iconify-icon {
  transform: rotate(15deg);
}

/* Hide/show icons based on theme */
.icon-sun {
  display: none;
}
.icon-moon {
  display: block;
}
[data-theme="light"] .icon-sun {
  display: block;
}
[data-theme="light"] .icon-moon {
  display: none;
}

/* =========================================
 * MAIN CONTENT
 * ========================================= */
main {
  padding-top: calc(64px + var(--space-4));
  padding-bottom: var(--space-6);
  min-height: calc(100vh - 200px);
}

/* =========================================
 * CARDS - Depth Through Lightness
 * ========================================= */
.card {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  animation: fade-in 0.3s ease-out;
}

[data-theme="light"] .card {
  background: var(--bg-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
  margin-bottom: var(--space-3);
}

.card-header h2,
.card-header h3 {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* =========================================
 * BUTTONS - Tactile 3:1 Ratio
 * ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 16px 48px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.1s ease,
    box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow:
    0 4px 12px rgba(102, 126, 234, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  box-shadow:
    0 6px 20px rgba(102, 126, 234, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.btn-secondary {
  background: var(--bg-surface-highlight);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--neon-cyan);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
}

.btn-sm {
  padding: 10px 24px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Context text below buttons */
.btn-context {
  margin-top: var(--space-1);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* =========================================
 * FORMS - Clean Input Fields
 * ========================================= */
.form-group {
  margin-bottom: var(--space-3);
}

label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: var(--space-2);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-helper {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Switch Toggle */
.switch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.switch input {
  width: 44px;
  height: 24px;
  appearance: none;
  background: var(--bg-elevated);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch input::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.switch input:checked {
  background: var(--electric-purple);
}

.switch input:checked::before {
  transform: translateX(20px);
}

/* =========================================
 * TABS / SEGMENTED CONTROL
 * ========================================= */
.tabs {
  display: flex;
  gap: var(--space-1);
  padding: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.tab.active {
  background: var(--accent-gradient);
  color: white;
}

/* =========================================
 * INFO BOXES & ALERTS
 * ========================================= */
.info-box {
  background: rgba(0, 245, 255, 0.08);
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: var(--space-3) 0;
}

.info-box h4,
.info-box h5 {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--neon-cyan);
  margin-bottom: var(--space-1);
}

.info-box ul {
  margin: var(--space-1) 0 0 var(--space-3);
  color: var(--text-secondary);
}

.info-box li {
  margin-bottom: 4px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.alert-success h4,
.alert-success h5 {
  color: var(--success);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  color: var(--error);
}

.alert-error strong {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* =========================================
 * CHIPS / BADGES
 * ========================================= */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface-highlight);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

/* =========================================
 * TABLES
 * ========================================= */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th,
td {
  padding: var(--space-1) var(--space-2);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td code {
  font-size: 0.75rem;
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

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

/* =========================================
 * DETAILS / ACCORDION
 * ========================================= */
details {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin: var(--space-2) 0;
}

summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "▶";
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: rotate(90deg);
}

details > div {
  padding: 0 var(--space-2) var(--space-2);
}

/* =========================================
 * SUCCESS STATE
 * ========================================= */
.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--success);
  border-radius: 50%;
  font-size: 2rem;
  color: var(--success);
}

/* =========================================
 * SHARE LINK INPUT
 * ========================================= */
.share-link-group {
  display: flex;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

.share-link-group input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.share-link-group .btn {
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}

/* =========================================
 * DESCRIPTION LIST (Share metadata)
 * ========================================= */
dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

dt {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

dd {
  color: var(--text-primary);
  font-weight: 600;
  margin: 0;
}

/* =========================================
 * NAV TABS (Admin)
 * ========================================= */
.nav-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--neon-cyan);
  border-bottom-color: var(--neon-cyan);
}

.nav-tab.danger {
  color: var(--error);
}

/* =========================================
 * STAT CARDS (Dashboard)
 * ========================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-value.primary {
  color: var(--neon-cyan);
}
.stat-value.success {
  color: var(--success);
}
.stat-value.warning {
  color: var(--warning);
}
.stat-value.error {
  color: var(--error);
}

.stat-label {
  margin-top: var(--space-1);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* =========================================
 * DANGER ZONE
 * ========================================= */
.danger-zone {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid var(--error);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: var(--space-3) 0;
}

.danger-zone h4-h5 {
  color: var(--error);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.danger-zone ul {
  margin: var(--space-2) 0 var(--space-2) var(--space-3);
  color: var(--text-secondary);
}

/* =========================================
 * FOOTER
 * ========================================= */
.site-footer {
  padding: var(--space-4) var(--space-3);
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

/* =========================================
 * ANIMATIONS
 * ========================================= */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fade-in 0.3s ease-out;
}

/* =========================================
 * LOADING STATES
 * ========================================= */
.htmx-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
}

.htmx-request .htmx-indicator {
  display: flex;
}

.htmx-request #create-btn {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =========================================
 * UTILITY CLASSES
 * ========================================= */
.hidden {
  display: none !important;
}
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-1 {
  gap: var(--space-1);
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-3 {
  margin-top: var(--space-3);
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-3 {
  margin-bottom: var(--space-3);
}

/* =========================================
 * RESPONSIVE
 * ========================================= */
@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }
  h2 {
    font-size: 1.5rem;
  }
  h3 {
    font-size: 1.25rem;
  }

  .card {
    padding: var(--space-3);
  }
  .btn {
    padding: 14px 32px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .share-link-group {
    flex-direction: column;
  }

  .nav-tabs {
    gap: 0;
  }

  .nav-tab {
    padding: var(--space-2);
    font-size: 0.8rem;
  }
}
