/* style.css */

/* CSS gốc từ bạn */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background: #1a202c;
    font-family: 'Inter', sans-serif;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Điều chỉnh container */
.container {
    background-color: #2d3748;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    flex: 1 0 auto; /* Cho phép container mở rộng nhưng không co lại nhỏ hơn nội dung */
    position: relative;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 20px;
}

.email-input-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    margin: 0 auto 16px;
    position: relative;
}

.email-input-group > input,
.email-input-group > select,
.email-input-group > #readMailBtn {
    flex-shrink: 0;
}

.email-input-group > .action-btn {
    flex-shrink: 0;
}

#emailPrefix {
    background-color: #4b5563;
    border: 1px solid #6b7280;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 8px 12px;
    color: #e2e8f0;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 150px;
    margin-right: 0;
}

#emailPrefix:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
    outline: none;
}

#emailDomain {
    background-color: #4b5563;
    border: 1px solid #6b7280;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 8px 30px 8px 12px;
    color: #e2e8f0;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 120px;
    margin-left: 0;
}

.action-btn, #readMailBtn {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.9rem;
    padding: 8px 12px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
    margin-left: 0;
    color: #ffffff;
}

#readMailBtn {
    background-color: #3b82f6;
}

#readMailBtn:hover {
    background-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

#generateMailBtn {
    background-color: #10b981;
}

#generateMailBtn:hover {
    background-color: #059669;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

#copyMailBtn {
    background-color: #f59e0b;
}

#copyMailBtn:hover {
    background-color: #d97706;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

#deleteAllMailBtn {
    background-color: #ef4444;
}

#deleteAllMailBtn:hover {
    background-color: #dc2626;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.svg_spin_45rt.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.email-table {
    border-collapse: collapse;
    background-color: transparent;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    width: 100%;
}

.email-table th, .email-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #4b5563;
}

.email-table th {
    background-color: #1e40af;
    color: #ffffff;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.email-table td {
    color: #1f2937;
}

.email-table tr.unseen {
    font-weight: bold !important;
    background-color: #f6f7f9 !important;
}

.email-table tr.unseen td {
    font-weight: bold !important;
    background-color: #f6f7f9 !important;
}

.email-table tr:not(.unseen) {
    background-color: #f6f7f9 !important;
}

.email-table tr:not(.unseen) td {
    background-color: #f6f7f9 !important;
    color: #1f2937 !important;
}

.email-table .column-subject {
    width: 45%;
}

.email-table .column-from {
    width: 20%;
}

.email-table .column-to {
    width: 20%;
}

.email-table .column-date {
    width: auto;
    min-width: 150px;
    text-align: center;
}

.email-table .column-code {
    width: 90px;
    min-width: 90px;
    text-align: center;
}

.email-table .column-action {
    width: 200px;
    min-width: 170px;
    text-align: center;
    padding: 12px 8px;
}

.email-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.email-table .view-btn,
.email-table .delete-btn {
    padding: 6px 8px;
    font-size: 0.85rem;
    margin: 0 2px;
}

.email-table .view-btn svg,
.email-table .delete-btn svg {
    width: 16px;
    height: 16px;
}

.email-table tr:last-child td {
    border-bottom: none;
}

.email-table tr:hover {
    color: #2563eb !important;
    transition: all 0.3s ease;
}

.email-table tr:hover td {
    color: #2563eb !important;
}

.email-table .view-btn {
    background-color: #10b981;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.email-table .view-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.email-table .view-btn:hover::before {
    width: 200%;
    height: 200%;
}

.email-table .view-btn:hover {
    background-color: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.email-table .delete-btn {
    background-color: #ef4444;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    color: #ffffff;
    display: inline-flex;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.email-table .delete-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%); /* Sửa lỗi -950% thành -50% */
    transition: width 0.6s ease, height 0.6s ease;
}

.email-table .delete-btn:hover::before {
    width: 200%;
    height: 200%;
}

.email-table .delete-btn:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    transform: translateY(-2px);
}

.inbox-empty-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background-color: #f6f7f9;
    border-radius: 8px;
    text-align: center;
    color: #6b7280;
}

.inbox-empty-msg svg {
    margin-bottom: 16px;
    position: relative;
}

.emptyInboxTitle {
    font-size: 1.25rem;
    font-weight: 500;
    color: #4b5563;
    margin-bottom: 8px;
}

.inbox-empty-msg p {
    font-size: 1rem;
    color: #6b7280;
}

#popup {
    backdrop-filter: blur(5px);
     z-index: 9999;
}

#popup > div {
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    color: #ffffff;
    background-color: #ef4444;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.close-btn:hover {
    background-color: #dc2626;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

#popup-html-content {
    font-size: 1rem;
    line-height: 1.6;
    color: #1f2937;
}

#popup-html-content h1, #popup-html-content h2, #popup-html-content h3 {
    color: #1e40af;
    margin-bottom: 12px;
}

#popup-html-content p {
    margin-bottom: 16px;
}

#popup-html-content a {
    color: #3b82f6;
    text-decoration: underline;
    transition: color 0.3s ease;
}

#popup-html-content a:hover {
    color: #2563eb;
}

#toast, #codeToast {
    position: fixed; /* Sửa từ absolute để đảm bảo vị trí cố định */
    top: 20%;
    right: 50%;
    transform: translateX(50%);
    background-color: #10b981;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #059669;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 1000;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    0% {
        transform: translateX(50%) translateY(10px);
        opacity: 0;
    }
    100% {
        transform: translateX(50%) translateY(0);
        opacity: 1;
    }
}

.emptyInboxRotation {
    animation: rotateAroundEnvelope 5s linear infinite;
    transform-origin: 46px 42.605px;
}

@keyframes rotateAroundEnvelope {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mx-guide {
    border: 1px solid #4b5563;
    transition: all 0.3s ease;
    border-color: #60a5fa;
}

.mx-guide:hover {
    border-color: #15e19d;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.2);
}

.mx-title {
    color: #60a5fa;
    border-bottom: 2px solid #60a5fa;
    padding-bottom: 4px;
    transition: all 0.3s ease;
}

.mx-description {
    color: #e2e8f0;
    line-height: 1.6;
}

.mx-highlight {
    color: #10b981;
    padding: 2px 6px;
    background-color: rgba(16, 185, 129, 0.1);
    border-radius: 4px;
    font-weight: 600;
}

.mx-steps {
    color: #d1d5db;
}

.mx-step-item {
    padding: 8px 12px;
    background-color: #374151;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mx-step-item:hover {
    background-color: #4b5563;
    transform: translateX(4px);
}

.mx-substeps {
    color: #d1d5db;
}

.mx-substep-item {
    padding: 4px 8px;
    border-radius: 4px;
    margin: 4px 0;
    transition: all 0.3s ease;
}

.mx-note {
    font-style: italic;
    background-color: rgba(107, 114, 128, 0.1);
    padding: 8px;
    border-left: 4px solid #60a5fa;
    border-radius: 4px;
}

.mx-value {
    color: #f59e0b;
    font-weight: 700;
    background-color: rgba(245, 158, 11, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    transition: all 0.3s ease;
}

.mx-value:hover {
    background-color: rgba(245, 158, 11, 0.3);
    transform: scale(1.1);
}

/* CSS cho Popup Quảng Cáo */
.khungquangcao {
    position: fixed;
    width: 260px;
    z-index: 1000;
    display: block;
    opacity: 0;
}

.khungquangcao-trai {
    left: calc(50% - 650px - 260px - 130px);
    top: 50%;
    transform: translateY(-50%);
    animation: fadeInLeft 0.5s ease forwards;
}

.khungquangcao-phai {
    right: calc(50% - 650px - 260px - 130px);
    top: 50%;
    transform: translateY(-50%);
    animation: fadeInRight 0.5s ease forwards;
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px) translateY(-50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(-50%) scale(1);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px) translateY(-50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(-50%) scale(1);
    }
}

.khungquangcao.an {
    display: none;
}

.noidungquangcao {
    background: linear-gradient(145deg, #1e3a8a 0%, #3b82f6 100%);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(59, 130, 246, 0.3);
    position: relative;
    border: 2px solid #93c5fd;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.noidungquangcao:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.5);
}

.nutdongquangcao {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 26px;
    font-weight: 700;
    cursor: pointer;
    color: #ffffff;
    background: linear-gradient(145deg, #f87171 0%, #ef4444 100%);
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    border-radius: 50%;
    border: 2px solid #fecaca;
    transition: all 0.3s ease;
}

.nutdongquangcao:hover {
    background: linear-gradient(145deg, #ef4444 0%, #dc2626 100%);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
    border-color: #f87171;
}

.tieudequangcao {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
    border-bottom: 3px solid #93c5fd;
    padding-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.motaquangcao {
    font-size: 1rem;
    color: #e0f2fe;
    margin-bottom: 20px;
    line-height: 1.5;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.nutquangcao {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(145deg, #34d399 0%, #10b981 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 10px;
    text-decoration: none;
    border: 2px solid #6ee7b7;
    transition: all 0.3s ease;
}

.nutquangcao:hover {
    background: linear-gradient(145deg, #10b981 0%, #059669 100%);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
    transform: translateY(-3px);
    border-color: #34d399;
}

/* System stats */
.system-stats {
    background-color: #4b5563;
    font-size: 0.9rem;
    padding: 8px;
}

/* Media query cho mobile */
@media (max-width: 768px) {
    .container {
        padding: 16px;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
    }

    h1 {
        font-size: 1.5rem;
    }
    
    #emailTitle {
        display: none;
    }

    /* Email input group */
    .email-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
        max-width: 100%;
        padding: 0; /* Loại bỏ padding thừa */
    }

    .email-input-wrapper {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        max-width: 100%;
        padding: 0; /* Loại bỏ padding thừa */
    }

    #emailPrefix {
        border: 1px solid #6b7280;
        border-radius: 8px;
        margin: 0; /* Loại bỏ margin thừa */
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    #emailDomain {
        border: 1px solid #6b7280;
        border-radius: 8px;
        margin: 0; /* Loại bỏ margin thừa */
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Button group */
    .button-group {
        display: grid;
        grid-template-columns: 30% 70%; /* Tỷ lệ 30% và 70% */
        gap: 12px;
        width: 100%;
        max-width: 100%; /* Đồng bộ với email-input-wrapper */
        align-items: center;
        padding: 0; /* Loại bỏ padding thừa */
        margin: 0; /* Loại bỏ margin thừa */
    }

    .action-btn, #readMailBtn {
        font-size: 0.85rem;
        padding: 8px;
        justify-content: center;
        width: 100%;
        max-width: 95%; /* Đảm bảo không vượt quá container */
        box-sizing: border-box;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #readMailBtn {
        font-size: 0.8rem;
        padding: 8px 6px;
    }

    #generateMailBtn {
        font-size: 0.9rem;
        padding: 8px 10px;
    }

    #copyMailBtn {
        font-size: 0.8rem;
        padding: 8px 6px;
    }

    #deleteAllMailBtn {
        font-size: 0.9rem;
        padding: 8px 10px;
    }

    /* Bảng email */
    .email-table th, .email-table td {
        padding: 8px;
        font-size: 0.85rem;
    }

    .email-table .column-from,
    .email-table .column-date,
    .email-table .column-action {
        display: none;
    }

    .email-table .column-subject {
        width: 70%;
    }

    .email-table .column-code {
        width: 30%;
        text-align: center;
    }

    .email-table td {
        max-width: 100px;
    }

    /* Popup quảng cáo */
    .khungquangcao {
        width: 90%;
        max-width: 300px;
        left: 50%;
        transform: translateX(-50%);
    }

    .khungquangcao-trai {
        top: 20%;
        animation: fadeInTop 0.5s ease forwards;
    }

    .khungquangcao-phai {
        top: 60%;
        animation: fadeInBottom 0.5s ease forwards;
    }

    @keyframes fadeInTop {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-20px) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }

    @keyframes fadeInBottom {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(20px) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }

    /* System stats */
    .system-stats {
        font-size: 0.8rem;
        padding: 6px;
    }

    /* Popup email */
    #popup > div {
        max-width: 75%;
        max-height: 85vh;
        border-radius: 12px;
        z-index: 9999;
    }

    #popup-html-content {
        font-size: 0.7rem;
    }

    .close-btn {
        width: 32px;
        height: 32px;
        line-height: 32px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }

    /* Toast */
    #toast, #codeToast {
        top: 20%;
        right: 50%;
        transform: translateX(50%);
    }
}

/* Desktop giữ nguyên */
@media (min-width: 769px) {
    .email-input-wrapper {
        display: flex;
        flex-direction: row;
        flex: 1;
        gap: 0;
        width: 100%;
    }

    .button-group {
        display: flex;
        gap: 8px;
        width: auto;
    }

    /* Đảm bảo quảng cáo hiển thị đúng trên desktop */
    .khungquangcao-trai {
        left: calc(50% - 650px - 260px - 130px);
        top: 50%;
        transform: translateY(-50%);
    }

    .khungquangcao-phai {
        right: calc(50% - 650px - 260px - 130px);
        top: 50%;
        transform: translateY(-50%);
    }
}