/* ===== CSS Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --success-dark: #065f46;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --danger-dark: #991b1b;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ===== Header ===== */
.header {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.header-content h1 {
    font-size: 2.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.instruction {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 1.5rem;
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s ease;
    background: var(--background);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea::placeholder {
    color: #94a3b8;
}

/* ===== Buttons ===== */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    flex: 1;
    min-width: 200px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Results Section ===== */
.results-card {
    animation: slideIn 0.4s ease;
}

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

.result-badge {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    border: 2px solid;
}

.result-badge.legitimate {
    background: var(--success-light);
    border-color: var(--success-color);
}

.result-badge.phishing {
    background: var(--danger-light);
    border-color: var(--danger-color);
}

.badge-icon {
    font-size: 3rem;
    line-height: 1;
}

.badge-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.result-badge.legitimate h3 {
    color: var(--success-dark);
}

.result-badge.phishing h3 {
    color: var(--danger-dark);
}

.confidence-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.confidence-text span {
    font-weight: 700;
    font-size: 1.1rem;
}

/* ===== Probability Section ===== */
.probability-section {
    margin-bottom: 2rem;
}

.probability-section h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.probability-bar {
    margin-bottom: 1rem;
}

.probability-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.progress-bar {
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

.progress-legitimate {
    background: linear-gradient(90deg, var(--success-color), #059669);
}

.progress-phishing {
    background: linear-gradient(90deg, var(--danger-color), #dc2626);
}

/* ===== Recommendation Section ===== */
.recommendation {
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid;
}

.recommendation h4 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.recommendation.safe {
    background: var(--success-light);
    border-color: var(--success-color);
}

.recommendation.safe h4 {
    color: var(--success-dark);
}

.recommendation.warning {
    background: var(--danger-light);
    border-color: var(--danger-color);
}

.recommendation.warning h4 {
    color: var(--danger-dark);
}

.recommendation p {
    margin-bottom: 0.5rem;
}

.recommendation ul {
    margin-left: 1.5rem;
    margin-top: 0.75rem;
}

.recommendation li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* ===== Error Section ===== */
.error-card {
    background: var(--danger-light);
    border: 2px solid var(--danger-color);
    animation: slideIn 0.4s ease;
}

.error-card h3 {
    color: var(--danger-dark);
    margin-bottom: 0.5rem;
}

.error-card p {
    color: var(--text-primary);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: white;
    margin-top: 2rem;
}

.footer p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.footer-note {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header-content h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .result-badge {
        flex-direction: column;
        text-align: center;
    }

    .badge-icon {
        font-size: 2.5rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .btn-primary {
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    textarea {
        font-size: 0.875rem;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== Floating Mailbox Button ===== */
.mailbox-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mailbox-float-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.mailbox-float-btn:active {
    transform: scale(0.95);
}

/* ===== Mailbox Popup ===== */
.mailbox-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mailbox-popup.open {
    display: flex;
    flex-direction: column;
}

.mailbox-popup.open .mailbox-header,
.mailbox-popup.open .mailbox-content {
    background: var(--card-bg);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.mailbox-popup.open .mailbox-header {
    border-radius: 12px 12px 0 0;
}

.mailbox-popup.open .mailbox-content {
    border-radius: 0 0 12px 12px;
    max-height: calc(90vh - 100px);
}

/* Mailbox Header */
.mailbox-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    display: none;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
}

.mailbox-popup.open .mailbox-header {
    display: flex;
}

.mailbox-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mailbox-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-discard {
    padding: 0.5rem 1rem;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-discard:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-close {
    padding: 0.5rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-close:hover {
    background: #475569;
    transform: translateY(-1px);
}

/* Mailbox Content */
.mailbox-content {
    overflow-y: auto;
    padding: 1rem;
    display: none;
    box-shadow: var(--shadow-lg);
}

.mailbox-popup.open .mailbox-content {
    display: block;
}

/* Email Item */
.email-item {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.email-item:hover {
    border-color: var(--primary-color);
}

.email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    background: white;
}

.email-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

.email-title i {
    color: var(--primary-color);
}

.email-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    transition: all 0.2s ease;
}

.email-toggle:hover {
    color: var(--primary-color);
}

/* Email Status */
.email-status {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

.status-not-checked {
    color: var(--text-secondary);
}

.status-ok {
    color: var(--success-color);
}

.status-phishing {
    color: var(--danger-color);
}

/* Email Body (Accordion) */
.email-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.email-body.open {
    max-height: 1000px;
}

.email-details {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.email-detail-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.email-detail-row strong {
    color: var(--text-secondary);
    min-width: 120px;
}

.email-detail-row span {
    color: var(--text-primary);
    word-break: break-word;
}

.email-message {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Email Actions */
.email-actions {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
}

.btn-check {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-check:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ===== Responsive Mailbox ===== */
@media (max-width: 768px) {
    .mailbox-float-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .mailbox-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mailbox-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .email-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .email-title {
        font-size: 0.9rem;
    }

    .email-detail-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .email-detail-row strong {
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .mailbox-popup {
        padding: 10px;
    }

    .mailbox-header h3 {
        font-size: 1rem;
    }

    .btn-discard {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
}
