*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c14;
  --surface: #12151f;
  --surface2: #1a1e2e;
  --border: #252a40;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --neon: #4f9eff;
  --neon2: #a855f7;
  --text: #e8eaf6;
  --text-muted: #8b90b0;
  --error: #ff5c5c;
  --success: #4caf7d;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ── AUTH ── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse at 60% 20%, rgba(108,99,255,0.15) 0%, transparent 55%),
                    radial-gradient(ellipse at 20% 80%, rgba(79,158,255,0.1) 0%, transparent 45%);
  background-attachment: fixed;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; }

.brand-icon {
  width: 32px; height: 32px;
  object-fit: contain;
  border-radius: 4px;
  background: white;
  padding: 3px;
}

.auth-card h1 { font-size: 1.4rem; letter-spacing: 0.05em; line-height: 1.3; }
.subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; line-height: 1.5; }

.tabs {
  display: flex; gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--bg);
  padding: 4px; border-radius: 8px;
}

.tab {
  flex: 1; padding: 0.5rem;
  border: none; background: transparent;
  color: var(--text-muted); border-radius: 6px;
  cursor: pointer; font-size: 0.9rem; transition: all 0.2s;
}
.tab.active { background: var(--accent); color: white; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.field small { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }

.input-group { display: flex; align-items: center; }
.input-group input { border-radius: var(--radius) 0 0 var(--radius) !important; flex: 1; }

.suffix {
  background: var(--surface2);
  border: 1px solid var(--border); border-left: none;
  padding: 0.65rem 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem; color: var(--text-muted); white-space: nowrap;
}

input, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--text); font-size: 0.95rem;
  outline: none; transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }

select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--text); font-size: 0.95rem;
  outline: none; cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}
select:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%; padding: 0.75rem;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  font-size: 1rem; cursor: pointer;
  margin-top: 0.5rem; transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-gen-text {
  background: none; border: none;
  color: var(--accent); font-size: 0.8rem;
  cursor: pointer; padding: 0.3rem 0;
  text-align: left; transition: opacity 0.2s;
}
.btn-gen-text:hover { opacity: 0.75; }

.error {
  background: rgba(255,92,92,0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.6rem 0.75rem;
  border-radius: 8px; font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.5rem;
  background: rgba(18,21,31,0.95);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
}

.brand-small {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
}

.topbar-logo {
  width: 28px; height: 28px;
  object-fit: contain; border-radius: 4px;
  background: white; padding: 2px;
}
@media (max-width: 700px) { .hide-mobile { display: none; } }
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* ── INBOX HEADER ── */
.inbox-header {
  position: relative;
  padding: 2rem 1.5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: visible;
}

.inbox-header-glow {
  position: absolute;
  inset: 0;
  background-color: transparent;
  background-image: radial-gradient(ellipse at 0% 50%, rgba(79,158,255,0.15) 0%, transparent 55%),
                    radial-gradient(ellipse at 100% 0%, rgba(168,85,247,0.12) 0%, transparent 45%);
  pointer-events: none;
  border-radius: inherit;
}

.inbox-header-content { position: relative; z-index: 1; }

.inbox-label {
  font-size: 0.7rem; letter-spacing: 0.15em;
  color: var(--neon); font-weight: 600;
}

.inbox-header h2 {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700; margin: 0.3rem 0 1rem;
  color: var(--text);
}

.inbox-meta {
  display: flex; gap: 2rem; margin-bottom: 1.25rem;
}

.meta-item { display: flex; flex-direction: column; gap: 0.2rem; }
.meta-label { font-size: 0.75rem; color: var(--text-muted); }
.meta-value { font-size: 0.9rem; font-weight: 600; }
.status-active { color: var(--success); }

.inbox-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.btn-action {
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 20px;
  cursor: pointer; font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-action:hover { background: var(--border); }
.btn-action.btn-accent { background: var(--accent); border-color: var(--accent); color: white; }
.btn-action.btn-accent:hover { background: var(--accent-hover); }
.btn-action.btn-danger { border-color: rgba(255,92,92,0.4); color: var(--error); background: rgba(255,92,92,0.08); }
.btn-action.btn-danger:hover { background: rgba(255,92,92,0.15); }

/* ── INBOX LAYOUT ── */
.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 53px - 160px);
}

@media (max-width: 700px) {
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .email-detail { display: none; }
  .email-detail.active { display: flex; position: fixed; inset: 0; z-index: 20; background: var(--bg); flex-direction: column; }
  .inbox-header h2 { font-size: 1rem; word-break: break-all; }
  .inbox-header { padding: 1rem; }
  .inbox-meta { gap: 1rem; }
  .inbox-actions { gap: 0.4rem; }
  .btn-action { padding: 0.4rem 0.7rem; font-size: 0.78rem; }
  .topbar { padding: 0.6rem 0.75rem; }
  .brand-small span { font-size: 0.75rem; }
  .topbar-logo { width: 22px; height: 22px; }
  .inbox-layout { height: calc(100vh - 53px - 140px); }
  .email-list { height: 100%; overflow-y: auto; }
}

.email-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--surface);
}

.list-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.list-header small { font-size: 0.7rem; text-transform: none; letter-spacing: 0; }

.email-item {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.email-item:hover { background: var(--surface2); }
.email-item.active { background: var(--surface2); border-left: 3px solid var(--accent); }

.email-item-from {
  font-size: 0.85rem; font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.email-item-subject {
  font-size: 0.82rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.email-item-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ── EMAIL DETAIL ── */
.email-detail { display: flex; flex-direction: column; overflow: hidden; }

.detail-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.detail-subject { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.detail-meta {
  font-size: 0.82rem; color: var(--text-muted);
  display: flex; flex-direction: column; gap: 0.2rem;
}
.detail-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.btn-delete {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.8rem;
  border-radius: 8px; cursor: pointer;
  font-size: 0.82rem; transition: all 0.2s;
}
.btn-delete:hover { border-color: var(--error); color: var(--error); }

.detail-body {
  flex: 1; overflow-y: auto;
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem; line-height: 1.6;
}
.detail-body iframe {
  width: 100%; border: none;
  min-height: 400px; background: white; border-radius: 8px;
}

/* ── MISC ── */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  align-items: center; justify-content: center;
  height: 100%;
}
.empty-state small { font-size: 0.8rem; opacity: 0.7; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 8px; font-size: 0.85rem;
  z-index: 100;
  animation: fadeInOut 2s ease forwards;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%; max-width: 380px;
}
.modal-card h3 { margin-bottom: 1.25rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

/* ── WA FLOAT ── */
.float-item {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: row; align-items: center; gap: 0.6rem;
  z-index: 999;
}

.float-tooltip {
  background: white;
  color: #111;
  padding: 0.65rem 1rem;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  white-space: nowrap;
  position: relative;
  display: flex; align-items: center; gap: 0.5rem;
  animation: floatUpDown 2s ease-in-out infinite;
}

.float-tooltip::after { display: none; }

.float-tooltip-close {
  background: none; border: none;
  font-size: 1rem; cursor: pointer;
  color: #aaa; line-height: 1; padding: 0;
  flex-shrink: 0;
}
.float-tooltip-close:hover { color: #333; }

.tooltip-hidden .float-tooltip { display: none; }

.float-btn.wa-btn {
  width: 56px; height: 56px;
  background: #25d366;
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(37,211,102,0.45);
  text-decoration: none;
  font-size: 1.7rem;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.float-btn.wa-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(37,211,102,0.6);
}

@keyframes floatUpDown {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
