/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ── Auth View ─────────────────────────────────────────────── */
#view-auth {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-box {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-box header {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-box header h1 {
    font-size: 1.6rem;
}
.auth-box header p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-top: 0.3rem;
}
.auth-box header strong {
    color: #38bdf8;
}

.auth-form h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.email-preview {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    color: #94a3b8;
}
.email-preview strong {
    color: #38bdf8;
}

.toggle-auth {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #94a3b8;
}
.toggle-auth a {
    color: #38bdf8;
    text-decoration: none;
    cursor: pointer;
}
.toggle-auth a:hover {
    text-decoration: underline;
}

/* ── App Layout ────────────────────────────────────────────── */
#view-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}
.topbar-title {
    font-weight: 700;
    font-size: 1.05rem;
}
.topbar-user {
    margin-left: auto;
    color: #94a3b8;
    font-size: 0.85rem;
}

.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    background: #1e293b;
    border-right: 1px solid #334155;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-btn {
    width: 100%;
}

.nav-list {
    list-style: none;
    margin-top: 0.5rem;
}
.nav-item {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition:
        background 0.15s,
        color 0.15s;
}
.nav-item:hover {
    background: #334155;
    color: #e2e8f0;
}
.nav-item.active {
    background: #334155;
    color: #38bdf8;
    font-weight: 600;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    max-width: 800px;
}

.main-content h2 {
    margin-bottom: 1.25rem;
    font-size: 1.3rem;
}

/* ── Email List ────────────────────────────────────────────── */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.email-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s;
}
.email-row:hover {
    background: #334155;
    border-color: #475569;
}
.email-row.unread {
    border-left: 3px solid #38bdf8;
}
.email-row .from {
    font-weight: 600;
    min-width: 160px;
    color: #e2e8f0;
}
.email-row .subject {
    flex: 1;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-row .date {
    color: #64748b;
    font-size: 0.8rem;
    min-width: 80px;
    text-align: right;
}

.empty-state {
    color: #64748b;
    text-align: center;
    padding: 3rem 0;
}

/* ── Email Detail ──────────────────────────────────────────── */
.email-detail-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}
.email-detail-card .header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #334155;
}
.email-detail-card .header h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}
.email-detail-card .header .meta {
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1.6;
}
.email-detail-card .body {
    white-space: pre-wrap;
    line-height: 1.65;
    color: #cbd5e1;
}

.email-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

/* ── Compose ───────────────────────────────────────────────── */
#view-compose {
    max-width: 600px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
    padding: 0.7rem 1.25rem;
    background: #38bdf8;
    color: #0f172a;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.btn-primary:hover {
    background: #7dd3fc;
}
.btn-primary:active {
    transform: scale(0.98);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 0.4rem 0.85rem;
    background: #334155;
    color: #e2e8f0;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-small:hover {
    background: #475569;
}
.btn-small.danger {
    color: #fca5a5;
}
.btn-small.danger:hover {
    background: #7f1d1d;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}
label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
input,
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
input:focus,
textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}
textarea {
    resize: vertical;
}

/* ── Messages ──────────────────────────────────────────────── */
.msg {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
}
.msg.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #fca5a5;
}
.msg.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid #22c55e;
    color: #86efac;
}
.msg.info {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid #38bdf8;
    color: #7dd3fc;
}

/* ── Settings ──────────────────────────────────────────────── */
.settings-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.settings-card p {
    margin-bottom: 0.3rem;
}
.user-email {
    font-size: 1.1rem;
    color: #38bdf8;
    font-weight: 700;
}
.help-text {
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1.5;
}
.help-text code {
    background: #0f172a;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    color: #7dd3fc;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .sidebar {
        width: 60px;
        padding: 0.75rem 0.5rem;
    }
    .sidebar-btn span,
    .nav-item span {
        display: none;
    }
    .nav-item {
        text-align: center;
        font-size: 1.2rem;
    }
}
