/* ═══════════════════════════════════════════════════
   UPLINK WEBMAIL — Gmail-like Interface
   Premium dark theme matching admin dashboard
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-message-unread: rgba(99, 102, 241, 0.06);
  --bg-message-hover: rgba(255, 255, 255, 0.04);
  --bg-selected: rgba(99, 102, 241, 0.12);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --sidebar-width: 240px;
  --toolbar-height: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* ─── Login ────────────────────────────────────── */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease-out;
}

.login-logo { text-align: center; margin-bottom: 2.5rem; }
.logo-icon { font-size: 3rem; margin-bottom: 0.5rem; }

.login-logo h1 {
  font-size: 1.6rem; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, var(--accent), #a78bfa, var(--info));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.login-error {
  margin-top: 1rem; padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-xs); color: var(--danger); font-size: 0.85rem; text-align: center;
}

/* ─── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.4rem;
}

.form-group input, .form-group textarea {
  width: 100%; padding: 0.65rem 0.85rem;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-xs); color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem; transition: var(--transition); outline: none;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input::placeholder { color: var(--text-muted); }

/* ─── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem; border: 1px solid transparent; border-radius: var(--radius-xs);
  font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); outline: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; padding: 0.4rem 0.6rem; }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-input); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Mail App Layout ──────────────────────────── */
.mail-app { display: flex; height: 100vh; }

/* ─── Sidebar ──────────────────────────────────── */
.mail-sidebar {
  width: var(--sidebar-width); height: 100vh;
  background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: var(--transition-slow);
}

.sidebar-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); }

.sidebar-logo { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.logo-icon-sm { font-size: 1.25rem; }
.logo-text {
  font-size: 1rem; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.btn-compose {
  width: 100%; padding: 0.7rem; border-radius: var(--radius-sm); font-size: 0.9rem;
}

.folder-list { flex: 1; padding: 0.5rem; overflow-y: auto; }

.folder-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.85rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); margin-bottom: 1px;
}
.folder-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.folder-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
  color: var(--accent-hover); border: 1px solid rgba(99, 102, 241, 0.2);
}
.folder-item .folder-name { display: flex; align-items: center; gap: 0.5rem; }
.folder-item .folder-icon { width: 20px; text-align: center; }

.folder-badge {
  background: var(--accent); color: white; font-size: 0.68rem; font-weight: 700;
  padding: 0.1rem 0.45rem; border-radius: 10px; min-width: 20px; text-align: center;
}

.sidebar-footer {
  padding: 0.75rem 1rem; border-top: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 0.5rem;
}

.user-info {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.4rem 0;
}

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: white; flex-shrink: 0;
}

.user-details { min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Mail Content ─────────────────────────────── */
.mail-content {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; height: 100vh;
}

.mail-toolbar {
  height: var(--toolbar-height); padding: 0 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(10, 14, 26, 0.8); backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.toolbar-left { display: flex; align-items: center; gap: 0.75rem; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.mobile-sidebar-btn { display: none; }

.search-box { flex: 1; max-width: 500px; }
.search-input {
  width: 100%; padding: 0.5rem 1rem;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 20px; color: var(--text-primary); font-family: inherit;
  font-size: 0.85rem; outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-muted); }

/* ─── Message List ─────────────────────────────── */
.message-list-container { flex: 1; overflow-y: auto; }

.message-list { display: flex; flex-direction: column; }

.message-item {
  display: grid;
  grid-template-columns: 20px 180px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.88rem;
}
.message-item:hover { background: var(--bg-message-hover); }
.message-item.unread {
  background: var(--bg-message-unread); font-weight: 600;
}
.message-item.unread .msg-from { color: var(--text-primary); font-weight: 700; }
.message-item.unread .msg-subject { color: var(--text-primary); }

.msg-star {
  cursor: pointer; font-size: 1rem; opacity: 0.3; transition: var(--transition);
  background: none; border: none; padding: 0; color: var(--warning);
}
.msg-star:hover { opacity: 0.8; }
.msg-star.starred { opacity: 1; }

.msg-from {
  color: var(--text-secondary); font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.msg-content {
  display: flex; align-items: baseline; gap: 0.5rem;
  min-width: 0; overflow: hidden;
}
.msg-subject {
  color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-preview {
  color: var(--text-muted); font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1;
}

.msg-date {
  color: var(--text-muted); font-size: 0.78rem; white-space: nowrap;
}
.message-item.unread .msg-date { color: var(--accent-hover); font-weight: 600; }

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

/* ─── Message View ─────────────────────────────── */
.message-view {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}

.message-view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.message-actions { display: flex; gap: 0.25rem; }

.message-view-body { flex: 1; overflow-y: auto; padding: 1.5rem; }

.mv-subject { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }

.mv-meta {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding-bottom: 1.25rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1.25rem;
}

.mv-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; flex-shrink: 0;
}

.mv-sender-info { flex: 1; }
.mv-from { font-weight: 600; font-size: 0.9rem; }
.mv-to { font-size: 0.78rem; color: var(--text-muted); }
.mv-date { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

.mv-body {
  font-size: 0.92rem; line-height: 1.7; color: var(--text-secondary);
}
.mv-body img { max-width: 100%; height: auto; }

.mv-html-frame {
  width: 100%; border: none; min-height: 200px; background: white; border-radius: var(--radius-xs);
}

/* ─── Compose ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: flex-end;
  z-index: 1000; padding: 2rem;
}

.compose-window {
  width: 550px; max-height: 80vh;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease-out;
}

.compose-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border-color);
  background: var(--bg-card); border-radius: var(--radius) var(--radius) 0 0;
}
.compose-header h3 { font-size: 0.95rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.5rem;
  cursor: pointer; line-height: 1; transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.compose-body { display: flex; flex-direction: column; flex: 1; }

.compose-field {
  display: flex; align-items: center; padding: 0.45rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.compose-field label {
  font-size: 0.78rem; color: var(--text-muted); font-weight: 600; width: 55px; flex-shrink: 0;
}
.compose-field input {
  flex: 1; background: transparent; border: none; color: var(--text-primary);
  font-family: inherit; font-size: 0.88rem; outline: none; padding: 0.35rem 0;
}
.compose-field input::placeholder { color: var(--text-muted); }

.compose-editor { flex: 1; padding: 0.75rem 1.25rem; }
.compose-editor textarea {
  width: 100%; height: 200px; resize: vertical;
  background: transparent; border: none; color: var(--text-primary);
  font-family: inherit; font-size: 0.92rem; line-height: 1.6; outline: none;
}
.compose-editor textarea::placeholder { color: var(--text-muted); }

.compose-footer {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-top: 1px solid var(--border-color);
}

/* ─── Empty State ──────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem; color: var(--text-muted); text-align: center; flex: 1;
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; max-width: 400px; }

/* ─── Pagination ───────────────────────────────── */
.message-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1.25rem; border-top: 1px solid var(--border-color);
  font-size: 0.78rem; color: var(--text-muted);
}
.pagination-buttons { display: flex; gap: 0.35rem; }
.pagination-buttons button {
  padding: 0.3rem 0.6rem; background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-secondary); border-radius: var(--radius-xs); cursor: pointer;
  font-size: 0.78rem; transition: var(--transition);
}
.pagination-buttons button:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); }
.pagination-buttons button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Toast ────────────────────────────────────── */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 2000;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.85rem;
  font-weight: 500; box-shadow: var(--shadow-lg); animation: slideInRight 0.3s ease-out;
  max-width: 350px; display: flex; align-items: center; gap: 0.5rem;
}
.toast-success { background: #065f46; color: #a7f3d0; border: 1px solid rgba(16,185,129,0.3); }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid rgba(239,68,68,0.3); }
.toast-info { background: #1e3a5f; color: #bfdbfe; border: 1px solid rgba(59,130,246,0.3); }

/* ─── Animations ───────────────────────────────── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  .mail-sidebar { transform: translateX(-100%); }
  .mail-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mail-content { margin-left: 0; }
  .mobile-sidebar-btn { display: block; }
  .message-item { grid-template-columns: 20px 1fr auto; }
  .msg-from { grid-column: 2; }
  .msg-content { grid-column: 2; }
  .compose-window { width: 100%; max-width: 100%; }
  .modal-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
}
