/* ═══════════════════════════════════════════════════════════════════
   SecureVault — style.css
   Aesthetic: Terminal-noir. Deep void backgrounds, electric cyan/green
   accents, monospaced type mixed with a sharp geometric display font.
   Every UI state communicates security status visually.
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Rajdhani:wght@400;500;600;700&display=swap');

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

:root {
  /* Palette */
  --void:        #070a0f;
  --abyss:       #0c1018;
  --surface:     #111820;
  --panel:       #161e28;
  --panel-raised:#1c2535;
  --border:      #1e2d3d;
  --border-glow: #00cfff33;

  --cyan:        #00cfff;
  --cyan-dim:    #00cfff88;
  --cyan-ghost:  #00cfff18;
  --green:       #00e5a0;
  --green-dim:   #00e5a066;
  --red:         #ff3a5c;
  --red-dim:     #ff3a5c44;
  --amber:       #ffd600;
  --amber-dim:   #ffd60044;

  --text-primary:   #c8dce8;
  --text-secondary: #5f7e94;
  --text-muted:     #334455;

  /* Typography */
  --font-display: 'Rajdhani', sans-serif;
  --font-mono:    'Share Tech Mono', monospace;

  /* Spacing */
  --r:  4px;
  --r2: 8px;
  --r3: 12px;

  /* Transitions */
  --t: 0.18s ease;
}

html { font-size: 16px; }

body {
  background: var(--void);
  color: var(--text-primary);
  font-family: var(--font-mono);
  min-height: 100vh;
  line-height: 1.6;
  /* Scanline overlay */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,207,255,0.012) 2px,
      rgba(0,207,255,0.012) 4px
    );
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--abyss); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ── Typography ─────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
}

a { color: var(--cyan); text-decoration: none; transition: color var(--t); }
a:hover { color: #fff; text-shadow: 0 0 8px var(--cyan); }

/* ── Layout Utilities ───────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.flex  { display: flex; }
.grid  { display: grid; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Navigation ─────────────────────────────────────────────────── */
.nav {
  background: var(--abyss);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 0 20px var(--cyan-dim);
}

.nav-brand .lock-icon {
  font-size: 1rem;
  animation: lockPulse 3s ease-in-out infinite;
}

@keyframes lockPulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 6px var(--cyan); }
  50%       { opacity: 0.6; text-shadow: 0 0 2px var(--cyan-dim); }
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--r);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.status-badge.secure {
  background: var(--green-dim);
  border: 1px solid var(--green-dim);
  color: var(--green);
}

.status-badge.secure::before {
  content: '●';
  font-size: 0.5rem;
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Auth Pages (Login / Register) ──────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0,207,255,0.06), transparent),
    var(--void);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}

/* Corner accent */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 60px; height: 60px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
  border-radius: var(--r3) 0 0 0;
}

.auth-card::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 60px; height: 60px;
  border-bottom: 2px solid var(--cyan-dim);
  border-right: 2px solid var(--cyan-dim);
  border-radius: 0 0 var(--r3) 0;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo h1 {
  font-size: 2rem;
  color: var(--cyan);
  text-shadow: 0 0 30px var(--cyan-dim);
  margin-bottom: 6px;
}

.auth-logo .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}

.form-input:focus {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px var(--cyan-ghost), 0 0 16px rgba(0,207,255,0.08);
}

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

/* Password wrapper with toggle */
.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-right: 44px; }
.input-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  transition: color var(--t);
  font-size: 1rem;
}
.input-toggle:hover { color: var(--cyan); }

/* Strength meter */
.strength-meter {
  margin-top: 8px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.strength-bars {
  display: flex;
  gap: 3px;
  flex: 1;
}

.strength-bar {
  height: 3px;
  flex: 1;
  background: var(--border);
  border-radius: 2px;
  transition: background var(--t);
}

.strength-label {
  font-size: 0.68rem;
  min-width: 72px;
  text-align: right;
  color: var(--text-muted);
  transition: color var(--t);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--r2);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--cyan);
  color: var(--void);
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: #fff;
  box-shadow: 0 0 24px var(--cyan-dim), 0 4px 16px rgba(0,207,255,0.3);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-ghost:hover:not(:disabled) {
  border-color: var(--cyan-dim);
  color: var(--cyan);
  background: var(--cyan-ghost);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--red-dim);
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-dim);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.78rem;
}

/* Ripple loading animation */
.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Progress / Status Bar ──────────────────────────────────────── */
.progress-bar {
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  font-size: 0.75rem;
  color: var(--cyan);
  display: none;
  align-items: center;
  gap: 10px;
}

.progress-bar.visible { display: flex; }

.progress-bar .step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r2);
  font-size: 0.82rem;
  display: none;
  margin-top: 16px;
  border-left: 3px solid;
  line-height: 1.5;
}

.alert.visible { display: block; }

.alert-error {
  background: var(--red-dim);
  border-color: var(--red);
  color: #ff8099;
}

.alert-success {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.alert-info {
  background: var(--cyan-ghost);
  border-color: var(--cyan-dim);
  color: var(--cyan);
}

/* ── Dashboard Layout ───────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

.dashboard .nav {
  grid-column: 1 / -1;
}

.sidebar {
  background: var(--abyss);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 16px;
  margin-bottom: 8px;
}

.sidebar-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 8px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r2);
  color: var(--text-secondary);
  font-size: 0.83rem;
  cursor: pointer;
  transition: all var(--t);
  border: 1px solid transparent;
  font-family: var(--font-mono);
}

.sidebar-item:hover {
  background: var(--panel);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--cyan-ghost);
  border-color: var(--border-glow);
  color: var(--cyan);
}

.sidebar-item .item-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
}

/* ── Main Content ───────────────────────────────────────────────── */
.main-content {
  background: var(--void);
  overflow-y: auto;
  padding: 32px;
}

.page-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
}

.page-header .page-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ── Panel / Card ────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: 24px;
  position: relative;
}

.panel-header {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Compose Area ────────────────────────────────────────────────── */
.compose-area {
  width: 100%;
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

.compose-area:focus {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px var(--cyan-ghost);
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ── Encryption Badge ────────────────────────────────────────────── */
.enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.enc-badge.encrypting { color: var(--amber); }
.enc-badge.encrypted  { color: var(--green); }

/* ── Messages List ───────────────────────────────────────────────── */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.message-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: 18px 20px;
  transition: border-color var(--t), transform var(--t);
  position: relative;
  overflow: hidden;
}

.message-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--border);
  transition: background var(--t);
}

.message-item:hover {
  border-color: var(--border-glow);
  transform: translateX(2px);
}

.message-item:hover::before {
  background: var(--cyan);
}

.message-item.decrypted::before {
  background: var(--green);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.message-from {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.message-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.message-body {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-body.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* Ciphertext preview (shown while decrypting) */
.cipher-preview {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--abyss);
  border-radius: var(--r);
  padding: 6px 10px;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
}

/* ── Recipient Input ─────────────────────────────────────────────── */
.recipient-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.recipient-row .form-input {
  flex: 1;
}

/* ── Key Display ─────────────────────────────────────────────────── */
.key-display {
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.8;
  max-height: 100px;
  overflow-y: auto;
  position: relative;
}

.key-display .key-label {
  color: var(--cyan-dim);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

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

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

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes glitch {
  0%   { transform: translate(0); }
  20%  { transform: translate(-2px, 2px); }
  40%  { transform: translate(-2px, -2px); }
  60%  { transform: translate(2px, 2px); }
  80%  { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

.glitch-text:hover {
  animation: glitch 0.3s steps(1) forwards;
}

/* ── Lock animation during crypto ops ───────────────────────────── */
.lock-animating {
  animation: lockSpin 0.6s ease-in-out;
}

@keyframes lockSpin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(20deg) scale(1.2); color: var(--green); }
  100% { transform: rotate(0deg) scale(1); }
}

/* ── Divider ─────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
  position: relative;
}

.divider span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  padding: 0 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* ── Toast Notifications ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text-primary);
  max-width: 320px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 60px auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 4px;
  }

  .sidebar-label { display: none; }

  .sidebar-item {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .main-content {
    padding: 20px 16px;
  }

  .auth-card {
    padding: 36px 24px;
  }

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

  .compose-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 28px 20px;
  }
}
