/* === GMAIL CLIENT === */
:root {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface2: #f1f3f4;
    --border: rgba(0,0,0,0.12);
    --border-hover: rgba(0,0,0,0.24);
    --text: #202124;
    --text-muted: #5f6368;
    --text-dim: #80868b;
    --accent: #1a73e8;
    --accent-soft: #e8f0fe;
    --accent-hover: #1557b0;
    --red: #ea4335;
    --blue: #1a73e8;
    --unread-bg: #ffffff;
    --sidebar-w: 256px;
    --font-display: Roboto, Arial, sans-serif;
    --font-body: Roboto, Arial, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 2px 6px 2px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }

/* ======= LANDING PAGE ======= */
.landing {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    overflow: hidden;
}

.landing-noise {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 200px;
}

.landing-content {
    display: flex; flex-direction: column; justify-content: center;
    padding: 80px 64px; position: relative; z-index: 1;
}

.landing-badge {
    display: inline-block; padding: 4px 14px;
    background: var(--accent-soft); border: 1px solid rgba(26,115,232,0.25);
    border-radius: 100px; color: var(--accent);
    font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
    margin-bottom: 32px; width: fit-content;
}

.landing-title {
    font-family: var(--font-display); font-size: clamp(36px, 4vw, 52px);
    line-height: 1.1; margin-bottom: 24px;
    display: flex; flex-direction: column; gap: 2px;
}
.title-light { color: var(--text); font-weight: 400; }
.title-italic { color: var(--accent); font-weight: 300; }

.landing-sub {
    color: var(--text-muted); font-size: 15px; line-height: 1.7;
    max-width: 380px; margin-bottom: 40px;
}

.btn-signin {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 14px 28px; background: #fff; color: #202124;
    border: 1px solid var(--border);
    border-radius: 10px; font-weight: 500; font-size: 14px;
    width: fit-content;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.btn-signin:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.landing-note {
    margin-top: 16px; color: var(--text-dim); font-size: 12px;
}

/* Preview Window */
.landing-preview {
    display: flex; align-items: center; justify-content: center;
    padding: 60px 48px;
    background: linear-gradient(135deg, #e8f0fe 0%, #f6f8fc 100%);
    position: relative;
}
.landing-preview::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 60% 40%, rgba(26,115,232,0.08) 0%, transparent 70%);
}

.preview-window {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); width: 420px; height: 320px;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    position: relative; z-index: 1;
}
.preview-topbar {
    background: var(--surface2); padding: 10px 14px;
    display: flex; align-items: center; gap: 6px;
    border-bottom: 1px solid var(--border);
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #28c840; }
.preview-url { margin-left: 12px; font-size: 11px; color: var(--text-dim); font-family: monospace; }

.preview-window > div:not(.preview-topbar) {
    display: flex; flex: 1; overflow: hidden;
}
.preview-sidebar {
    width: 100px; background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 12px 0;
}
.ps-item {
    padding: 8px 14px; font-size: 11px; color: var(--text-muted);
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer;
}
.ps-item.active { color: var(--accent); background: var(--accent-soft); border-radius: 0 16px 16px 0; }
.badge { background: var(--accent); color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 10px; }

.preview-list { flex: 1; padding: 8px 0; overflow: hidden; }
.pe {
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    display: grid; gap: 2px;
}
.pe.unread { background: var(--unread-bg); }
.pe-from { font-size: 11px; font-weight: 600; color: var(--text); }
.pe-sub { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-date { font-size: 10px; color: var(--text-dim); text-align: right; }

/* ======= APP LAYOUT ======= */
.app, .read-app {
    display: flex; height: 100vh; overflow: hidden;
}

/* ======= SIDEBAR ======= */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}

.sidebar-header {
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
}
.app-logo {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-size: 18px; color: var(--text);
}

.sidebar-nav {
    flex: 1; padding: 12px 8px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 16px;
    color: var(--text-muted); font-size: 13px; font-weight: 400;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 13px; width: 18px; text-align: center; }
.nav-label { flex: 1; }
.nav-badge {
    color: var(--text-muted);
    font-size: 12px; font-weight: 400;
    padding: 0; background: none; border-radius: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #0d47a1);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: #fff;
    flex-shrink: 0;
}
.user-details { overflow: hidden; }
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 10px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 6px;
    color: var(--text-dim); transition: color 0.12s, background 0.12s;
}
.btn-logout:hover { color: var(--red); background: rgba(234,67,53,0.1); }

/* ======= MAIN EMAIL LIST ======= */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.main-header {
    padding: 20px 28px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.inbox-title {
    font-family: var(--font-display); font-size: 22px; font-weight: 400;
    display: flex; align-items: center; gap: 10px;
}
.inbox-count { color: var(--text-dim); font-size: 12px; margin-left: auto; }

.email-list { flex: 1; overflow-y: auto; }

.email-row {
    display: grid;
    grid-template-columns: 20px 160px 1fr auto 72px;
    align-items: center; gap: 0 16px;
    padding: 13px 28px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    cursor: pointer;
}
.email-row:hover { background: var(--surface2); }
.email-row.unread { background: var(--unread-bg); }
.email-row.unread:hover { background: var(--surface2); }

.email-dot-col { display: flex; align-items: center; justify-content: center; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.email-from { display: flex; align-items: center; gap: 10px; min-width: 0; }
.from-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text-muted); flex-shrink: 0;
}
.email-row.unread .from-avatar { border-color: var(--accent); color: var(--accent); }
.email-from > span { font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-row.unread .email-from > span { font-weight: 600; color: var(--text); }

.email-body-col { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow: hidden; }
.email-subject { font-size: 13px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 250px; }
.email-row.unread .email-subject { font-weight: 600; }
.email-snippet { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.email-attach-icon { color: var(--text-dim); display: flex; }
.email-date { font-size: 11px; color: var(--text-dim); text-align: right; white-space: nowrap; }
.email-row.unread .email-date { color: var(--accent); font-weight: 500; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 300px; gap: 12px; }
.empty-icon { font-size: 32px; color: var(--text-dim); }
.empty-state p { color: var(--text-muted); }

.pagination { padding: 20px 28px; display: flex; justify-content: center; }
.btn-page {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 24px; border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-muted); font-size: 13px;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.btn-page:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ======= EMAIL READ VIEW ======= */
.read-sidebar { justify-content: flex-start; }
.back-link {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 18px; color: var(--text-muted); font-size: 13px;
    border-bottom: 1px solid var(--border);
    transition: color 0.12s;
}
.back-link:hover { color: var(--accent); }

.read-main { flex: 1; overflow-y: auto; padding: 32px 48px; }

.email-article {
    max-width: 760px; margin: 0 auto;
}

.email-head {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.email-title {
    font-family: var(--font-display); font-size: 26px; font-weight: 400;
    line-height: 1.3; margin-bottom: 20px; color: var(--text);
}

.email-meta {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 16px;
    margin-bottom: 12px;
}
.meta-from { display: flex; align-items: center; gap: 14px; }
.sender-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #0d47a1);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 600; color: #fff;
}
.sender-name { font-weight: 600; font-size: 14px; }
.sender-email { font-size: 12px; color: var(--text-muted); }
.meta-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.meta-date { font-size: 12px; color: var(--text-dim); }
.starred-badge { font-size: 11px; color: #f0b429; background: rgba(240,180,41,0.1); padding: 2px 8px; border-radius: 100px; }
.meta-row { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.meta-label { color: var(--text-dim); font-weight: 500; }

.attachments-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 12px 16px; background: var(--surface2);
    border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 24px;
}
.attach-label { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; margin-right: 4px; }
.attachment-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 11px;
}
.att-name { color: var(--text); font-weight: 500; }
.att-size { color: var(--text-dim); }

.email-body { line-height: 1.7; }
.body-html iframe {
    width: 100%; border: none; min-height: 200px;
    background: #fff; border-radius: 8px;
}
.body-text pre {
    white-space: pre-wrap; word-break: break-word;
    font-family: var(--font-body); font-size: 14px; color: var(--text);
    line-height: 1.7;
}
.body-empty { color: var(--text-dim); font-style: italic; }

.email-actions {
    max-width: 760px; margin: 24px auto 0;
    padding-top: 20px; border-top: 1px solid var(--border);
    display: flex; gap: 10px;
}
.action-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 20px; border-radius: 8px; font-size: 13px;
    transition: background 0.12s, color 0.12s;
}
.action-btn.secondary {
    color: var(--text-muted); border: 1px solid var(--border);
}
.action-btn.secondary:hover {
    color: var(--text); background: var(--surface2); border-color: var(--border-hover);
}

/* ======= SCROLLBARS ======= */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ======= ACTION BUTTON VARIANTS ======= */
.action-btn.primary { background: var(--accent); color: #fff; font-weight: 500; }
.action-btn.primary:hover { background: var(--accent-hover); }

/* Mobile nav hidden on desktop */
.mobile-nav { display: none; }

/* ======= RESPONSIVE ======= */
@media (max-width: 900px) {
    .landing { grid-template-columns: 1fr; }
    .landing-preview { display: none; }
    .sidebar { width: 60px; min-width: 60px; }
    .nav-label, .nav-badge, .user-details, .app-logo span { display: none; }
    .email-row { grid-template-columns: 20px 44px 1fr 72px; }
    .email-body-col { flex-direction: column; gap: 2px; }
    .read-main { padding: 20px 20px; }
}

/* ======= MOBILE (≤600px) ======= */
@media (max-width: 600px) {
    .app, .read-app { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
    .sidebar { display: none !important; }
    .read-main { padding: 16px; }

    /* Bottom navigation bar */
    .mobile-nav {
        display: flex; position: fixed;
        bottom: 0; left: 0; right: 0;
        height: calc(56px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--border);
        z-index: 200;
    }
    .mob-nav-item {
        flex: 1; display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        gap: 3px; font-size: 10px; color: var(--text-muted);
        padding: 6px 4px; min-height: 44px;
        transition: color 0.12s;
    }
    .mob-nav-item:hover, .mob-nav-item.active { color: var(--accent); }

    /* Inbox — simplified stacked email rows */
    .main-header { padding: 12px 16px; }
    .inbox-title { font-size: 1rem; }
    .email-row {
        display: flex !important; flex-direction: column;
        align-items: stretch;
        padding: 12px 16px; gap: 2px; position: relative;
    }
    .email-dot-col { display: none; }
    .email-from { padding-right: 64px; gap: 6px; }
    .from-avatar { display: none; }
    .email-body-col { flex-direction: column; gap: 1px; overflow: visible; width: 100%; }
    .email-subject { max-width: none; white-space: normal; }
    .email-snippet { font-size: 11px; }
    .email-attach-icon { display: none; }
    .email-date {
        position: absolute; top: 12px; right: 16px; font-size: 11px;
        max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    /* Email read view */
    .email-title { font-size: 1.3rem; }
    .email-meta { flex-direction: column; gap: 10px; }
    .meta-right { flex-direction: row; align-items: center; align-self: flex-start; gap: 12px; }
    .email-actions { flex-direction: column; max-width: none; margin: 16px 0 0; padding-top: 12px; }
    .action-btn { justify-content: center; min-height: 44px; }

    /* Touch-friendly inputs */
    input[type="text"], input[type="number"], input[type="email"], select {
        font-size: 16px;
    }

    /* Landing */
    .landing { grid-template-columns: 1fr; }
    .landing-preview { display: none; }
    .landing-content { padding: 48px 24px; }
}
