/* Quarantine Management GUI - Stylesheet */

:root {
    --color-bg: #f5f6fa;
    --color-white: #ffffff;
    --color-text: #2c3e50;
    --color-text-light: #7f8c8d;
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-success: #27ae60;
    --color-danger: #e74c3c;
    --color-warning: #f39c12;
    --color-border: #dcdde1;
    --color-sa: #e67e22;
    --color-ai: #9b59b6;
    --radius: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 14px;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

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

.login-container h1 {
    text-align: center;
    margin-bottom: 4px;
    font-size: 24px;
}

.login-subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 24px;
    font-size: 13px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
}

.header h1 {
    font-size: 22px;
    display: inline;
    margin-right: 12px;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    color: var(--color-text-light);
    font-size: 13px;
}

.message-count {
    color: var(--color-text-light);
    font-size: 13px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
}

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

.btn-success:hover {
    background: #219a52;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-outline {
    background: white;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background: var(--color-bg);
}

/* Alerts */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: #fdecea;
    color: var(--color-danger);
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-sa {
    background: #fef0e5;
    color: var(--color-sa);
    border: 1px solid var(--color-sa);
}

.badge-ai {
    background: #f3edf7;
    color: var(--color-ai);
    border: 1px solid var(--color-ai);
}

.badge-unknown {
    background: #eee;
    color: #999;
    border: 1px solid #ccc;
}

.badge-admin {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #2e7d32;
}

/* Admin user column */
.col-user {
    width: 180px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--color-text-light);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* Message list table */
.message-list {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow-x: auto;
}

.message-list table {
    width: 100%;
    border-collapse: collapse;
}

.message-list thead {
    background: var(--color-bg);
}

.message-list th {
    padding: 8px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.message-list td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.message-list tr:hover {
    background: #f8f9fc;
}

.col-check {
    width: 36px;
    text-align: center;
}

.col-type {
    width: 110px;
}

.col-from {
    width: 200px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-subject a {
    color: var(--color-text);
    text-decoration: none;
}

.col-subject a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.col-score {
    width: 60px;
    text-align: center;
}

.col-date {
    width: 130px;
    white-space: nowrap;
    color: var(--color-text-light);
}

.score {
    font-weight: 700;
    color: var(--color-danger);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
}

.page-info {
    color: var(--color-text-light);
    font-size: 13px;
}

/* Message detail */
.message-detail {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.message-meta {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.meta-row {
    display: flex;
    padding: 4px 0;
    font-size: 13px;
}

.meta-label {
    width: 140px;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--color-text-light);
}

.meta-value {
    flex: 1;
    word-break: break-all;
}

.quarantine-reason {
    margin-left: 8px;
    color: var(--color-text-light);
    font-size: 12px;
}

/* SA Report */
.sa-report {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.sa-report h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--color-text-light);
}

.sa-rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.sa-rules-table th {
    text-align: left;
    padding: 6px 8px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-light);
}

.sa-rules-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #f0f0f0;
}

.sa-col-score {
    width: 60px;
    text-align: right;
    font-weight: 700;
    font-family: monospace;
}

.sa-col-rule {
    width: 220px;
}

.sa-col-rule code {
    font-size: 11px;
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
}

.sa-rule-bad .sa-col-score {
    color: var(--color-danger);
}

.sa-rule-good .sa-col-score {
    color: var(--color-success);
}

.raw-headers {
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
}

.raw-headers summary {
    padding: 10px 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
}

.headers-pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 11px;
    overflow-x: auto;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

.message-body {
    padding: 16px;
}

.message-body h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--color-text-light);
}

.body-pre {
    background: #f8f9fa;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
    line-height: 1.6;
}

/* SA reason tags */
.sa-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin: 1px 2px;
    white-space: nowrap;
    line-height: 1.5;
}

.tag-url { background: #fff0f0; color: #c0392b; border: 1px solid #e8a0a0; }
.tag-sender { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.tag-html { background: #f3e5f5; color: #7b1fa2; border: 1px solid #ce93d8; }
.tag-bl { background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }
.tag-bayes { background: #e8eaf6; color: #283593; border: 1px solid #9fa8da; }
.tag-dkim { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }

/* Reason column */
.col-reason {
    width: 70px;
    text-align: center;
    position: relative;
}

.reason-none {
    color: #ccc;
}

.reason-trigger {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-primary);
    cursor: pointer;
    position: relative;
    border: 1px solid var(--color-border);
    background: #f8f9fc;
}

.reason-trigger:hover {
    background: #eef1f7;
}

.reason-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px 10px;
    z-index: 100;
    white-space: nowrap;
}

.reason-popup.show {
    display: block;
}

/* Whitelist button */
.btn-whitelist {
    background: #2980b9;
    color: white;
    border-color: #2471a3;
}

.btn-whitelist:hover {
    background: #2471a3;
}

/* Not-spam report button */
.btn-report {
    background: var(--color-warning);
    color: white;
    border-color: #e08e0b;
}

.btn-report:hover {
    background: #e08e0b;
}

/* Whitelist management page */
.whitelist-section {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.whitelist-add {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.whitelist-add h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--color-text-light);
}

.whitelist-form {
    max-width: 500px;
}

.whitelist-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.whitelist-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: monospace;
}

.whitelist-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.whitelist-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--color-text-light);
}

.whitelist-list {
    padding: 16px;
}

.whitelist-list h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--color-text-light);
}

.whitelist-empty {
    color: var(--color-text-light);
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

.whitelist-table {
    width: 100%;
    border-collapse: collapse;
}

.whitelist-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-light);
}

.whitelist-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.whitelist-table tr:hover {
    background: #f8f9fc;
}

.whitelist-table code {
    font-size: 13px;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
}

.whitelist-col-action {
    width: 80px;
    text-align: center;
}

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

    .toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .col-from {
        width: 120px;
        max-width: 120px;
    }

    .meta-row {
        flex-direction: column;
    }

    .meta-label {
        width: auto;
        margin-bottom: 2px;
    }
}
