/* ============================================
   BASE STYLES
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --danger: #ef4444;
  --success: #22c55e;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  padding-bottom: 100px;
}

.screen.active {
  display: block;
}

.container {
  max-width: 500px;
  margin: 0 auto;
}

.container.center {
  text-align: center;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

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

.small {
  font-size: 0.75rem;
}

/* ============================================
   CARDS
   ============================================ */

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

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  width: 100%;
  margin-top: 0.5rem;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.primary:disabled {
  background: #4b5563;
  cursor: not-allowed;
}

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

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

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn.small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  width: auto;
}

.btn.large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem 0;
}

.full-width {
  width: 100%;
}

/* ============================================
   FORMS
   ============================================ */

input, textarea, select {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

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

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.inline-input {
  width: 60px;
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0 0.25rem;
}

/* ============================================
   HEADER
   ============================================ */

header {
  margin-bottom: 1.5rem;
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.address-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

#my-address {
  font-family: monospace;
  font-size: 1.125rem;
  flex: 1;
}

/* ============================================
   ADDRESS BOX (voor delen)
   ============================================ */

.address-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0.75rem 0;
}

.address-box code {
  flex: 1;
  font-size: 1.125rem;
  font-family: monospace;
  letter-spacing: 0.05em;
}

/* ============================================
   BADGE
   ============================================ */

.badge {
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  min-width: 1.5rem;
  text-align: center;
}

.badge.hidden {
  display: none;
}

/* ============================================
   MESSAGES LIST
   ============================================ */

.messages-list {
  margin-bottom: 1rem;
}

.message-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s;
}

.message-item:hover {
  border-color: var(--primary);
}

.message-item .from {
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.message-item .time {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.message-item.new {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.message-item.read {
  opacity: 0.6;
}

.message-item .new-badge {
  background: var(--primary);
  color: white;
  font-size: 0.625rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

/* ============================================
   PULSE DOT
   ============================================ */

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   CONTACTS
   ============================================ */

.contacts-list {
  margin-bottom: 1rem;
}

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.contact-item .name {
  font-weight: 600;
}

.contact-item .address {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 0.875rem;
}

/* ============================================
   QR CODE
   ============================================ */

.qr-container {
  background: white;
  padding: 1rem;
  border-radius: var(--radius);
  display: inline-block;
  margin: 1rem 0;
}

.qr-container.large {
  padding: 2rem;
}

.qr-container canvas {
  display: block;
}

.qr-details {
  margin-top: 1rem;
}

.qr-details summary {
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem 0;
}

.qr-details summary:hover {
  color: var(--primary);
}

.qr-scanner {
  margin-top: 1rem;
}

.qr-scanner video {
  width: 100%;
  border-radius: var(--radius);
}

.hidden {
  display: none !important;
}

/* ============================================
   ATTACHMENTS
   ============================================ */

.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.attachment-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.attachment-item .remove {
  cursor: pointer;
  color: var(--danger);
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

/* ============================================
   BOTTOM ACTIONS
   ============================================ */

.bottom-actions {
  display: flex;
  gap: 1rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  max-width: 500px;
  margin: 0 auto;
}

.bottom-actions .btn {
  flex: 1;
  margin: 0;
  }

/* ============================================
   DECRYPTED CONTENT
   ============================================ */

#message-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1rem 0;
}

.decrypted-text {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.decrypted-text:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.decrypted-attachment {
  margin: 0.75rem 0;
}

.decrypted-attachment img {
  max-width: 100%;
  border-radius: var(--radius);
}

.decrypted-attachment video {
  max-width: 100%;
  border-radius: var(--radius);
}

.message-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.message-actions .btn {
  flex: 1;
}

.address-text {
  font-family: monospace;
  font-size: 1.25rem;
  margin: 1rem 0;
  letter-spacing: 0.05em;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 400px) {
  .screen {
    padding: 15px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .btn {
    padding: 0.75rem 1rem;
  }
  
  .address-box {
    flex-direction: column;
    align-items: stretch;
  }
  
  .address-box code {
    text-align: center;
    margin-bottom: 0.5rem;
  }
}