/* DevSolutions Mail — folha de estilos */

:root {
    --blue: #1a5fd7;
    --blue-dark: #1248a3;
    --blue-light: #e8f0fe;
    --bg: #f4f6fa;
    --white: #ffffff;
    --gray-100: #f1f3f6;
    --gray-200: #e2e6ec;
    --gray-400: #9aa3b0;
    --gray-700: #4a5568;
    --gray-900: #1d2530;
    --red: #d64545;
    --green: #1f9d55;
    --radius: 8px;
    --shadow: 0 2px 10px rgba(20, 40, 80, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--gray-900);
    background: var(--bg);
}

/* ===== Login ===== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    padding: 16px;
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
}

.login-brand { text-align: center; margin-bottom: 28px; }

.brand-logo {
    font-size: 26px;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -.5px;
}
.brand-logo span { color: var(--gray-900); font-weight: 400; }
.brand-tag { color: var(--gray-400); margin: 6px 0 0; font-size: 14px; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.field input, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    background: var(--white);
    color: var(--gray-900);
}
.field input:focus, .field textarea:focus {
    outline: 2px solid var(--blue);
    outline-offset: -1px;
    border-color: var(--blue);
}
.field small { color: var(--gray-400); font-size: 12px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.toggle-pass {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 6px;
    opacity: .6;
}
.toggle-pass:hover { opacity: 1; }

.form-error {
    background: #fdecec;
    color: var(--red);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    margin-bottom: 14px;
}

.login-hint {
    text-align: center;
    font-size: 12px;
    color: var(--gray-400);
    margin: 18px 0 0;
}

/* ===== Botões ===== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-700);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--gray-100); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}
.btn-primary:hover { background: var(--blue-dark); }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: #fdecec; }

.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--gray-700);
}
.icon-btn:hover { background: var(--gray-100); }

.btn-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Estrutura do aplicativo ===== */

.app-page { height: 100vh; overflow: hidden; }
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}
.topbar .brand-logo { font-size: 18px; white-space: nowrap; }
.menu-toggle { display: none; }

.search-wrap {
    flex: 1;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    background: var(--gray-100);
    border-radius: 20px;
    padding: 0 6px 0 14px;
    align-items: center;
}
.search-wrap input {
    flex: 1;
    border: none;
    background: none;
    padding: 9px 0;
    font-size: 14px;
}
.search-wrap input:focus { outline: none; }

.account-menu { position: relative; }
.account-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
}
.account-btn:hover { background: var(--gray-100); }
.account-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.account-email { font-size: 13px; color: var(--gray-700); }

.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 180px;
    z-index: 60;
}
.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    cursor: pointer;
    color: var(--gray-900);
}
.dropdown-item:hover { background: var(--gray-100); }
.dropdown-item.danger { color: var(--red); }

.app-body { display: flex; flex: 1; min-height: 0; }

/* ===== Barra lateral ===== */

.sidebar {
    width: 230px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 14px 10px;
    overflow-y: auto;
    flex-shrink: 0;
}

.btn-compose { width: 100%; justify-content: center; margin-bottom: 14px; }

.folder-list { list-style: none; margin: 0; padding: 0; }
.folder-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}
.folder-list li:hover { background: var(--gray-100); }
.folder-list li.active { background: var(--blue-light); color: var(--blue-dark); font-weight: 600; }
.folder-list .folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-list .unseen-badge {
    background: var(--blue);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    margin-left: 6px;
}

/* ===== Lista de mensagens ===== */

.list-pane {
    width: 380px;
    min-width: 300px;
    border-right: 1px solid var(--gray-200);
    background: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-200);
}
.list-title { font-weight: 700; font-size: 15px; }
.pagination { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-400); }
.pagination button { padding: 3px 8px; }

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

.msg-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    display: block;
}
.msg-item:hover { background: var(--gray-100); }
.msg-item.active { background: var(--blue-light); }
.msg-item .row1 {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}
.msg-item .sender { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item .date { color: var(--gray-400); flex-shrink: 0; }
.msg-item .row2 {
    font-size: 14px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-item.unread .sender,
.msg-item.unread .row2 { font-weight: 800; color: var(--gray-900); }
.msg-item .clip { margin-left: 4px; }

/* ===== Área de leitura ===== */

.read-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--white); }

.state-empty, .state-loading, .state-error {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 15px;
    padding: 30px;
    text-align: center;
}
.state-error { color: var(--red); }

.read-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.read-header { padding: 14px 18px 10px; border-bottom: 1px solid var(--gray-200); }
.read-header h2 { margin: 0 0 8px; font-size: 18px; }
.read-meta { font-size: 13px; color: var(--gray-700); line-height: 1.6; }
.read-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.back-btn { display: none; }

.attach-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 4px 12px;
    color: var(--gray-700);
    text-decoration: none;
}
.attach-chip:hover { background: var(--blue-light); }

.images-bar {
    padding: 8px 18px;
    background: #fff8e1;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.read-body-wrap { flex: 1; min-height: 0; display: flex; }
.read-frame { flex: 1; border: none; width: 100%; height: 100%; background: #fff; }
.read-text {
    flex: 1;
    margin: 0;
    padding: 18px;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
}

/* ===== Modal ===== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 45, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.compose-card { max-width: 720px; }
.prefs-card { max-width: 460px; padding-bottom: 14px; }
.prefs-card .field { padding: 0 18px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { margin: 0; font-size: 16px; }

.compose-fields { padding: 8px 18px 0; }
.field-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
}
.field-row label {
    width: 60px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-400);
    flex-shrink: 0;
}
.field-row input {
    flex: 1;
    border: none;
    padding: 9px 0;
    font-size: 14px;
}
.field-row input:focus { outline: none; }

.compose-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--gray-200);
}
.fmt-btn {
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
}
.fmt-btn:hover { background: var(--gray-100); }

.compose-body {
    min-height: 180px;
    max-height: 40vh;
    overflow-y: auto;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.55;
}
.compose-body:focus { outline: none; }
.compose-body blockquote {
    border-left: 3px solid var(--gray-200);
    margin: 8px 0;
    padding-left: 10px;
    color: var(--gray-700);
}

.compose-attachments { padding: 8px 18px; }
.attach-list { list-style: none; margin: 8px 0 0; padding: 0; }
.attach-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    background: var(--gray-100);
    border-radius: 6px;
    padding: 5px 10px;
    margin-bottom: 4px;
}
.attach-list .remove-att {
    border: none;
    background: none;
    color: var(--red);
    cursor: pointer;
    font-size: 14px;
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--gray-200);
}
.compose-status { font-size: 13px; color: var(--gray-400); }
.compose-status.ok { color: var(--green); }
.compose-status.err { color: var(--red); }

.move-menu {
    position: fixed;
    max-height: 260px;
    overflow-y: auto;
}

/* ===== Toast ===== */

.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 200;
    box-shadow: var(--shadow);
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* ===== Responsivo ===== */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }

    .list-pane { width: 100%; min-width: 0; border-right: none; }
    .read-pane {
        position: fixed;
        inset: 56px 0 0 0;
        z-index: 40;
        transform: translateX(100%);
        transition: transform .2s;
    }
    .read-pane.open { transform: translateX(0); }
    .back-btn { display: inline-flex; }

    .account-email { display: none; }
    .search-wrap { max-width: none; }
}
