/* ══════════════════════════════════════════════════
   MailFlat — Main Stylesheet
   ══════════════════════════════════════════════════ */

:root {
    --bg-base:    #0b0c10;
    --bg-panel:   #111318;
    --bg-card:    #181b22;
    --bg-hover:   #1f2330;
    --border:     #1f2333;
    --accent:     #00e5ff;
    --accent-dim: #00b8cc;
    --text-main:  #e2e8f0;
    --text-muted: #6b7280;
    --text-dim:   #374151;
    --green:      #22c55e;
    --red:        #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-base);
    color: var(--text-main);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* ── SCROLLBAR ─────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ══════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════ */
#auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: radial-gradient(ellipse at 50% 40%, #0d1a2a 0%, var(--bg-base) 70%);
}
.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 380px;
}
.auth-logo {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: white;
}
.auth-logo span { color: var(--accent); }
.auth-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-muted); }
.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background .2s, opacity .2s;
    width: 100%;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .2s;
    width: 100%;
}
.btn-outline:hover { background: rgba(0,229,255,.07); }

.auth-label {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.otp-input {
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 700;
}

/* ══════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════ */
#app-screen { display: none; flex-direction: column; height: 100vh; }

/* HEADER */
.app-header {
    height: 46px;
    min-height: 46px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}
.header-logo {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.5px;
    color: white;
}
.header-logo span { color: var(--accent); }
.badge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}
.live-dot {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--green);
    margin-left: auto;
}
.live-dot::before {
    content: '';
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.header-user {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-logout {
    background: transparent;
    border: 1px solid #2d2d3a;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── 3-PANEL BODY ──────────────────────── */
.panels {
    --w-inbox:  220px;
    --w-emails: 300px;
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── PANEL DIVIDER (resizable) ─────────── */
.panel-divider {
    width: 1px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    transition: background .15s;
    z-index: 10;
}
/* Wider invisible hit area */
.panel-divider::before {
    content: '';
    position: absolute;
    left: -4px;
    right: -4px;
    top: 0;
    bottom: 0;
}
.panel-divider:hover,
.panel-divider.dragging { background: var(--accent); }

/* ── PANEL 1: INBOXES ──────────────────── */
.panel-inboxes {
    width: var(--w-inbox);
    min-width: 160px;
    max-width: 420px;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
.panel-inboxes-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.btn-new-inbox {
    width: 100%;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background .2s;
}
.btn-new-inbox:hover { background: var(--accent-dim); }
.inbox-list { flex: 1; overflow-y: auto; padding: 8px; }
.inbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    border: 1px solid transparent;
}
.inbox-item:hover { background: var(--bg-hover); }
.inbox-item.active {
    background: rgba(0,229,255,.08);
    border-color: rgba(0,229,255,.2);
}
.inbox-item.active .inbox-name { color: var(--accent); }
.inbox-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.inbox-item.active .inbox-dot { background: var(--accent); }
.inbox-name {
    font-size: 12px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.inbox-empty {
    padding: 20px 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ACTION BUTTONS (🔑 + 🗑) */
.inbox-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.inbox-key-btn, .inbox-del-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1;
    transition: color .15s;
}
.inbox-item:hover .inbox-key-btn { color: var(--text-muted); }
.inbox-item.active .inbox-key-btn { color: rgba(0,229,255,.5); }
.inbox-key-btn:hover { color: var(--accent) !important; }
.inbox-del-btn {
    opacity: 0;
    font-size: 13px;
    transition: opacity .15s, color .15s, background .15s;
}
.inbox-item:hover .inbox-del-btn {
    opacity: 1;
    color: #e06c6c !important;
}
.inbox-del-btn:hover {
    color: #f85149 !important;
    background: rgba(248,81,73,.18) !important;
    border-radius: 4px;
}

/* ── FLOATING API KEY CARD ─────────────── */
#api-key-card {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid rgba(0,229,255,.25);
    border-radius: 10px;
    padding: 12px 14px;
    width: 270px;
    z-index: 999;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#api-key-card .ak-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: .6px;
    font-weight: 700;
    margin-bottom: 6px;
}
#api-key-card .ak-value {
    font-family: monospace;
    font-size: 11px;
    color: var(--accent);
    word-break: break-all;
    margin-bottom: 10px;
    line-height: 1.5;
}
#api-key-card .ak-copy {
    width: 100%;
    background: rgba(0,229,255,.1);
    border: 1px solid rgba(0,229,255,.25);
    color: var(--accent);
    border-radius: 6px;
    padding: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
}
#api-key-card .ak-copy:hover { background: rgba(0,229,255,.2); }
#api-key-card .ak-copy.copied { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.3); color: #4ade80; }

/* ── DELETE CONFIRM CARD ───────────────── */
#del-confirm-card {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid rgba(248,81,73,.35);
    border-radius: 10px;
    padding: 14px 16px;
    width: 220px;
    z-index: 999;
    box-shadow: 0 8px 32px rgba(0,0,0,.55);
}
#del-confirm-card .dc-title {
    font-size: 13px; font-weight: 700;
    color: #f85149; margin-bottom: 6px;
}
#del-confirm-card .dc-addr {
    font-size: 11px; font-family: monospace;
    color: var(--text-muted); word-break: break-all;
    margin-bottom: 6px; line-height: 1.4;
}
#del-confirm-card .dc-warn {
    font-size: 11px; color: var(--text-dim);
    margin-bottom: 12px; line-height: 1.4;
}
#del-confirm-card .dc-btns { display: flex; gap: 8px; }
#del-confirm-card .dc-cancel {
    flex: 1; padding: 6px; border-radius: 6px; cursor: pointer;
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    font-size: 12px;
}
#del-confirm-card .dc-cancel:hover { background: var(--bg-hover); }
#del-confirm-card .dc-ok {
    flex: 1; padding: 6px; border-radius: 6px; cursor: pointer;
    background: rgba(248,81,73,.15); border: 1px solid rgba(248,81,73,.4);
    color: #f85149; font-size: 12px; font-weight: 600;
}
#del-confirm-card .dc-ok:hover { background: rgba(248,81,73,.28); }

/* ── PANEL 2: EMAIL LIST ───────────────── */
.panel-emails {
    width: var(--w-emails);
    min-width: 200px;
    max-width: 600px;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
.panel-emails-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}
.panel-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.btn-refresh {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: color .2s, border-color .2s;
}
.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }
.email-list { flex: 1; overflow-y: auto; }
.email-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .15s;
    position: relative;
}
.email-item:hover { background: var(--bg-card); }
.email-item.active { background: var(--bg-hover); }
.email-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--accent);
}
.email-subject {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.email-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}
.email-sender {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.otp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(34,197,94,.12);
    border: 1px solid rgba(34,197,94,.3);
    color: #4ade80;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    font-family: monospace;
    margin-top: 4px;
}
.panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
}
.panel-empty-icon { font-size: 36px; opacity: .3; }
.panel-empty-text { font-size: 13px; color: var(--text-muted); text-align: center; }

/* ── PANEL 3: EMAIL READER ─────────────── */
.panel-reader {
    flex: 1;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 250px;
}
.reader-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}
.reader-subject {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}
.reader-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}
.otp-highlight {
    margin: 16px 24px;
    background: rgba(34,197,94,.08);
    border: 1px solid rgba(34,197,94,.25);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.otp-label { font-size: 11px; color: #4ade80; font-weight: 600; letter-spacing: .5px; }
.otp-code {
    font-size: 28px;
    font-weight: 800;
    font-family: monospace;
    color: #4ade80;
    letter-spacing: 4px;
}
.btn-copy {
    background: rgba(34,197,94,.15);
    border: 1px solid rgba(34,197,94,.3);
    color: #4ade80;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.btn-copy:hover { background: rgba(34,197,94,.25); }
.btn-copy.copied { color: white; background: #22c55e; border-color: #22c55e; }
.reader-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}
.reader-body-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Menlo', monospace;
}
.reader-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
}
.reader-empty-icon { font-size: 48px; opacity: .2; }
.reader-empty-text { font-size: 14px; color: var(--text-muted); }

/* ── NEW INBOX MODAL ───────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    width: 360px;
}
.modal-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
}
.domain-suffix {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: none;
    color: var(--text-muted);
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 0 8px 8px 0;
    white-space: nowrap;
}
.modal-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-right: none;
    color: var(--text-main);
    border-radius: 8px 0 0 8px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-muted); }

/* ── TOAST ─────────────────────────────── */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 13px;
    color: var(--text-main);
    transform: translateY(80px);
    opacity: 0;
    transition: all .3s ease;
    z-index: 200;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: rgba(34,197,94,.4); color: #4ade80; }
#toast.error   { border-color: rgba(239,68,68,.4);  color: #f87171; }
