/* ===== CSS Variables ===== */
:root {
  --panel: #ffffff;
  --border: #e5e7eb;
  --accent: #3b82f6;
  --text: #1f2937;
  --muted: #6b7280;
  --bg: #f9fafb;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
}

/* ===== Base Styles ===== */
html, body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

* {
  box-sizing: border-box;
}

/* ===== Utility Classes ===== */
.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.text-center {
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ===== Container ===== */
.smtp-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Header ===== */
.smtp-header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.smtp-header h1 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
}

.smtp-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

/* ===== Form Styles ===== */
.smtp-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.smtp-form h2 {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.smtp-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.smtp-form .field {
  min-width: auto;
}

.smtp-form .field.full-width {
  grid-column: 1 / -1;
}

.smtp-form label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 500;
}

.smtp-form input,
.smtp-form select {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.smtp-form input:focus,
.smtp-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 103, 217, 0.1);
}

.smtp-form button {
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.smtp-form button:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.smtp-form button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== Button Styles ===== */
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  display: inline-block;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== Result Display ===== */
.smtp-result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  text-align: center;
}

/* ===== Created Email Display ===== */
.smtp-created {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.smtp-created h2 {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.smtp-created .email-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 16px;
  background: #f3f4f6;
  border-radius: 8px;
}

.smtp-created .email-display {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  font-family: monospace;
}

.smtp-created .actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Inbox Styles ===== */
.smtp-inbox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.smtp-inbox .inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.smtp-inbox .inbox-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.smtp-inbox .inbox-status {
  color: var(--muted);
  font-size: 14px;
}

.smtp-inbox-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.smtp-inbox-list .message {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.smtp-inbox-list .message:hover {
  border-color: var(--accent);
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.smtp-inbox-list .message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.smtp-inbox-list .message-meta {
  flex: 1;
  min-width: 0;
}

.smtp-inbox-list .message-from {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  word-break: break-all;
}

.smtp-inbox-list .message-subject {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}

.smtp-inbox-list .message-date {
  font-size: 12px;
  color: var(--muted);
}

.smtp-inbox-list .message-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Button Components ===== */
.otp-btn {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 500;
}

.otp-btn.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.otp-btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.otp-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.otp-btn.primary:hover {
  background: #2563eb;
}

.otp-btn.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Navigation ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  padding: 12px 20px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 20px;
  transition: all 0.2s;
  font-weight: 500;
}

.back-link:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== Modal Styles ===== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 860px;
  width: 92vw;
  max-height: 80vh;
  overflow: auto;
  padding: 20px;
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background: var(--border);
}

/* Modal content styling */
.modal-content .message-content {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.9rem;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.modal-content .message-header {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.modal-content .message-meta {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-content .message-meta b {
  color: var(--text);
}

.modal-content .message-subject {
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 16px;
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  min-width: 250px;
}

.toast.show {
  transform: translateX(0);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-icon {
  font-size: 16px;
}

.toast-message {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

/* Toast variants */
.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

.toast.info {
  border-left: 4px solid var(--accent);
}

/* ===== Tab Navigation ===== */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
}

.tab-btn {
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}

.tab-btn.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Main Actions ===== */
.main-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.main-action-btn {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.main-action-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.main-action-btn:hover .action-icon {
  transform: scale(1.1);
}

.action-icon {
  font-size: 48px;
  transition: transform 0.3s;
  flex-shrink: 0;
}

.action-content h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.action-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.quick-access {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.quick-access h3 {
  margin: 0 0 15px;
  color: var(--text);
  font-size: 18px;
}

.quick-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Quick email buttons */
.quick-email {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.quick-email h3 {
  margin: 0 0 15px;
  color: var(--text);
  font-size: 18px;
}

.quick-email-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.quick-email-btn {
  padding: 10px 15px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
  transition: 0.2s;
  font-size: 14px;
}

.quick-email-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ===== Loading States ===== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Success/Error States ===== */
.success {
  color: var(--success);
  border-color: var(--success);
}

.error {
  color: var(--error);
  border-color: var(--error);
}

.warning {
  color: var(--warning);
  border-color: var(--warning);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .smtp-container {
    padding: 10px;
  }
  
  .smtp-form .row {
    grid-template-columns: 1fr;
  }
  
  .smtp-created .email-info {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .smtp-inbox .inbox-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .smtp-inbox-list .message-header {
    flex-direction: column;
    gap: 12px;
  }
  
  .smtp-inbox-list .message-actions {
    justify-content: center;
  }
  
  .modal-content {
    width: 95vw;
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .smtp-header h1 {
    font-size: 24px;
  }
  
  .smtp-form {
    padding: 16px;
  }
  
  .smtp-form button {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  .otp-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ===== Focus Styles ===== */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Animation Classes ===== */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
