/* ===== MOBILE RESPONSIVE - Outlook Reader ===== */
/* Chỉ áp dụng cho màn hình <= 768px, KHÔNG ảnh hưởng desktop */

@media screen and (max-width: 768px) {

    /* === Layout === */
    body {
        padding: 0 !important;
    }

    .top-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        justify-content: center;
    }

    .top-title {
        font-size: 1.1rem;
        width: 100%;
        text-align: center;
    }

    .app-container {
        margin: 10px 6px;
        padding: 10px;
        border-radius: 10px;
    }

    /* === Textarea === */
    .token-textarea {
        font-size: 0.7rem;
        min-height: 100px;
        padding: 10px;
    }

    .input-label {
        font-size: 0.85rem;
    }

    /* === Button === */
    .btn-action {
        width: 100%;
        padding: 14px;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* === Loading === */
    .loading-inline {
        flex-direction: column;
        gap: 6px;
    }

    .loading-inline span {
        font-size: 0.85rem;
    }

    /* === Placeholder === */
    .placeholder-loading {
        font-size: 0.72rem;
        padding: 10px 12px;
        word-break: break-all;
    }

    /* === Email Group === */
    .email-group {
        margin-bottom: 12px;
    }

    .email-group-header {
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
        border-radius: 10px 10px 0 0;
    }

    .email-group-account-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .email-group-account {
        font-size: 0.75rem;
        word-break: break-all;
    }

    .email-group-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .btn-small {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .badge-count {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    /* === TABLE: chuyển sang card view cho mobile === */
    .mail-table {
        display: block !important;
        table-layout: auto !important;
        border: none !important;
        background: none !important;
    }

    .mail-table thead {
        display: none !important;
        /* Ẩn header trên mobile */
    }

    .mail-table tbody {
        display: block !important;
    }

    .mail-table tbody tr {
        display: block !important;
        background: #0d1b30;
        border: 1px solid #1e4a6f;
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 10px 12px;
    }

    /* GIỮ hidden rows ẩn trên mobile */
    .mail-table tbody tr.row-hidden {
        display: none !important;
    }

    .mail-table tbody tr:nth-child(even) {
        background: #0f2238;
    }

    .mail-table td {
        display: block !important;
        text-align: left !important;
        padding: 3px 0 !important;
        border: none !important;
        width: 100% !important;
        font-size: 0.78rem !important;
    }

    /* Label trước mỗi td */
    .mail-table td::before {
        font-weight: 700;
        color: #6b8299;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-right: 6px;
    }

    .td-mail {
        font-size: 0.8rem !important;
        color: #00d4ff !important;
        font-weight: 600;
        padding-bottom: 4px !important;
        border-bottom: 1px solid #1e4a6f !important;
        margin-bottom: 4px;
        word-break: break-all;
    }

    .td-stt {
        display: none !important;
        /* Ẩn STT trên mobile */
    }

    .td-from::before {
        content: "From: ";
    }

    .td-from {
        color: #e0e4e8 !important;
        word-break: break-all;
    }

    .td-time::before {
        content: "Time: ";
    }

    .td-time {
        color: #c0c8d0 !important;
        font-size: 0.72rem !important;
    }

    .td-content {
        color: #e8ecf0 !important;
        padding-top: 4px !important;
        border-top: 1px solid #152a45 !important;
        margin-top: 4px;
        line-height: 1.5 !important;
    }

    .td-content .xem-them {
        display: block;
        float: none;
        margin-top: 6px;
        text-align: right;
        font-size: 0.72rem;
    }

    .td-content .highlight-code {
        font-size: 1rem;
    }

    /* === Expand Button === */
    .expand-btn-row {
        padding: 8px 0;
        background: none;
    }

    .btn-expand {
        font-size: 0.78rem;
        padding: 8px 20px;
        width: 100%;
        border-radius: 8px;
    }

    /* === Modal === */
    .modal-content {
        width: 95%;
        margin: 15px auto;
        padding: 0;
        border-radius: 10px;
    }

    .modal-header {
        padding: 12px 15px;
    }

    .modal-header h3 {
        font-size: 0.85rem;
    }

    .modal-close {
        font-size: 1.3rem;
    }

    #modalIframe {
        min-height: 300px;
    }

    /* === Theme Switch === */
    .theme-switch-wrapper {
        transform: scale(0.9);
    }

    /* === Toast === */
    .toast {
        font-size: 0.78rem;
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        text-align: center;
        max-width: none;
    }
}

/* === LIGHT THEME MOBILE === */
@media screen and (max-width: 768px) {
    [data-theme="light"] .mail-table tbody tr {
        background: #fff;
        border-color: #ddd;
    }

    [data-theme="light"] .mail-table tbody tr:nth-child(even) {
        background: #f8f9fa;
    }

    [data-theme="light"] .td-mail {
        color: #2980b9 !important;
        border-bottom-color: #e0e0e0 !important;
    }

    [data-theme="light"] .td-content {
        color: #2c3e50 !important;
        border-top-color: #e0e0e0 !important;
    }

    [data-theme="light"] .mail-table td::before {
        color: #7f8c8d;
    }

    [data-theme="light"] .placeholder-loading {
        background: rgba(52, 152, 219, 0.05);
        border-color: #bdc3c7;
        color: #7f8c8d;
    }
}

/* Very small phones */
@media screen and (max-width: 400px) {
    .top-title {
        font-size: 0.95rem;
    }

    .email-group-account {
        font-size: 0.68rem;
    }

    .btn-action {
        font-size: 0.9rem;
        padding: 12px;
    }

    .mail-table td {
        font-size: 0.72rem !important;
    }
}