/* ============================================
   AuthFam - Family Code Generator
   Theme: Friendly, Trustworthy, Accessible
   ============================================ */

:root {
  /* Palette - Clean, Trustworthy Light Theme */
  --color-bg: #f8fafc;        /* Slate 50 */
  --color-surface: #ffffff;    /* White */
  --color-text: #0f172a;      /* Slate 900 */
  --color-text-muted: #64748b; /* Slate 500 */
  
  /* Brand Colors */
  --color-primary: #2563eb;       /* Blue 600 */
  --color-primary-hover: #1d4ed8; /* Blue 700 */
  --color-primary-light: #eff6ff; /* Blue 50 */
  
  /* Status Colors */
  --color-success: #16a34a;   /* Green 600 */
  --color-warning: #d97706;   /* Amber 600 */
  --color-warning-bg: #fffbeb; /* Amber 50 */
  --color-danger: #dc2626;    /* Red 600 */
  --color-danger-bg: #fef2f2; /* Red 50 */
  
  /* UI Elements */
  --color-border: #e2e8f0;    /* Slate 200 */
  --color-focus: #3b82f6;     /* Blue 500 */
  
  /* Spacing - Generous & Breathable */
  --space-xs: 0.5rem;   /* 8px */
  --space-sm: 1rem;     /* 16px */
  --space-md: 1.5rem;   /* 24px */
  --space-lg: 2.5rem;   /* 40px */
  --space-xl: 4rem;     /* 64px */
  
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Liberation Sans', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  
  --text-sm: 0.875rem;
  --text-base: 1.125rem; /* Slightly larger base text for readability */
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 3rem;
  
  /* Shapes */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 24px;
  
  /* Modern Soft Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4 {
  margin: 0 0 var(--space-md);
  line-height: 1.2;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
  margin: 0 0 var(--space-md);
  color: var(--color-text-muted);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ============================================
   Layout
   ============================================ */

.container {
  width: 100%;
  max-width: 900px; /* Wider for more breathing room */
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  flex: 1;
}

header {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
  margin-bottom: var(--space-md);
}

header h1 {
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

header p {
  font-size: var(--text-lg);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

main {
  padding-bottom: var(--space-xl);
}

footer {
  text-align: center;
  padding: var(--space-lg);
  margin-top: auto;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  border-top: 1px solid var(--color-border);
}

/* ============================================
   Components
   ============================================ */

/* Language Selector */
.lang-selector {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  z-index: 10;
}

.lang-selector label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

.lang-selector select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.lang-selector select:hover {
  border-color: var(--color-primary);
}

.lang-selector select:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* Forms */
.form-section {
  background: var(--color-surface);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-xl);
  border: 1px solid var(--color-border);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group > label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--color-text);
  font-size: var(--text-lg);
}

.members-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.member-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

input[type="text"] {
  width: 100%;
  padding: var(--space-md); /* Large touch targets */
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--color-bg);
  transition: all 0.2s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--color-focus);
  background: var(--color-surface);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 2px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.btn-full {
  width: 100%;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

.btn-small {
  padding: 0.75rem 1.25rem;
  font-size: var(--text-sm);
}

.btn-icon {
  padding: var(--space-sm);
  background: transparent;
  color: var(--color-text-muted);
  border: 2px solid transparent;
}

.btn-icon:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-bg);
}

/* Security Warnings */
.security-section {
  background: var(--color-warning-bg);
  border: 1px solid #fcd34d;
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
}

.security-title {
  color: var(--color-warning);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xl);
  margin-bottom: var(--space-md);
}

.security-list {
  margin: 0;
  padding-left: var(--space-lg);
  color: #78350f; /* Dark amber text for readability */
}

.security-list li {
  margin-bottom: var(--space-xs);
}

/* Demo Section */
.demo-section {
  background: var(--color-surface);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}

.demo-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.demo-code {
  font-family: var(--font-mono);
  font-size: 3rem; /* Huge for readability */
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.15em;
  line-height: 1;
  padding: var(--space-sm) 0;
}

.demo-label {
  display: block;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.demo-timer {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  font-weight: 600;
}

.demo-progress-bar {
  width: 160px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.demo-progress {
  height: 100%;
  background: var(--color-primary);
  transition: width 1s linear, background-color 0.3s;
}

.demo-progress.warning {
  background: var(--color-danger);
}

/* Results (QR Grid) */
.results-section {
  text-align: center;
}

.results-section h2 {
  color: var(--color-success);
  font-size: var(--text-2xl);
  margin-bottom: var(--space-lg);
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.qr-card {
  background: var(--color-surface);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.qr-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.qr-card h3 {
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.qr-container {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  border: 2px solid var(--color-border);
}

.qr-container img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Manual Entry Toggle & Details */
.toggle-manual {
  font-size: var(--text-sm);
}

.manual-details {
  background: var(--color-bg);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  width: 100%;
  text-align: left;
  margin-top: var(--space-md);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.manual-field {
  margin-bottom: var(--space-md);
}

.manual-field:last-child {
  margin-bottom: 0;
}

.manual-field label {
  font-weight: 600;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 4px;
}

.secret-row {
  display: flex;
  gap: var(--space-sm);
}

.secret-row .value {
  font-family: var(--font-mono);
  background: white;
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  flex: 1;
  word-break: break-all;
  color: var(--color-text);
  font-size: 1rem;
}

/* Help Section */
.help-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.help-section--spaced {
  margin-bottom: var(--space-xl);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-lg);
}

.help-item h4 {
  color: var(--color-primary);
  font-size: var(--text-lg);
  margin-bottom: var(--space-sm);
}

.help-extra h4 {
  margin-top: var(--space-xl);
  font-size: var(--text-lg);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.app-links a {
  background: var(--color-surface);
  color: var(--color-primary);
  padding: 0.75rem 1.25rem;
  border-radius: 50px; /* Pill shape */
  border: 1px solid var(--color-border);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.app-links a:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  text-decoration: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-text); /* Dark background for contrast */
  color: white;
  padding: 1rem 2rem;
  border-radius: 50px;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success { border-left: none; background: #065f46; /* Dark Green */ }
.toast-error { border-left: none; background: #991b1b; /* Dark Red */ }

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  z-index: 9999;
  transition: top 0.2s;
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Print */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .lang-selector,
  .btn,
  .help-section,
  .demo-section,
  .security-section,
  .toast,
  footer {
    display: none;
  }
  
  .container {
    padding: 0;
    max-width: none;
  }
  
  .qr-grid {
    display: block;
  }
  
  .qr-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
    margin-bottom: 2rem;
    page-break-inside: avoid;
  }
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --text-3xl: 2rem;
  }
  
  .container {
    padding: var(--space-md);
  }
  
  .form-section,
  .demo-section,
  .qr-card {
    padding: var(--space-lg);
  }
  
  .lang-selector {
    position: static;
    margin-bottom: var(--space-lg);
    justify-content: center;
    width: 100%;
  }
  
  .btn-full {
    padding: 1rem;
  }
  
  .demo-display {
    padding: var(--space-md);
    gap: var(--space-lg);
  }
}
