/* ========================================
 * JMBot Mail - Modern Dark Theme
 * ======================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-hover: #1e1e2a;
    --bg-input: #1a1a25;
    --border: #2a2a3a;
    --border-focus: #818cf8;
    --text-primary: #e8e8ed;
    --text-secondary: #9898a8;
    --text-muted: #6a6a7a;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ---- Navbar ---- */
.navbar {
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(18, 18, 26, 0.9);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.logo svg {
    color: var(--accent);
}

.nav-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-input);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ---- Main ---- */
.main {
    flex: 1;
    padding: 40px 0;
}

/* ---- Hero (Home) ---- */
.hero {
    text-align: center;
    padding: 40px 0;
}

.hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    margin-bottom: 28px;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.2); }
    50% { box-shadow: 0 0 30px 10px rgba(129, 140, 248, 0.1); }
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 40px;
}

/* ---- Email Form ---- */
.email-form {
    max-width: 460px;
    margin: 0 auto 50px;
}

.form-label {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-full {
    width: 100%;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', 'Inter', monospace;
    outline: none;
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-suffix {
    padding-right: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: nowrap;
    user-select: none;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(129, 140, 248, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 0.95rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* ---- Alert ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    font-size: 0.85rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ---- Inbox Header ---- */
.inbox-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.inbox-title h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.inbox-title h2 svg {
    color: var(--accent);
}

.inbox-email {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.inbox-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
}

/* ---- Inbox Table ---- */
.table-wrapper {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.inbox-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.inbox-table thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
}

.inbox-table th {
    padding: 14px 18px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.inbox-table th .th-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inbox-table td {
    padding: 14px 18px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.inbox-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}

.inbox-table tbody tr:last-child td {
    border-bottom: none;
}

.inbox-table tbody tr:hover {
    background: var(--bg-hover);
}

.inbox-table tbody tr.unread {
    background: rgba(129, 140, 248, 0.03);
}

.inbox-table tbody tr.unread td {
    font-weight: 500;
}

.inbox-table .col-from {
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-table .col-subject a {
    color: var(--accent);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    max-width: 340px;
    transition: color var(--transition);
}

.inbox-table .col-subject a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.inbox-table .col-time {
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.inbox-table .col-status {
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-unread {
    background: rgba(129, 140, 248, 0.15);
    color: var(--accent);
}

.status-read {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.empty-icon {
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

.auto-refresh-notice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 8px 16px;
    border-radius: 20px;
}

/* ---- Email Detail ---- */
.email-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.email-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.inline-form {
    display: inline;
}

.email-detail-meta {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.email-detail-subject {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
    line-height: 1.4;
}

.email-detail-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.email-detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.email-detail-sender {
    flex: 1;
}

.email-detail-sender strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.email-detail-sender .text-muted {
    font-size: 0.8rem;
}

.email-detail-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.email-detail-body {
    padding: 24px 20px;
    min-height: 200px;
}

.email-iframe {
    width: 100%;
    border: none;
    min-height: 300px;
    border-radius: var(--radius-sm);
    background: transparent;
}

.email-text-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.email-html-content {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* ---- Email Detail (new table layout) ---- */
.detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.detail-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table tr {
    border-bottom: 1px solid var(--border);
}

.detail-table tr:last-child {
    border-bottom: none;
}

.detail-table td {
    padding: 14px 20px;
    font-size: 0.9rem;
    vertical-align: middle;
}

.detail-label {
    width: 140px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    background: var(--bg-secondary);
}

.detail-body-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.detail-body-title {
    padding: 14px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.detail-body-content {
    min-height: 200px;
}

.detail-body-content .email-iframe {
    width: 100%;
    border: none;
    min-height: 400px;
    background: #fff;
    border-radius: 0;
}

.detail-body-content .email-text-content {
    padding: 20px;
}

/* ---- Copy Button ---- */
.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-copy:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-copy.copied {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
    border-color: var(--success);
}

.btn-copy-nav {
    padding: 4px 8px;
}

.inbox-email-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.inbox-email-row .inbox-email {
    margin-top: 0;
}

/* ---- Utilities ---- */
.text-muted {
    color: var(--text-muted);
}

/* ---- Footer ---- */
.footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .input-group {
        flex-direction: column;
    }

    .btn-lg {
        justify-content: center;
    }

    .inbox-header {
        flex-direction: column;
    }

    .email-detail-info {
        flex-wrap: wrap;
    }

    .email-detail-date {
        width: 100%;
        margin-left: 52px;
    }

    .nav-info {
        display: none;
    }

    .email-detail-subject {
        font-size: 1.15rem;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .inbox-table {
        min-width: 600px;
    }

    .inbox-table th,
    .inbox-table td {
        padding: 12px 14px;
        font-size: 0.82rem;
    }
}
