/* VeilDrop - Modern Design */

:root {
  --bg: #f8f9fa;
  --bg-white: #ffffff;
  --bg-hover: #f1f3f4;
  --bg-active: #e8f0fe;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #e8f0fe;
  --green: #0d904f;
  --green-bg: #e6f4ea;
  --red: #d93025;
  --red-bg: #fce8e6;
  --border: #dadce0;
  --border-light: #e8eaed;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-width: 240px;
}

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

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

/* Header */
.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon-wrap {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon {
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  gap: 8px;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue { background: var(--accent-light); color: var(--accent); }

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 140px);
}

.section { display: none; }
.section.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Cards */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  max-width: 600px;
  margin: 0 auto;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.card-icon { font-size: 1.5rem; }
.card-header h2 { font-size: 1.3rem; font-weight: 600; }
.card-desc { color: var(--text-secondary); margin-bottom: 24px; }

/* Login */
.login-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 480px;
  margin: 40px auto;
  overflow: hidden;
}

.login-hero {
  text-align: center;
  padding: 48px 32px 32px;
}

.hero-icon { font-size: 3rem; margin-bottom: 16px; }
.login-hero h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 8px; }
.login-hero p { color: var(--text-secondary); }

.login-actions {
  padding: 0 32px 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
}

.divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}

.divider span {
  background: var(--bg-white);
  padding: 0 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  position: relative;
}

.phrase-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-accent { background: #1a73e8; color: white; }
.btn-accent:hover { background: #1557b0; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #f8d7da; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger-text { color: var(--red) !important; }
.btn-danger-text:hover { background: var(--red-bg) !important; }

.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-small { padding: 6px 14px; font-size: 0.8rem; }
.btn-tiny { padding: 4px 10px; font-size: 0.75rem; }
.btn-full { width: 100%; }

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

/* Forms */
input, textarea {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

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

/* Recovery Phrase */
.phrase-card {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.phrase-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #92400e;
}

.recovery-phrase {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.recovery-phrase .word {
  background: rgba(255,255,255,0.8);
  padding: 6px 8px;
  border-radius: 4px;
  text-align: center;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  border: 1px solid #e5e7eb;
}

.recovery-phrase .word-num {
  color: var(--text-muted);
  font-size: 0.65rem;
  margin-right: 2px;
}

/* Address */
.address-card {
  background: var(--accent-light);
  border: 1px solid #c2d9f7;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.address-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
}

.email-address {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.expiry-line {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

/* Mailbox Layout */
.mailbox-layout {
  display: flex;
  gap: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-height: 600px;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.compose-btn { margin-bottom: 8px; font-weight: 600; }

.sidebar-address {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  word-break: break-all;
  padding: 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-xs);
  line-height: 1.4;
}

.sidebar-expiry {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 0;
}

/* Content */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Message List */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.9rem;
}

.msg-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.messages {
  display: flex;
  flex-direction: column;
}

.message-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

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

.message-item.unread {
  background: #f0f7ff;
}

.message-item.unread:hover { background: #e3effc; }

.message-item .message-icon { font-size: 1.1rem; flex-shrink: 0; }

.message-item .message-preview { flex: 1; min-width: 0; }

.message-item .message-from {
  font-weight: 500;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-item .message-subject {
  color: var(--text-secondary);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-item .message-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.has-att { font-size: 0.8rem; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-hint { font-size: 0.8rem; margin-top: 4px; }

/* Message View */
.message-view { display: flex; flex-direction: column; }

.msg-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-light);
}

.msg-toolbar-actions { display: flex; gap: 4px; }

.msg-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
}

.msg-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.msg-meta-text { flex: 1; font-size: 0.85rem; }
.msg-meta-sub { color: var(--text-muted); font-size: 0.8rem; }
.msg-meta-date { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }

.message-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.email-html {
  font-size: 0.9rem;
  line-height: 1.6;
}

.email-html img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.email-html a { color: var(--accent); }

/* Attachments */
.message-attachments {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

.message-attachments h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.attachment-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  transition: box-shadow 0.15s;
}

.attachment-card:hover { box-shadow: var(--shadow-sm); }

.attachment-card.attachment-generic {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.attachment-icon { font-size: 2rem; }

.attachment-thumb {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
  margin-bottom: 8px;
  object-fit: contain;
}

.attachment-name {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  word-break: break-all;
}

.attachment-name:hover { text-decoration: underline; }

.attachment-size {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 2px;
}

/* Compose Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  overflow: hidden;
}

.compose-modal {
  max-width: 640px;
}

.phrase-modal {
  max-width: 560px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 { font-size: 1rem; font-weight: 600; }

#compose-form {
  display: flex;
  flex-direction: column;
}

.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding: 0 20px;
}

.compose-field label {
  width: 60px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.compose-field input {
  border: none;
  padding: 12px 0;
  border-radius: 0;
  font-size: 0.9rem;
}

.compose-field input:focus { box-shadow: none; }

.compose-body-field {
  padding: 0;
  flex: 1;
}

.compose-body-field textarea {
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  resize: none;
  min-height: 200px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.compose-body-field textarea:focus { box-shadow: none; }

.compose-attachments {
  padding: 8px 20px;
  border-top: 1px solid var(--border-light);
}

.compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
}

/* Attachment list in compose */
.attachment-list { display: flex; flex-direction: column; gap: 6px; }

.attachment-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-remove-att {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-remove-att:hover { background: var(--red-bg); color: var(--red); }

.attach-btn { cursor: pointer; }

.upload-label { cursor: pointer; }

/* Phrase Modal */
.phrase-modal-body { padding: 20px; }

.warning-text {
  color: var(--red);
  font-size: 0.8rem;
  text-align: center;
  margin: 16px 0;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-links a:hover { color: var(--accent); }

/* Utility */
.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: toastIn 0.3s ease;
}

.toast.error { background: var(--red); }

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

/* Responsive */
@media (max-width: 768px) {
  .header-badges { display: none; }
  .sidebar { display: none; }
  .mailbox-layout { border-radius: var(--radius-sm); }
  .recovery-phrase { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 12px; }
  .login-card { margin: 16px auto; }
  .login-hero { padding: 32px 20px 24px; }
  .login-actions { padding: 0 20px 24px; }
  .footer-inner { flex-direction: column; gap: 4px; text-align: center; }
  .attachment-grid { grid-template-columns: 1fr; }
}
