:root {
    --bg-dark: #0d1117;
    --bg-card: #121824;
    --bg-header: #1a2332;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-cyan: #38bdf8;
    --accent-green: #4ade80;
    --accent-red: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0; /* Hapus padding luar biar bisa nempel tepi */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Mencegah scrollbar ganda */
}

/* Main Terminal Wrapper Responsiveness */
.terminal-wrapper {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;  /* Hapus kuncian 520px/780px */
    max-height: 100%; /* Hapus kuncian 760px */
    display: flex;
    flex-direction: column;
    border-radius: 0;  /* Bikin rata tepi layar */
    border: none;
    box-shadow: none;
}

.mail-app-container {
    background: var(--bg-card);
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Header Bar */
.app-header {
    padding: 12px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.search-box {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 24px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 12px;
    width: 100%;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #22d3ee;
    color: #0f172a;
    font-weight: bold;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Sub Header Fluid Flex */
.sub-header {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    color: var(--accent-cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#displayClientId {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    display: inline-block;
}

.sub-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.count-badge {
    font-size: 10px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Mail List Container with FAB spacing */
.mail-list-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    padding-bottom: 80px; /* Memberikan ruang aman agar item paling bawah tidak tertutup FAB */
}

.mail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
}

.mail-item:hover { background: rgba(255, 255, 255, 0.03); }
.mail-item.selected { background: rgba(56, 189, 248, 0.15); }

.item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #000;
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Detail View Container */
.mail-detail-container {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    background: var(--bg-card);
    overflow-y: auto;
}

/* Floating Buttons Group */
.fab-group {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.fab-btn {
    background: #1e293b;
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.6);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.fab-btn:active { transform: scale(0.95); }
.fab-btn.compose { background: var(--accent-cyan); color: #0d1117; }

/* Modal Responsive Fixes */
.modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(2, 4, 10, 0.88); 
    backdrop-filter: blur(6px);
    display: none; 
    justify-content: center; 
    align-items: center;
    z-index: 10000; 
    padding: 16px;
    overflow-y: auto;
}

.modal-content {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.btn-action {
    background: #238636;
    color: #ffffff;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

.btn-danger {
    background: rgba(244, 63, 94, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.form-input {
    width: 100%;
    background: #161b22;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    margin-top: 4px;
    margin-bottom: 12px;
}

.header-link-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.header-link-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
}

/* Toast Notification Styles */
.korvali-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.korvali-toast {
    background: rgba(18, 24, 36, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-cyan);
    color: var(--text-main);
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.korvali-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.korvali-toast.error {
    border-left-color: var(--accent-red);
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.15), rgba(18, 24, 36, 0.98));
}

.korvali-toast.warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(18, 24, 36, 0.98));
}

.korvali-toast.success {
    border-left-color: var(--accent-green);
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(18, 24, 36, 0.98));
}

.korvali-toast-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.korvali-toast-content {
    flex: 1;
    word-break: break-word;
}

.korvali-toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.korvali-toast-close:hover {
    color: var(--text-main);
}

/* ==========================================
   MEDIA QUERIES FOR RESPONSIVENESS
   ========================================== */

/* Tablet & HP Standard */
@media (max-width: 640px) {
    body {
        padding: 0;
    }

    .terminal-wrapper {
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        border-radius: 0;
        max-height: none;
    }
}

    .sub-header {
        padding: 8px 10px;
    }

    #displayClientId {
        max-width: 140px;
        font-size: 11px;
    }

    .fab-group {
        bottom: 12px;
        right: 12px;
        gap: 8px;
    }

    .fab-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .modal-content {
        padding: 16px;
        max-height: 90vh;
    }
}

/* HP Layar Sangat Kecil (< 380px) */
@media (max-width: 380px) {
    .sub-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .sub-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    #displayClientId {
        max-width: 100%;
    }
}

/* Landscape Mode / HP Layar Pendek */
@media (max-height: 600px) {
    .terminal-wrapper {
        height: 96vh;
        min-height: 320px;
    }

    .modal-content {
        max-height: 92vh;
    }
}
