/* ==========================================================================
   TempMail Generator — Frontend Public CSS
   Premium dark/light design with glass morphism and micro-animations
   ========================================================================== */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties (Light theme) ---------- */
:root {
    --tm-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Brand palette */
    --tm-primary: #4f46e5;
    --tm-primary-h: #4338ca;
    --tm-primary-light: #ede9fe;
    --tm-accent: #06b6d4;
    --tm-success: #10b981;
    --tm-danger: #ef4444;
    --tm-danger-h: #dc2626;
    --tm-warning: #f59e0b;

    /* Surfaces */
    --tm-bg: #f8faff;
    --tm-card: #ffffff;
    --tm-border: #e5e7eb;
    --tm-border-focus: #a5b4fc;

    /* Text */
    --tm-text: #111827;
    --tm-text-2: #4b5563;
    --tm-text-3: #9ca3af;

    /* Shadows */
    --tm-shadow-sm: 0 1px 4px rgba(0, 0, 0, .06);
    --tm-shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
    --tm-shadow-lg: 0 8px 32px rgba(0, 0, 0, .14);

    /* Misc */
    --tm-radius: 14px;
    --tm-radius-sm: 8px;
    --tm-transition: .22s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Dark theme overrides ---------- */
[data-dark="true"] {
    --tm-bg: #0f172a;
    --tm-card: #1e293b;
    --tm-border: #334155;
    --tm-border-focus: #818cf8;
    --tm-text: #f1f5f9;
    --tm-text-2: #94a3b8;
    --tm-text-3: #475569;
    --tm-primary-light: #1e1b4b;
    --tm-shadow-sm: 0 1px 4px rgba(0, 0, 0, .3);
    --tm-shadow-md: 0 4px 16px rgba(0, 0, 0, .4);
    --tm-shadow-lg: 0 8px 32px rgba(0, 0, 0, .55);
}

/* ==========================================================================
   GLOBAL WRAPPER
   ========================================================================== */
.tempmail-wrap,
.tempmail-wrap * {
    box-sizing: border-box;
    font-family: var(--tm-font);
}

.tempmail-wrap {
    background: var(--tm-bg);
    color: var(--tm-text);
    max-width: 900px;
    margin: 0 auto 40px;
    border-radius: var(--tm-radius);
    overflow: visible;
    transition: background var(--tm-transition), color var(--tm-transition);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.tm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 26px;
    background: var(--tm-card);
    border-bottom: 1px solid var(--tm-border);
    border-radius: var(--tm-radius) var(--tm-radius) 0 0;
    box-shadow: var(--tm-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.tm-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--tm-primary);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.3px;
}

.tm-logo svg {
    flex-shrink: 0;
}

.tm-icon-btn {
    background: none;
    border: 1px solid var(--tm-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tm-text-2);
    transition: background var(--tm-transition), color var(--tm-transition), border-color var(--tm-transition);
}

.tm-icon-btn:hover {
    background: var(--tm-primary-light);
    border-color: var(--tm-primary);
    color: var(--tm-primary);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.tm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--tm-radius-sm);
    font-family: var(--tm-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background var(--tm-transition), color var(--tm-transition),
        border-color var(--tm-transition), transform var(--tm-transition),
        box-shadow var(--tm-transition);
    text-decoration: none;
    white-space: nowrap;
}

.tm-btn:focus-visible {
    outline: 3px solid var(--tm-border-focus);
    outline-offset: 2px;
}

.tm-btn:active {
    transform: scale(.97);
}

.tm-btn-primary {
    background: linear-gradient(135deg, var(--tm-primary) 0%, #7c3aed 100%);
    color: #fff;
    border-color: var(--tm-primary);
    box-shadow: 0 4px 14px rgba(79, 70, 229, .35);
}

.tm-btn-primary:hover {
    background: linear-gradient(135deg, var(--tm-primary-h) 0%, #6d28d9 100%);
    box-shadow: 0 6px 20px rgba(79, 70, 229, .45);
}

.tm-btn-outline {
    background: transparent;
    color: var(--tm-primary);
    border-color: var(--tm-primary);
}

.tm-btn-outline:hover {
    background: var(--tm-primary-light);
}

.tm-btn-danger {
    background: transparent;
    color: var(--tm-danger);
    border-color: var(--tm-danger);
}

.tm-btn-danger:hover {
    background: #fee2e2;
    color: var(--tm-danger-h);
}

[data-dark="true"] .tm-btn-danger:hover {
    background: #450a0a;
}

.tm-btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.tm-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ==========================================================================
   GENERATOR CARD
   ========================================================================== */
.tm-generator-card {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #06b6d4 100%);
    padding: 36px;
    text-align: center;
}

[data-dark="true"] .tm-generator-card {
    background: linear-gradient(135deg, #312e81 0%, #4c1d95 50%, #0e7490 100%);
}

.tm-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, .8);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px;
}

.tm-email-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, .15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: var(--tm-radius);
    padding: 6px 6px 6px 20px;
    margin-bottom: 20px;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.tm-email-display {
    flex: 1;
    text-align: left;
    overflow: hidden;
}

#tm-email-text {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.tm-action-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tm-timer {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    font-weight: 500;
}

.tm-countdown {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

/* ==========================================================================
   INBOX PANEL
   ========================================================================== */
.tm-inbox-panel {
    background: var(--tm-card);
    border-top: 1px solid var(--tm-border);
}

.tm-inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--tm-border);
    flex-wrap: wrap;
    gap: 12px;
}

.tm-inbox-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--tm-text);
}

.tm-inbox-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tm-export-group {
    display: flex;
    gap: 6px;
}

.tm-badge {
    background: var(--tm-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Refresh indicator */
.tm-refresh-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    font-size: 12px;
    color: var(--tm-text-3);
    border-bottom: 1px solid var(--tm-border);
}

.tm-refresh-indicator.visible {
    display: flex;
}

.tm-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--tm-border);
    border-top-color: var(--tm-primary);
    border-radius: 50%;
    animation: tmSpin .8s linear infinite;
    flex-shrink: 0;
}

@keyframes tmSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Message list */
.tm-message-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tm-message-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--tm-border);
    cursor: pointer;
    transition: background var(--tm-transition);
    position: relative;
}

.tm-message-item:last-child {
    border-bottom: none;
}

.tm-message-item:hover {
    background: var(--tm-primary-light);
}

[data-dark="true"] .tm-message-item:hover {
    background: rgba(79, 70, 229, .15);
}

.tm-message-item.unread .tm-msg-subject {
    font-weight: 700;
}

.tm-message-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tm-primary);
}

.tm-msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tm-primary) 0%, var(--tm-accent) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.tm-msg-content {
    flex: 1;
    overflow: hidden;
}

.tm-msg-from {
    font-size: 13px;
    font-weight: 600;
    color: var(--tm-text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-msg-subject {
    font-size: 13px;
    color: var(--tm-text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-msg-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.tm-msg-time {
    font-size: 11px;
    color: var(--tm-text-3);
    white-space: nowrap;
}

.tm-msg-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--tm-text-3);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color var(--tm-transition), background var(--tm-transition);
    opacity: 0;
}

.tm-message-item:hover .tm-msg-delete {
    opacity: 1;
}

.tm-msg-delete:hover {
    color: var(--tm-danger);
    background: #fee2e2;
}

[data-dark="true"] .tm-msg-delete:hover {
    background: #450a0a;
}

/* Empty state */
.tm-no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
    color: var(--tm-text-3);
}

.tm-no-messages svg {
    opacity: .35;
    margin-bottom: 16px;
}

.tm-no-messages p {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 500;
}

.tm-no-messages small {
    font-size: 13px;
}

/* ==========================================================================
   EMAIL VIEWER
   ========================================================================== */
.tm-viewer-panel {
    background: var(--tm-card);
    border-top: 1px solid var(--tm-border);
    border-radius: 0 0 var(--tm-radius) var(--tm-radius);
}

.tm-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--tm-border);
}

.tm-viewer-meta {
    padding: 16px 24px;
    background: var(--tm-bg);
    border-bottom: 1px solid var(--tm-border);
}

.tm-meta-row {
    font-size: 13px;
    color: var(--tm-text-2);
    padding: 4px 0;
}

.tm-meta-row strong {
    color: var(--tm-text);
    margin-right: 6px;
}

.tm-viewer-body {
    padding: 0;
    min-height: 300px;
}

#tm-email-iframe {
    width: 100%;
    border: none;
    min-height: 400px;
    background: #fff;
    display: block;
}

.tm-attachments {
    padding: 16px 24px;
    border-top: 1px solid var(--tm-border);
}

.tm-attachments h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--tm-text-2);
}

.tm-attachments ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tm-attachments li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--tm-primary);
    text-decoration: none;
    transition: background var(--tm-transition), border-color var(--tm-transition);
}

.tm-attachments li a:hover {
    background: var(--tm-primary-light);
    border-color: var(--tm-primary);
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.tm-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: #1e293b;
    color: #f1f5f9;
    padding: 14px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--tm-shadow-lg);
    z-index: 9999;
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease;
    max-width: 320px;
}

[data-dark="true"] .tm-toast {
    background: #e2e8f0;
    color: #1e293b;
}

.tm-toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.tm-toast.error {
    background: var(--tm-danger);
    color: #fff;
}

.tm-toast.success {
    background: var(--tm-success);
    color: #fff;
}

/* ==========================================================================
   FAQ SECTION
   ========================================================================== */
.tm-faq-section {
    max-width: 900px;
    margin: 40px auto 0;
    padding: 0 16px;
}

.tm-faq-inner {
    background: var(--tm-card);
    border-radius: var(--tm-radius);
    padding: 40px 44px;
    box-shadow: var(--tm-shadow-md);
}

.tm-section-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--tm-text);
    margin: 0 0 8px;
    text-align: center;
}

.tm-section-subtitle {
    font-size: 15px;
    color: var(--tm-text-2);
    text-align: center;
    margin: 0 0 32px;
}

.tm-faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tm-faq-item {
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color var(--tm-transition), box-shadow var(--tm-transition);
}

.tm-faq-item:has(.tm-faq-question[aria-expanded="true"]) {
    border-color: var(--tm-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}

.tm-faq-question {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    font-family: var(--tm-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--tm-text);
    text-align: left;
    transition: background var(--tm-transition), color var(--tm-transition);
}

.tm-faq-question:hover {
    background: var(--tm-primary-light);
}

[data-dark="true"] .tm-faq-question:hover {
    background: rgba(79, 70, 229, .15);
}

.tm-faq-icon {
    flex-shrink: 0;
    color: var(--tm-primary);
    transition: transform var(--tm-transition);
}

.tm-faq-question[aria-expanded="true"] .tm-faq-icon {
    transform: rotate(180deg);
}

.tm-faq-answer {
    padding: 0 20px;
    overflow: hidden;
    max-height: 0;
    transition: max-height .35s ease, padding .35s ease;
}

.tm-faq-answer:not([hidden]) {
    max-height: 400px;
    padding: 4px 20px 18px;
}

.tm-faq-answer[hidden] {
    display: block !important;
}

/* Override native hidden so CSS max-height works */

.tm-faq-answer p {
    margin: 0;
    font-size: 14px;
    line-height: 1.75;
    color: var(--tm-text-2);
}

/* ==========================================================================
   LATEST POSTS GRID
   ========================================================================== */
.tm-posts-section {
    max-width: 900px;
    margin: 32px auto 0;
    padding: 0 16px 40px;
}

.tm-posts-inner {
    background: var(--tm-card);
    border-radius: var(--tm-radius);
    padding: 40px 44px;
    box-shadow: var(--tm-shadow-md);
}

.tm-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.tm-post-card {
    border: 1px solid var(--tm-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--tm-bg);
    transition: transform var(--tm-transition), box-shadow var(--tm-transition), border-color var(--tm-transition);
}

.tm-post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--tm-shadow-lg);
    border-color: var(--tm-primary);
}

.tm-post-thumb-link {
    display: block;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.tm-post-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 16/9;
    display: block;
    transition: transform .4s ease;
}

.tm-post-card:hover .tm-post-thumb {
    transform: scale(1.05);
}

.tm-post-thumb-placeholder {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, var(--tm-primary-light) 0%, #ddd6fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tm-primary);
}

[data-dark="true"] .tm-post-thumb-placeholder {
    background: linear-gradient(135deg, #1e1b4b 0%, #2e1065 100%);
}

.tm-post-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tm-post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--tm-text-3);
}

.tm-post-cat {
    background: var(--tm-primary-light);
    color: var(--tm-primary);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.tm-post-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--tm-text);
    margin: 0;
    line-height: 1.4;
}

.tm-post-title a {
    color: inherit;
    text-decoration: none;
}

.tm-post-title a:hover {
    color: var(--tm-primary);
}

.tm-post-excerpt {
    font-size: 13px;
    color: var(--tm-text-2);
    margin: 0;
    line-height: 1.6;
    flex: 1;
}

.tm-read-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tm-primary);
    text-decoration: none;
    margin-top: auto;
    transition: gap var(--tm-transition);
}

.tm-read-more:hover {
    gap: 8px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 720px) {
    .tm-posts-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tm-faq-inner,
    .tm-posts-inner {
        padding: 26px 20px;
    }

    .tm-generator-card {
        padding: 24px 16px;
    }

    #tm-email-text {
        font-size: 14px;
    }

    .tm-inbox-actions {
        gap: 6px;
    }

    .tm-inbox-header {
        padding: 12px 16px;
    }

    .tm-message-item {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .tm-posts-grid {
        grid-template-columns: 1fr;
    }

    .tm-email-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tm-export-group {
        display: none;
    }

    /* hide on very small screens */
}

/* ==========================================================================
   UTILITY / ANIMATION
   ========================================================================== */
@keyframes tmFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tm-message-item {
    animation: tmFadeIn .25s ease both;
}

/* Pulse on unread badge */
@keyframes tmPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(6, 182, 212, .5);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(6, 182, 212, 0);
    }
}

.tm-badge {
    animation: tmPulse 2s ease infinite;
}