:root {
    --bg-color: #f4f4f9;
    --text-color: #333;
    --card-bg: #fff;
    --primary: #007bff;
    --primary-hover: #0056b3;
    --border: #ddd;
}

* {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: 100vh;
    overflow: hidden;
}

.container {
    background: var(--card-bg);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 600px;
    margin-top: 2vh;
    display: flex;
    flex-direction: column;
    max-height: 96vh;
}

h1 {
    text-align: center;
    margin: 0 0 15px 0;
    font-size: 1.4rem;
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

input:focus { border-color: var(--primary); }

button {
    padding: 8px 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

button:hover { background-color: var(--primary-hover); }
button:disabled { background-color: #ccc; cursor: not-allowed; }

.hidden { display: none !important; }

#loading {
    text-align: center;
    color: #666;
    margin-bottom: 10px;
    font-size: 13px;
}

#inbox-list {
    flex: 1;
    overflow-y: auto; 
    padding-right: 5px; 
}

#inbox-list::-webkit-scrollbar { width: 5px; }
#inbox-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
#inbox-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
#inbox-list::-webkit-scrollbar-thumb:hover { background: #999; }

details {
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 8px;
    background: #fafafa;
    overflow: hidden;
}

summary {
    padding: 10px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent;
    font-size: 14px;
}

summary::-webkit-details-marker { display: none; }
details[open] summary { border-bottom: 1px solid var(--border); }

.summary-left {
    flex: 1;
    min-width: 0;
    padding-right: 10px;
}

.summary-left > div:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-meta { font-size: 0.85em; color: #666; font-weight: normal; margin-top: 2px; white-space: nowrap; }
.summary-right { flex-shrink: 0; text-align: right; }

.email-body {
    padding: 12px;
    background: #fff;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.4;
    max-height: 45vh;
    overflow-y: auto;
}

.email-body::-webkit-scrollbar { width: 5px; }
.email-body::-webkit-scrollbar-track { background: transparent; }
.email-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

mark.otp {
    background-color: #ffeeba;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 1.05em;
    color: #856404;
}

a.parsed-link { color: var(--primary); text-decoration: none; font-weight: 500; word-break: break-all; }
a.parsed-link:hover { text-decoration: underline; }

/* ====================================================
   TOAST & CONFIRM DIALOG STYLES
   ==================================================== */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    min-width: 250px;
    max-width: 350px;
    padding: 12px 16px;
    background: #333;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    opacity: 0;
    transform: translateY(20px);
    animation: toastSlideIn 0.3s forwards;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.error { background: #dc3545; }
.toast.success { background: #28a745; }
.toast.info { background: #17a2b8; }

.toast.fade-out { animation: toastFadeOut 0.3s forwards; }

@keyframes toastSlideIn { to { opacity: 1; transform: translateY(0); } }
@keyframes toastFadeOut { to { opacity: 0; transform: translateY(20px); } }

#confirm-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; justify-content: center; align-items: center;
    z-index: 10000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

.confirm-box {
    background: #fff;
    padding: 20px 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 350px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(0.95);
    animation: scaleUp 0.2s forwards;
}

.confirm-box h3 { margin: 0 0 10px 0; color: #333; font-size: 1.2rem; }
.confirm-box p { margin: 0 0 20px 0; color: #555; font-size: 14px; line-height: 1.5; }

.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-cancel { background: #f8f9fa; color: #333; border: 1px solid #ddd; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
.btn-cancel:hover { background: #e2e6ea; }
.btn-ok { background: var(--primary); padding: 8px 16px; border-radius: 4px; color: white; border: none; cursor: pointer; }
.btn-ok:hover { background: var(--primary-hover); }

@keyframes fadeIn { to { opacity: 1; } }
@keyframes scaleUp { to { transform: scale(1); } }

/* ====================================================
   DOMAIN HINT BADGE
   ==================================================== */
.domain-hint {
    font-size: 12px;
    color: #2e7d32;
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-radius: 4px;
    padding: 5px 10px;
    margin-bottom: 10px;
}

.domain-hint code {
    background: #dcedc8;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    font-family: monospace;
}

/* ====================================================
   STATUS BAR AUTO-REFRESH
   ==================================================== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
    font-size: 13px;
    padding: 7px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2e7d32;
    flex-shrink: 0;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

.btn-stop {
    margin-left: auto;
    padding: 3px 10px;
    font-size: 12px;
    background: #fff;
    color: #c62828;
    border: 1px solid #e57373;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-stop:hover { background: #ffebee; }

/* Responsive Mobile Rules */
@media (max-width: 480px) {
    body { padding: 0; }
    .container {
        padding: 12px 15px; margin-top: 0;
        height: 100vh; max-height: 100vh; border-radius: 0;
    }
    .input-group { flex-direction: column; }
    button { width: 100%; }
    summary { flex-direction: column; align-items: flex-start; }
    .summary-left { width: 100%; padding-right: 0; }
    .summary-right { margin-top: 4px; text-align: left; }
    
    #toast-container {
        left: 20px; /* Lebarkan ke kiri di HP */
        bottom: 20px;
    }
    .toast { min-width: unset; width: 100%; }
}
