/* Mini Webmail - UI menarik, simple */
:root {
    --bg-dark: #2b1608;
    --bg-sidebar: #241207;
    --bg-content: #fff8f2;
    --accent: #f4511e;
    --accent-hover: #d84315;
    --text: #1f2937;
    --text-muted: #6b7280;
    --white: #fff;
    --unread-bg: #fff1e6;
    --border: #f0e0d6;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #4a2313 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--white);
    padding: 32px 24px;
    text-align: center;
}

.login-header .logo {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.login-header h1 {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.login-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.login-form {
    padding: 28px 24px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(244, 81, 30, 0.18);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-block {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
}

.btn-back {
    background: var(--border);
    color: var(--text);
}

.btn-back:hover {
    background: #d1d5db;
}

/* ---------- Inbox layout ---------- */
.inbox-page {
    min-height: 100vh;
    display: flex;
    background: var(--bg-content);
}

.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-sidebar);
    color: var(--white);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo {
    font-size: 28px;
}

.sidebar-header .brand {
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.nav-item.active {
    background: var(--accent);
    color: var(--white);
}

.nav-item .icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .btn-logout {
    display: block !important;
    width: 100% !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #fff !important;
    background: #b91c1c !important;
    border: none !important;
    border-radius: 8px !important;
    text-decoration: none !important;
    text-align: center !important;
    box-sizing: border-box !important;
    transition: background 0.2s, filter 0.2s;
}

.sidebar-footer .btn-logout:hover {
    background: #991b1b !important;
    color: #fff !important;
    filter: brightness(1.1);
}

/* ---------- Content ---------- */
.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--white);
    margin: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

.content-header {
    padding: 10px 20px;
    min-height: 42px;
    background: var(--bg-content);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.header-email {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    max-width: min(100%, 320px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toolbar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}

.folder-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.auto-reload {
    font-size: 18px;
    opacity: 0.6;
}

/* ---------- Email list (2 kolom seperti Gmail: Pengirim | Subjek | Waktu) ---------- */
.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-list-header {
    display: grid;
    grid-template-columns: 220px 1fr 100px;
    gap: 16px;
    padding: 10px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 2px solid var(--border);
    background: #fafafa;
}

.email-row {
    display: grid;
    grid-template-columns: 220px 1fr 100px;
    gap: 16px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    align-items: center;
}

.email-row:hover {
    background: #f9fafb;
}

.email-row.unread {
    background: var(--unread-bg);
}

.email-row.unread .col-subjek {
    font-weight: 600;
}

.email-row .col-pengirim {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.email-row .col-subjek {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 14px;
}

.email-row .col-waktu {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
}

.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- Email view (baca) - tampilan rapi seperti gambar ---------- */
.content.email-detail-layout {
    background: #fafafa;
}

.toolbar-detail {
    border-bottom: none;
    background: #fafafa;
}

.toolbar-detail .btn-back {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    background: #e5e7eb;
    color: #374151;
}

.toolbar-detail .btn-back:hover {
    background: #d1d5db;
}

.email-view {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.email-view .email-subject {
    margin: 0 0 20px 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
}

.email-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.email-meta .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
}

.email-meta .meta-label {
    font-weight: 600;
    color: var(--text);
    min-width: 56px;
}

.email-meta .meta-value {
    color: var(--text-muted);
    word-break: break-all;
}

/* Kartu putih untuk isi email (rounded, shadow) */
.email-body-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    padding: 28px 32px;
}

.email-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

/* Isi email HTML: tabel, link, gambar */
.email-body-html {
    white-space: normal;
}

.email-body-html img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px auto;
}

.email-body-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.email-body-html td,
.email-body-html th {
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.email-body-html tr:nth-child(even) td {
    background: #f7f7f7;
}

.email-body-html a {
    color: #c2410c;
    text-decoration: none;
}

.email-body-html a:hover {
    text-decoration: underline;
}

.email-body-html strong {
    color: #c2410c;
}

/* Responsive */
@media (max-width: 768px) {
    .inbox-page {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: 0;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar-nav {
        display: flex;
        flex: 0 0 auto;
    }
    .sidebar-footer {
        width: 100%;
    }
    .email-list-header {
        grid-template-columns: 1fr 80px;
    }
    .email-list-header .col-pengirim { grid-column: 1; }
    .email-list-header .col-subjek { display: none; }
    .email-list-header .col-waktu { grid-column: 2; }
    .email-row {
        grid-template-columns: 1fr 80px;
    }
    .email-row .col-pengirim {
        grid-column: 1;
    }
    .email-row .col-subjek {
        grid-column: 1;
        grid-row: 2;
        font-size: 13px;
        font-weight: normal;
    }
    .email-row.unread .col-subjek {
        font-weight: 600;
    }
    .email-row .col-waktu {
        grid-column: 2;
        grid-row: 1 / 3;
        align-self: center;
    }
}
