* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #333;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
#login-screen.active {
    min-height: 100vh;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #667eea;
}

.login-container p {
    color: #666;
    margin-bottom: 30px;
}

#login-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

#login-form input:focus {
    outline: none;
    border-color: #667eea;
}

#login-form button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
}

#login-form button:hover {
    background: #5568d3;
}

.error {
    color: #e74c3c;
    margin-top: 15px;
    font-size: 14px;
}

.hint {
    margin-top: 20px;
    font-size: 12px;
    color: #999;
}

/* Header */
header {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 24px;
    color: #667eea;
    margin-bottom: 5px;
}

#user-info {
    color: #666;
    font-size: 14px;
}

.header-right {
    display: flex;
    gap: 10px;
}

/* Container */
.container {
    display: flex;
    height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: white;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
}

.nav-btn {
    width: 100%;
    padding: 12px 15px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #f5f7fa;
}

.nav-btn.active {
    background: #667eea;
    color: white;
}

.count {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.nav-btn.active .count {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* Spam Stats */
.spam-stats {
    margin-top: 30px;
    padding: 15px;
    background: #f5f7fa;
    border-radius: 8px;
}

.spam-stats h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #667eea;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.hidden {
    display: none !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px;
    color: #666;
}

.empty-state p {
    font-size: 20px;
    margin-bottom: 20px;
}

/* Email List */
.email-item {
    background: white;
    padding: 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.email-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateX(5px);
}

.email-item.spam {
    border-left-color: #e74c3c;
    background: #fff5f5;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.email-from {
    font-weight: 600;
    color: #333;
}

.email-date {
    color: #999;
    font-size: 12px;
}

.email-subject {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 5px;
}

.email-preview {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spam-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
}

/* Email Detail */
.email-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.email-actions {
    display: flex;
    gap: 10px;
}

.email-detail-body {
    background: white;
    padding: 30px;
    border-radius: 8px;
}

.email-header {
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

#detail-subject {
    font-size: 24px;
    color: #333;
    margin-bottom: 15px;
}

.email-meta {
    color: #666;
    font-size: 14px;
}

.email-meta > div {
    margin-bottom: 8px;
}

.email-body {
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .email-actions {
        flex-direction: column;
    }
}

/* Spam Score Badges */
.spam-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

/* High spam score (marked as spam) */
.spam-badge.spam-high {
    background: #dc3545;
}

/* Medium spam score (suspicious but not marked) */
.spam-badge.spam-medium {
    background: #ffc107;
    color: #000;
}

/* Low spam score (safe) */
.spam-badge.spam-low {
    background: #28a745;
}

/* Pagination */
#pagination {
    padding: 20px;
    text-align: center;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.pagination-controls button {
    padding: 8px 16px;
    min-width: 100px;
}

.page-info {
    font-weight: 500;
    color: #666;
}

/* Auto-fetch notification */
.auto-fetch-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    font-size: 14px;
}

.auto-fetch-notification.fade-out {
    animation: fadeOut 0.3s ease-out;
    opacity: 0;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
