/* Clean white theme — ChatGPT-inspired */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Söhne', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  color: #0d0d0d;
  min-height: 100vh;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e5e5;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  color: #0d0d0d;
}

.token-status {
  font-size: 12px;
  color: #8e8ea0;
}
.token-status.active { color: #10a37f; }
.token-status.expired { color: #ef4444; }

/* Credentials */
.credentials-section {
  background: #f7f7f8;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid #e5e5e5;
}

/* Provider Toggle */
.provider-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: #ececf1;
  border-radius: 10px;
  padding: 3px;
}

.toggle-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #6e6e80;
  transition: all 0.2s;
}

.toggle-btn:hover {
  color: #353740;
}

.toggle-btn.active {
  background: #fff;
  color: #0d0d0d;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6e6e80;
  margin-bottom: 6px;
}

.form-group .optional {
  font-weight: 400;
  color: #acacbe;
  font-size: 11px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d9d9e3;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #0d0d0d;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}

.form-group input::placeholder {
  color: #acacbe;
}

.form-row {
  margin-bottom: 16px;
}

.form-row textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d9d9e3;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  color: #0d0d0d;
  resize: vertical;
  font-family: 'SFMono-Regular', Consolas, monospace;
  line-height: 1.5;
}

.form-row textarea:focus {
  outline: none;
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}

.form-row textarea::placeholder {
  color: #acacbe;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

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

.btn-primary {
  background: #10a37f;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #0e8c6b; }

.btn-secondary {
  background: #ececf1;
  color: #0d0d0d;
}
.btn-secondary:hover:not(:disabled) { background: #d9d9e3; }

.btn-danger {
  background: #fff;
  color: #ef4444;
  border: 1px solid #fecaca;
}
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

.status-text {
  font-size: 13px;
  color: #8e8ea0;
  margin-left: 8px;
}
.status-text.success { color: #10a37f; }
.status-text.error { color: #ef4444; }

/* Inbox Section */
.inbox-section {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e5e5e5;
  overflow: hidden;
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #e5e5e5;
  background: #f7f7f8;
}

.inbox-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #0d0d0d;
}

.count-badge {
  background: #10a37f;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 100px;
}

/* Email List */
.email-list {
  max-height: none;
}

.email-item {
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.1s;
}

.email-item:hover {
  background: #f7f7f8;
}

.email-item:last-child {
  border-bottom: none;
}

.email-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.email-from {
  font-weight: 600;
  font-size: 14px;
  color: #0d0d0d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.email-date {
  font-size: 12px;
  color: #8e8ea0;
  white-space: nowrap;
}

.email-subject {
  font-size: 14px;
  color: #353740;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-snippet {
  font-size: 13px;
  color: #8e8ea0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  z-index: 1000;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e5e5;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  word-break: break-word;
  flex: 1;
  margin-right: 16px;
  color: #0d0d0d;
}

.modal-close {
  background: #f7f7f8;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #6e6e80;
  transition: background 0.15s;
}
.modal-close:hover { background: #ececf1; }

.modal-meta {
  padding: 14px 24px;
  background: #f7f7f8;
  font-size: 13px;
  color: #6e6e80;
  line-height: 1.8;
  border-bottom: 1px solid #e5e5e5;
}

.modal-meta strong { color: #353740; }

.modal-body {
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  color: #353740;
  overflow-x: auto;
}

.modal-body iframe {
  width: 100%;
  border: none;
  min-height: 400px;
  background: #fff;
  border-radius: 8px;
}

.modal-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

/* Loading */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #d9d9e3;
  border-top-color: #10a37f;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #8e8ea0;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

.form-hint {
  font-size: 12px;
  color: #8e8ea0;
  margin-bottom: 14px;
}

.form-hint code {
  background: #ececf1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #353740;
}

#accountSelector {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e5e5;
}

#accountSelector label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6e6e80;
  margin-bottom: 6px;
}

#accountSelect {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d9d9e3;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #0d0d0d;
}

#accountSelect:focus {
  outline: none;
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}

.email-account {
  font-weight: 400;
  font-size: 12px;
  color: #8e8ea0;
}

/* 2FA TOTP Section */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #0d0d0d;
  margin-bottom: 14px;
}

.totp-section {
  margin-bottom: 24px;
}

.totp-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.totp-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d9d9e3;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #0d0d0d;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

.totp-input-row input:focus {
  outline: none;
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}

.totp-input-row input::placeholder {
  color: #acacbe;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.totp-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.totp-code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 8px;
  color: #0d0d0d;
  user-select: all;
}

.totp-copy {
  padding: 8px 14px !important;
  font-size: 13px !important;
  white-space: nowrap;
}

.totp-timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.totp-timer-bar {
  flex: 1;
  height: 6px;
  background: #ececf1;
  border-radius: 3px;
  overflow: hidden;
}

.totp-timer-fill {
  height: 100%;
  background: #10a37f;
  border-radius: 3px;
  transition: width 1s linear, background-color 0.3s;
}

.totp-timer-fill.warning {
  background: #ef4444;
}

.totp-timer-text {
  font-size: 13px;
  font-weight: 600;
  color: #6e6e80;
  min-width: 30px;
  text-align: right;
}

.totp-timer-fill {
  transition: width 0.3s linear, background-color 0.3s;
}

@keyframes totpFlash {
  0% { color: #10a37f; transform: scale(1.05); }
  100% { color: #0d0d0d; transform: scale(1); }
}
.totp-flash {
  animation: totpFlash 0.4s ease-out;
}

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 16px 12px; }
  .credentials-section { padding: 16px; }
  .email-item { padding: 14px 16px; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { text-align: center; }
  .status-text { margin-left: 0; margin-top: 8px; }
}
