/* ============================================================
   PLS Webmail — identidade visual PLS
   Paleta: azul #074679 · claro #67BCD8 · profundo #053962/#021c31
   ============================================================ */

:root {
    --pls-blue: #074679;
    --pls-blue-dark: #053962;
    --pls-blue-night: #021c31;
    --pls-cyan: #67BCD8;
    --pls-cyan-soft: #9ad4ea;
    --pls-mist: #f1fafd;
    --pls-ice: #ddf1f8;
    --bg: #f4f8fb;
    --surface: #ffffff;
    --text: #10263a;
    --muted: #64798c;
    --line: #e2ecf3;
    --danger: #d64545;
    --success: #1c9e6e;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(7, 70, 121, .08), 0 8px 24px rgba(7, 70, 121, .06);
    --shadow-lift: 0 4px 10px rgba(7, 70, 121, .12), 0 16px 40px rgba(7, 70, 121, .10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

a { color: var(--pls-blue); text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 58px;
    background: linear-gradient(90deg, var(--pls-blue-night) 0%, var(--pls-blue) 60%, var(--pls-blue-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(2, 28, 49, .25);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: .2px;
}

.brand img.brand-logo {
    height: 32px;
    width: auto;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}

.brand:hover img.brand-logo { transform: scale(1.06); }

.brand-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, .35);
    display: inline-block;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, .12);
    border-radius: 999px;
    padding: 4px 14px 4px 4px;
    font-size: 13px;
    color: #dff1fa;
}

.user-chip .avatar { width: 28px; height: 28px; font-size: 11px; }

/* ---------- Layout ---------- */
.app {
    display: flex;
    min-height: calc(100vh - 58px);
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.content {
    flex: 1;
    padding: 20px 26px 40px;
    min-width: 0;
    animation: pageIn .35s ease both;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Sidebar ---------- */
.btn-compose {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--pls-blue) 0%, #0a5b96 100%);
    color: #fff;
    font-weight: 600;
    border: 0;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
}

.btn-compose:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn-compose:active { transform: translateY(0) scale(.98); }

.folders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.folders a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: background .15s ease, transform .15s ease;
}

.folders a:hover { background: var(--pls-ice); transform: translateX(3px); }

.folders a.active {
    background: var(--pls-blue);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(7, 70, 121, .25);
}

.folders a.drop-hover {
    background: var(--pls-cyan);
    color: var(--pls-blue-night);
    transform: scale(1.04);
    box-shadow: 0 0 0 2px var(--pls-blue) inset;
}

.folders .f-count {
    margin-left: auto;
    font-size: 11px;
    background: var(--pls-cyan);
    color: var(--pls-blue-night);
    border-radius: 999px;
    padding: 1px 8px;
    font-weight: 700;
}

.folders a.active .f-count { background: rgba(255,255,255,.25); color: #fff; }

.side-sep {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 12px 4px;
}

.side-links { display: flex; flex-direction: column; gap: 2px; }

.side-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13.5px;
    transition: background .15s, color .15s, transform .15s;
}

.side-links a:hover { background: var(--pls-ice); color: var(--pls-blue); transform: translateX(3px); }

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar h2 { margin: 0; font-size: 20px; color: var(--pls-blue-dark); }

.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 8px 6px 16px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
    flex: 1;
    max-width: 420px;
}

.search-box:focus-within { box-shadow: 0 0 0 3px var(--pls-cyan-soft); }

.search-box input {
    border: 0;
    outline: 0;
    flex: 1;
    font-size: 14px;
    background: transparent;
    color: var(--text);
}

.search-box button {
    border: 0;
    background: var(--pls-blue);
    color: #fff;
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
}

.search-box button:hover { background: var(--pls-blue-dark); }

.pager { display: flex; align-items: center; gap: 8px; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--pls-blue);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all .15s ease;
}

.btn:hover { border-color: var(--pls-cyan); background: var(--pls-mist); transform: translateY(-1px); }

.btn-primary {
    background: var(--pls-blue);
    border-color: var(--pls-blue);
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover { background: var(--pls-blue-dark); color: #fff; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: #fdf0f0; }

.btn-small { padding: 5px 11px; font-size: 12.5px; }

.inline { display: inline; }

/* ---------- Layout lista + leitura (estilo Outlook) ---------- */
.mail-layout { display: block; }

.mail-layout.split {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

/* min-width:0 é essencial: sem isso o conteúdo estoura a coluna do grid */
.mail-layout.split > * { min-width: 0; }

.mail-layout.split .mail-list-col {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Na coluna estreita a tabela obedece a largura disponível */
.mail-layout.split .msg-list { table-layout: fixed; width: 100%; }
.mail-layout.split .msg-list td { padding: 9px 6px; }
.mail-layout.split .col-avatar { width: 40px; padding-left: 8px !important; }
.mail-layout.split .avatar { width: 28px; height: 28px; font-size: 10.5px; }
.mail-layout.split .col-from { width: 96px; max-width: 96px; font-size: 13px; }
.mail-layout.split .col-subject { max-width: 0; } /* deixa o ellipsis funcionar */
.mail-layout.split .col-att { width: 22px; }
.mail-layout.split .col-date { width: 46px; font-size: 11px; padding-right: 4px !important; }
.mail-layout.split .col-actions { width: 34px; padding-right: 8px !important; }
.mail-layout.split .row-actions .icon-btn[data-action="toggle-seen"] { display: none; }
.mail-layout.split .msg-list tr:hover { transform: none; }

.mail-layout.split .msg-list tr.active {
    background: var(--pls-ice);
    box-shadow: inset 3px 0 0 var(--pls-blue);
}

.mail-read-col {
    position: sticky;
    top: 74px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* A animação fica no conteúdo (recarregado a cada mensagem), nunca na coluna
   sticky — transform residual desalinharia a coluna. */
.mail-read-col .message {
    padding: 4px 24px 24px;
    box-shadow: none;
    border-radius: 0;
    animation: pageIn .25s ease both;
}
.mail-read-col .msg-subject { font-size: 18px; }
.mail-read-col .html-body { min-height: 44vh; }

/* Barra de ações do painel: fica grudada no topo enquanto rola */
.msg-toolbar-pane {
    justify-content: flex-end;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}

.msg-toolbar-pane > div { display: flex; gap: 6px; flex-wrap: wrap; }

.pane-placeholder { padding: 80px 20px; box-shadow: none; }

.pane-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px;
    color: var(--muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--pls-ice);
    border-top-color: var(--pls-blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.msg-from-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-from-line .avatar { width: 32px; height: 32px; font-size: 12px; }
.msg-from-line strong { color: var(--text); }

.mail-layout.split .drag-hint { font-size: 11.5px; margin: 8px 4px 0; }

@media (max-width: 1100px) {
    .mail-layout.split { grid-template-columns: 1fr; }
    .mail-layout.split .mail-list-col { max-height: none; }
    .mail-read-col { position: static; max-height: none; }
    .mail-layout.split .col-from { width: 150px; max-width: 150px; }
}

/* ---------- Lista de mensagens ---------- */
.msg-list {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.msg-list tr {
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .12s ease, transform .12s ease, box-shadow .12s ease;
    animation: rowIn .3s ease both;
}

.msg-list tr:nth-child(1) { animation-delay: .02s; }
.msg-list tr:nth-child(2) { animation-delay: .04s; }
.msg-list tr:nth-child(3) { animation-delay: .06s; }
.msg-list tr:nth-child(4) { animation-delay: .08s; }
.msg-list tr:nth-child(5) { animation-delay: .10s; }

@keyframes rowIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.msg-list tr:hover {
    background: var(--pls-mist);
    transform: translateX(2px);
    box-shadow: inset 3px 0 0 var(--pls-cyan);
}

.msg-list tr.dragging { opacity: .45; }

.msg-list td { padding: 11px 12px; vertical-align: middle; }

.msg-list tr:last-child { border-bottom: 0; }

.col-avatar { width: 52px; padding-right: 0 !important; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .5px;
    flex-shrink: 0;
    user-select: none;
}

.col-from { width: 210px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.unseen .col-from, .unseen .col-subject a { font-weight: 700; color: var(--pls-blue-dark); }

.unseen-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--pls-cyan);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 6px var(--pls-cyan);
}

.col-subject { overflow: hidden; }
.col-subject a { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.col-att { width: 30px; text-align: center; }
.col-date { width: 76px; text-align: right; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.col-actions { width: 84px; text-align: right; white-space: nowrap; }

.row-actions { opacity: 0; transition: opacity .15s; display: inline-flex; gap: 2px; }

.msg-list tr:hover .row-actions { opacity: 1; }

.icon-btn {
    border: 0;
    background: transparent;
    font-size: 15px;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 8px;
    transition: background .12s, transform .12s;
}

.icon-btn:hover { background: var(--pls-ice); transform: scale(1.15); }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 70px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty .empty-ico { font-size: 44px; display: block; margin-bottom: 10px; animation: float 3s ease-in-out infinite; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* ---------- Mensagem ---------- */
.message {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 30px;
}

.msg-subject { margin: 0 0 14px; color: var(--pls-blue-dark); }

.msg-meta {
    font-size: 13.5px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.msg-attachments { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--pls-mist);
    border: 1px solid var(--pls-ice);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    transition: all .15s;
}

.attachment:hover { border-color: var(--pls-cyan); transform: translateY(-1px); box-shadow: var(--shadow); }

.html-body { width: 100%; min-height: 60vh; border: 0; }

.text-body { white-space: pre-wrap; font-family: inherit; line-height: 1.55; }

/* ---------- Compor ---------- */
.compose {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 860px;
}

.compose label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; position: relative; }

.compose input[type="text"], .compose textarea, .form-card input[type="text"], .form-card input[type="email"], .form-card textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: 0;
}

.compose input:focus, .compose textarea:focus, .form-card input:focus, .form-card textarea:focus {
    border-color: var(--pls-cyan);
    box-shadow: 0 0 0 3px var(--pls-ice);
}

.compose-actions { display: flex; gap: 10px; }

/* ---------- Autocomplete ---------- */
.ac-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-lift);
    z-index: 80;
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
    animation: pageIn .15s ease both;
}

.ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 400;
}

.ac-item:hover, .ac-item.sel { background: var(--pls-mist); }

.ac-item .avatar { width: 30px; height: 30px; font-size: 11px; }

.ac-item .ac-name { color: var(--text); font-size: 14px; }
.ac-item .ac-mail { color: var(--muted); font-size: 12px; }

/* ---------- Contatos ---------- */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.contact-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform .18s ease, box-shadow .18s ease;
    animation: rowIn .3s ease both;
}

.contact-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.contact-card .avatar { width: 42px; height: 42px; font-size: 15px; }

.contact-info { flex: 1; min-width: 0; }
.contact-info .c-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-info .c-mail { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-tag { font-size: 10px; color: var(--pls-cyan); }

.form-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: 860px;
}

.form-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; flex: 1; min-width: 180px; }

.form-card textarea { width: 100%; }
.form-card .full { flex-basis: 100%; }

/* ---------- Alertas / Toasts ---------- */
.alert { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fdecec; color: #96281f; border: 1px solid #f5c6c6; }
.alert-success { background: #e7f7ef; color: #14684a; border: 1px solid #bce8d4; }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--pls-blue-night);
    color: #fff;
    padding: 12px 22px;
    border-radius: 999px;
    box-shadow: var(--shadow-lift);
    font-size: 14px;
    z-index: 200;
    opacity: 0;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), opacity .3s;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(103, 188, 216, .35), transparent 60%),
        radial-gradient(800px 500px at -10% 110%, rgba(154, 212, 234, .3), transparent 60%),
        linear-gradient(160deg, var(--pls-blue-night) 0%, var(--pls-blue-dark) 45%, var(--pls-blue) 100%);
}

.login-box {
    background: rgba(255, 255, 255, .97);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(2, 28, 49, .5);
    padding: 40px 38px 34px;
    width: 100%;
    max-width: 380px;
    animation: loginIn .5s cubic-bezier(.34, 1.4, .64, 1) both;
}

@keyframes loginIn {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-brand img.login-logo { width: 190px; height: auto; }
.login-brand h1 { margin: 0; font-size: 20px; color: var(--pls-blue-dark); letter-spacing: 2px; text-transform: uppercase; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }

.login-box form { display: flex; flex-direction: column; gap: 14px; }

.login-box label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }

.login-box input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 15px;
    outline: 0;
    transition: border-color .15s, box-shadow .15s;
}

.login-box input:focus { border-color: var(--pls-cyan); box-shadow: 0 0 0 3px var(--pls-ice); }

.login-box button {
    background: linear-gradient(135deg, var(--pls-blue) 0%, #0a5b96 100%);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    border: 0;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    margin-top: 6px;
    transition: transform .15s, box-shadow .15s;
}

.login-box button:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

/* ---------- Drawer lateral ---------- */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 28, 49, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 150;
}

.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 420px;
    max-width: 94vw;
    background: var(--surface);
    box-shadow: -12px 0 40px rgba(2, 28, 49, .25);
    transform: translateX(105%);
    transition: transform .32s cubic-bezier(.32, .9, .35, 1);
    z-index: 160;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.drawer-head h3 { margin: 0; color: var(--pls-blue-dark); }

.drawer-form {
    padding: 18px 22px 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

.drawer-form input[type="text"], .drawer-form input[type="email"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    outline: 0;
    transition: border-color .15s, box-shadow .15s;
}

.drawer-form input:focus { border-color: var(--pls-cyan); box-shadow: 0 0 0 3px var(--pls-ice); }

.drawer-row { display: flex; gap: 10px; align-items: flex-end; }

.drawer-fieldset {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawer-fieldset legend { font-size: 12.5px; color: var(--pls-blue); font-weight: 700; padding: 0 6px; }

.cep-status { font-size: 12px; color: var(--muted); padding-bottom: 10px; min-width: 90px; }
.cep-status.ok { color: var(--success); }
.cep-status.err { color: var(--danger); }

.drawer-photo { display: flex; align-items: center; gap: 14px; }

.photo-preview {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--pls-ice);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    overflow: hidden;
    border: 2px solid var(--pls-cyan-soft);
    flex-shrink: 0;
}

.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.photo-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.drawer-actions { display: flex; gap: 10px; margin-top: 6px; }

.avatar-photo { object-fit: cover; }

/* ---------- Antispam: veredito do filtro na mensagem ---------- */
.spam-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid;
    border-radius: 10px;
    margin: 0 0 16px;
    font-size: 13px;
    animation: pageIn .25s ease both;
}

.spam-bar.is-ham     { background: #eefaf4; border-color: #bce8d4; color: #14684a; }
.spam-bar.is-spam    { background: #fdecec; border-color: #f5c6c6; color: #96281f; }
.spam-bar.is-unknown { background: var(--pls-mist); border-color: var(--pls-ice); color: var(--muted); }

.spam-badge { font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }

.spam-score {
    background: rgba(255, 255, 255, .8);
    border-radius: 999px;
    padding: 1px 9px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.spam-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.spam-rules {
    flex-basis: 100%;
    list-style: none;
    margin: 4px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(2, 28, 49, .1);
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: pageIn .2s ease both;
}

/* display:flex venceria o [hidden] do navegador — sem isso a lista nasce aberta */
.spam-rules[hidden] { display: none; }

.spam-rules li { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: var(--text); }
.spam-rule-score { min-width: 46px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.spam-rule-score.bad { color: var(--danger); }
.spam-rule-score.good { color: var(--success); }
.spam-rule-tag { margin-left: auto; font-size: 10.5px; letter-spacing: .3px; }

/* ---------- Antispam: página de listas ---------- */
.sync-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
    flex-wrap: wrap;
}

.sync-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sync-bar.ok .sync-dot  { background: var(--success); box-shadow: 0 0 8px rgba(28, 158, 110, .7); }
.sync-bar.err .sync-dot { background: var(--danger); box-shadow: 0 0 8px rgba(214, 69, 69, .7); }

.form-card select, .compose select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14.5px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: 0;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.rule-col {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 16px;
    min-width: 0;
}

.rule-title { margin: 0 0 12px; font-size: 16px; color: var(--pls-blue-dark); }

.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.rule-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--pls-mist);
    transition: background .15s, transform .15s;
    animation: rowIn .3s ease both;
}

.rule-item:hover { background: var(--pls-ice); transform: translateX(2px); }
.rule-ico { flex-shrink: 0; }
.rule-value { flex: 1; min-width: 0; word-break: break-word; font-size: 14px; }
.rule-action { display: block; font-size: 11.5px; color: var(--muted); }
.rule-empty { padding: 30px 16px; box-shadow: none; background: var(--pls-mist); }
.rule-empty .empty-ico { font-size: 32px; }
.rule-note { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 14px 0 0; }

/* ---------- Menu mobile ---------- */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: 4px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.nav-toggle:active { transform: scale(.93); }

.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 28, 49, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 130;
}

.nav-backdrop.open { opacity: 1; pointer-events: auto; }

.btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); background: transparent; }
.btn-ghost:hover { color: #fff; border-color: #fff; background: rgba(255, 255, 255, .14); }

/* Botão flutuante de escrever (só no celular) */
.fab {
    display: none;
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--pls-blue) 0%, #0a5b96 100%);
    box-shadow: 0 8px 22px rgba(2, 28, 49, .35);
    z-index: 90;
    transition: transform .18s ease;
}

.fab:active { transform: scale(.92); }

.pane-back { display: none; }

/* ---------- Util ---------- */
.muted { color: var(--muted); font-weight: 400; }

h2.page-title { color: var(--pls-blue-dark); margin: 0 0 4px; }
p.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ============================================================
   Celular e tablet — nada de tira de ícones: menu deslizante,
   lista em cartões, leitura em tela cheia, alvos de toque grandes.
   ============================================================ */
@media (max-width: 900px) {
    html, body { overflow-x: hidden; }

    .nav-toggle { display: flex; }
    .topbar { padding: 0 10px 0 6px; gap: 6px; }
    .brand { font-size: 15px; gap: 8px; }
    .brand img.brand-logo { height: 26px; }
    .brand-sep, .brand-name { display: none; }
    .topbar-right { gap: 8px; }
    .user-chip { padding: 3px; background: transparent; }
    .user-chip .user-mail { display: none; }

    .app { display: block; min-height: calc(100vh - 58px); }

    .sidebar {
        position: fixed;
        top: 58px;
        left: 0;
        bottom: 0;
        width: 268px;
        max-width: 84vw;
        padding: 16px 12px calc(20px + env(safe-area-inset-bottom, 0px));
        background: var(--surface);
        box-shadow: 12px 0 40px rgba(2, 28, 49, .22);
        transform: translateX(-105%);
        transition: transform .28s cubic-bezier(.32, .9, .35, 1);
        z-index: 140;
        overflow-y: auto;
    }

    .sidebar.open { transform: none; }

    .folders a, .side-links a { padding: 13px 14px; font-size: 15px; border-radius: 12px; }
    .side-links a { color: var(--text); }
    .btn-compose { padding: 14px 16px; font-size: 15px; }

    .content { padding: 14px 14px calc(90px + env(safe-area-inset-bottom, 0px)); }

    .fab { display: flex; }

    /* Nenhum botão abaixo do alvo confortável de toque */
    .btn { min-height: 40px; }

    /* Barra de ferramentas: título em cima, busca ocupando a largura */
    .toolbar { gap: 10px; }
    .toolbar h2 { font-size: 17px; }
    .search-box { flex-basis: 100%; max-width: none; order: 3; padding: 4px 6px 4px 14px; }
    .search-box input { font-size: 16px; padding: 6px 0; } /* 16px evita o zoom do iOS */
    .search-box button { padding: 9px 16px; min-height: 40px; }
    .topbar .btn { min-height: 40px; padding: 9px 14px; }
    .pager .btn { min-width: 40px; min-height: 40px; justify-content: center; }

    /* ---- Lista de mensagens vira cartões ---- */
    .mail-layout.split .mail-list-col, .mail-list-col { max-height: none; overflow: visible; }

    .msg-list, .msg-list tbody, .msg-list tr, .msg-list td { display: block; }
    .msg-list { background: transparent; box-shadow: none; border-radius: 0; table-layout: auto !important; }

    .msg-list tr, .mail-layout.split .msg-list tr {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) auto auto;
        grid-template-areas:
            "avatar from    att  date"
            "avatar subject subject subject";
        column-gap: 10px;
        row-gap: 4px;
        align-items: center;
        background: var(--surface);
        border: 0;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 12px 14px;
        margin-bottom: 10px;
    }

    .msg-list tr:hover { transform: none; box-shadow: var(--shadow); }
    .msg-list tr:active { transform: scale(.99); }

    .msg-list tr.unseen { box-shadow: inset 4px 0 0 var(--pls-cyan), var(--shadow); }
    .mail-layout.split .msg-list tr.active { box-shadow: inset 4px 0 0 var(--pls-blue), var(--shadow); }

    .msg-list td, .mail-layout.split .msg-list td { padding: 0; }

    .col-avatar, .mail-layout.split .col-avatar { grid-area: avatar; width: auto; padding: 0 !important; }
    .msg-list .avatar, .mail-layout.split .avatar { width: 42px; height: 42px; font-size: 14px; }

    .col-from, .mail-layout.split .col-from {
        grid-area: from;
        width: auto;
        max-width: none;
        font-size: 14px;
        font-weight: 600;
    }

    .col-subject, .mail-layout.split .col-subject { grid-area: subject; max-width: none; }
    .col-subject a { font-size: 13.5px; color: var(--muted); }
    .unseen .col-subject a { color: var(--text); }

    .col-att, .mail-layout.split .col-att { grid-area: att; width: auto; }
    .col-date, .mail-layout.split .col-date {
        grid-area: date;
        display: block;
        width: auto;
        font-size: 12px;
        padding: 0 !important;
    }

    /* Sem botõezinhos no cartão: um alvo de 44px na linha empurraria o cartão
       para ~90px de altura e comeria a largura do assunto. Excluir e marcar
       como lida ficam na mensagem aberta, com alvos grandes. */
    .col-actions, .mail-layout.split .col-actions { display: none; }
    .row-actions { opacity: 1; }
    .icon-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }

    .drag-hint { display: none; } /* arrastar não faz sentido no toque */

    /* ---- Leitura em tela cheia ---- */
    .mail-read-col {
        position: fixed;
        inset: 0;
        z-index: 145;
        max-height: none;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform .28s cubic-bezier(.32, .9, .35, 1), visibility .28s;
    }

    body.pane-open { overflow: hidden; }
    body.pane-open .mail-read-col { transform: none; visibility: visible; }

    .pane-placeholder { display: none; }
    .pane-back { display: inline-flex; }

    .msg-toolbar-pane {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
        border-radius: 0;
    }

    .msg-toolbar-pane > div { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
    .msg-toolbar .btn { white-space: nowrap; }

    /* No celular a mensagem já ocupa a tela: "tela cheia" e imprimir só atrapalham */
    .btn-fullscreen, .msg-toolbar-pane .btn-print { display: none; }

    .mail-read-col .message, .message { padding: 16px 16px 28px; }
    .msg-subject, .mail-read-col .msg-subject { font-size: 17px; line-height: 1.35; }
    .msg-meta { font-size: 13px; word-break: break-word; }
    .html-body, .mail-read-col .html-body { min-height: 60vh; }

    .spam-actions { margin-left: 0; width: 100%; }
    .spam-actions .btn { flex: 1; justify-content: center; min-height: 40px; }
    .spam-rule-tag { display: none; }

    /* ---- Formulários e drawers ---- */
    .compose, .form-card, .rule-col { padding: 16px; }
    .compose input[type="text"], .compose textarea, .compose select,
    .form-card input, .form-card textarea, .form-card select,
    .login-box input, .drawer-form input { font-size: 16px; }
    .compose-actions .btn, .form-card .btn { min-height: 44px; padding: 12px 18px; }
    .compose-actions { flex-wrap: wrap; }
    .form-card label { min-width: 100%; }

    .drawer { width: 100%; max-width: 100%; height: 100%; border-radius: 0; }
    .drawer-form { padding: 16px 16px calc(30px + env(safe-area-inset-bottom, 0px)); }
    .drawer-row { flex-wrap: wrap; }
    .drawer-actions .btn { flex: 1; justify-content: center; min-height: 44px; }

    .login-page { padding: 16px; }
    .login-box { padding: 28px 22px 26px; }
    .login-brand img.login-logo { width: 160px; }
    .login-box button { min-height: 48px; }

    .contacts-grid { grid-template-columns: 1fr; }
    .rules-grid { grid-template-columns: 1fr; }
    .toast { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateY(80px); border-radius: 12px; text-align: center; }
    .toast.show { transform: none; }
}

/* Telas bem estreitas: aperta o cartão sem apertar o texto */
@media (max-width: 359px) {
    .msg-list tr, .mail-layout.split .msg-list tr { padding: 10px; column-gap: 8px; }
    .col-date { font-size: 11px; }
    .btn-small { padding: 7px 10px; }
}

/* Paisagem no celular: topo mais baixo para sobrar altura de leitura */
@media (max-height: 480px) and (orientation: landscape) {
    .topbar { height: 48px; }
    .app { min-height: calc(100vh - 48px); }
    .sidebar { top: 48px; }
}

/* Quem prefere menos movimento não recebe animação nenhuma */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
