/* ============================================================
   DESIGN SYSTEM & VARIABLES
   ============================================================ */
:root {
  /* Light Theme Color Tokens */
  --bg-sidebar: #faf9f6;
  --bg-middle: #ffffff;
  --bg-right: #fdfdfd;
  --bg-card: #f9f8f4;
  --bg-card-hover: #f3f2eb;
  --color-border: #eae9e0;
  --color-text-primary: #1c1917;
  --color-text-muted: #78716c;
  --color-brand: #f97316; /* Premium Orange */
  --color-brand-hover: #ea580c;
  --bg-input: #f5f4eb;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Dark Theme Color Tokens */
  --bg-sidebar: #0c0a09;
  --bg-middle: #171513;
  --bg-right: #1c1917;
  --bg-card: #292524;
  --bg-card-hover: #332d2a;
  --color-border: #292524;
  --color-text-primary: #f5f5f4;
  --color-text-muted: #a8a29e;
  --color-brand: #f97316;
  --color-brand-hover: #ea580c;
  --bg-input: #1c1917;
}

/* ============================================================
   BASE STYLES & RESET
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--color-text-primary);
  background-color: var(--bg-right);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
}

button {
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* ============================================================
   APP CONTAINER LAYOUT (3 COLUMNS)
   ============================================================ */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-right);
  transition: background-color var(--transition-normal);
}

/* ────────────────────────────────────────────────────────────
   COLUMN 1: SIDEBAR
   ──────────────────────────────────────────────────────────── */
.sidebar {
  width: 290px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 20px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background-color: var(--color-brand);
  color: #ffffff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--color-text-muted);
}

.theme-btn:hover {
  background-color: var(--bg-card-hover);
  color: var(--color-text-primary);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.btn-primary {
  width: 100%;
  height: 48px;
  background-color: var(--color-brand);
  color: #ffffff;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.custom-input-wrapper {
  position: relative;
  width: 100%;
}

.custom-input-wrapper input {
  width: 100%;
  height: 44px;
  background-color: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 14px;
  color: var(--color-text-primary);
  outline: none;
}

.custom-input-wrapper input:focus {
  border-color: var(--color-brand);
  background-color: var(--bg-middle);
}

.inboxes-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inboxes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.manage-btn {
  font-size: 11px;
  color: var(--color-brand);
  font-weight: 600;
}

.inboxes-list {
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.inboxes-list::-webkit-scrollbar {
  width: 4px;
}

.inboxes-list::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 4px;
}

.inbox-item {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.inbox-item i {
  color: var(--color-brand);
  font-size: 15px;
}

.inbox-item span {
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.inbox-item.active {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
}

.inbox-item:hover:not(.active) {
  background-color: var(--bg-card-hover);
}

.sidebar-footer {
  margin-top: 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* ────────────────────────────────────────────────────────────
   COLUMN 2: EMAILS LIST PANEL
   ──────────────────────────────────────────────────────────── */
.emails-list-panel {
  width: 340px;
  background-color: var(--bg-middle);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.panel-header {
  padding: 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.active-email-info h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 230px;
}

.update-status {
  font-size: 12px;
  color: var(--color-text-muted);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--color-text-primary);
}

.search-wrapper {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-sidebar);
  border-radius: 8px;
  padding: 0 14px;
  height: 38px;
}

.search-box i {
  color: var(--color-text-muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  height: 100%;
  font-size: 13px;
  outline: none;
}

.emails-container {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.emails-container::-webkit-scrollbar {
  width: 4px;
}

.emails-container::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
}

/* Email List Item */
.email-card {
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.email-card:hover {
  background-color: var(--bg-card-hover);
}

.email-card.active {
  background-color: var(--bg-card);
}

.email-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.email-sender {
  font-weight: 600;
  max-width: 180px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

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

.email-subject {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.email-preview {
  font-size: 12px;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty Inbox State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 40px;
  text-align: center;
}

.empty-state-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--bg-card);
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ────────────────────────────────────────────────────────────
   COLUMN 3: EMAIL DETAIL PANEL
   ──────────────────────────────────────────────────────────── */
.email-detail-panel {
  flex-grow: 1;
  background-color: var(--bg-right);
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal);
}

.detail-header {
  height: 85px;
  padding: 0 32px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-email-display {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 15px;
}

.header-email-display i {
  color: var(--color-brand);
}

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

.btn-secondary {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-middle);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
}

.btn-secondary-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background-color: var(--bg-middle);
  color: var(--color-text-muted);
}

.btn-secondary-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--color-text-primary);
}

.detail-view-area {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.select-email-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  text-align: center;
  color: var(--color-text-muted);
}

.select-email-placeholder i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.select-email-placeholder h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.select-email-placeholder p {
  font-size: 13px;
}

/* Email View Layout */
.email-view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.email-view-sender-info {
  display: flex;
  gap: 16px;
  align-items: center;
}

.sender-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--color-brand);
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sender-details h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.sender-details p {
  font-size: 12px;
  color: var(--color-text-muted);
}

.email-view-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.email-view-date {
  font-size: 12px;
  color: var(--color-text-muted);
}

.btn-danger {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: #ef4444;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.08);
}

.email-view-subject-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.email-view-body-wrapper {
  flex-grow: 1;
  background-color: var(--bg-middle);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 400px;
  display: flex;
}

.email-view-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff; /* Always render email on white background for HTML readability */
}

/* ============================================================
   MODALS STYLING
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--bg-middle);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  width: 480px;
  max-width: 90%;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  margin-bottom: 24px;
}

.modal-icon-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.modal-envelope-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: rgba(249, 115, 22, 0.1);
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.modal-icon-title h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
}

.modal-icon-title p {
  font-size: 13px;
  color: var(--color-text-muted);
}

.modal-body {
  margin-bottom: 28px;
}

.input-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0 14px;
  height: 46px;
  margin-bottom: 16px;
}

.input-group input {
  flex-grow: 1;
  height: 100%;
  font-size: 14px;
  outline: none;
  min-width: 0;
}

.at-sign {
  color: var(--color-text-muted);
  font-weight: 600;
  padding: 0 8px;
}

.input-group select {
  font-size: 14px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.preview-box {
  background-color: rgba(249, 115, 22, 0.05);
  border: 1px dashed var(--color-brand);
  border-radius: 10px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--color-brand);
  font-size: 15px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-right-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-text {
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text-muted);
  padding: 8px 12px;
}

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

.btn-action {
  height: 44px;
  padding: 0 20px;
  background-color: var(--color-brand);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
}

.btn-action:hover {
  background-color: var(--color-brand-hover);
}

/* QR Code Modal Custom */
.qr-content {
  width: 340px;
  position: relative;
  text-align: center;
  padding-top: 36px;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.modal-close-btn:hover {
  color: var(--color-text-primary);
}

.qr-header {
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
}

.qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#qrcode-container {
  background-color: #ffffff;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

#qr-email-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 110;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(100%);
  animation: slideIn 0.25s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success i {
  color: #10b981;
}

.toast.error i {
  color: #ef4444;
}

@keyframes slideIn {
  to {
    transform: translateX(0);
  }
}
