/* ============================================================
   TempMail — Стили
   Премиальный дизайн: градиенты, тени, микро-анимации
   ============================================================ */

/* --- Токены дизайн-системы --- */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-start: #667eea;
    --primary-end: #764ba2;
    --accent: #2CC672;
    --accent-hover: #25a85f;
    --accent-light: rgba(44, 198, 114, 0.1);
    --accent-glow: rgba(44, 198, 114, 0.25);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.08);
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;
    --border: #e5e7eb;
    --border-focus: #667eea;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.18);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --transition: all 0.2s ease;
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --container-max: 680px;
}

/* --- Сброс и базовые стили --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* --- Кнопки: базовые стили --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    flex-shrink: 0;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
    position: relative;
    background: var(--primary-gradient);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 24px 100px;
    overflow: hidden;
}

/* Декоративные круги на фоне */
.hero::before,
.hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    background: #fff;
}
.hero::before {
    width: 400px;
    height: 400px;
    top: -120px;
    right: -80px;
}
.hero::after {
    width: 250px;
    height: 250px;
    bottom: -60px;
    left: -40px;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    animation: fadeIn 0.8s ease;
}

.hero-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
    line-height: 1.7;
}

/* Волна внизу hero */
.hero-wave {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    z-index: 1;
    line-height: 0;
}
.hero-wave svg {
    width: 100%;
    height: 60px;
    display: block;
}

/* ============================================================
   ADDRESS BAR — Карточка с адресом
   ============================================================ */
.address-bar {
    position: relative;
    z-index: 10;
    max-width: var(--container-max);
    margin: -48px auto 0;
    padding: 28px 28px 20px;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.6s ease;
}

.address-inputs {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.input-group {
    flex: 1;
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.input-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.input-username {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 14px 16px;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 0;
}

.input-username::placeholder {
    color: var(--text-light);
    font-weight: 400;
}

.input-at {
    display: flex;
    align-items: center;
    color: var(--text-light);
    font-size: 1.05rem;
    font-weight: 500;
    user-select: none;
    padding: 0 2px;
}

.select-domain {
    border: none;
    outline: none;
    background: transparent;
    padding: 14px 32px 14px 4px;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 140px;
}

/* Кнопка «Копировать» */
.btn-copy {
    background: var(--accent);
    color: var(--text-white);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-copy:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-copy:active {
    transform: scale(0.97) translateY(0);
}

.btn-copy.copied {
    background: #16a34a;
}

/* Ряд действий под адресом */
.address-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Кнопка «Случайное имя» */
.btn-random {
    background: var(--accent-light);
    color: var(--accent);
    border: 1.5px solid var(--accent);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.btn-random:hover {
    background: var(--accent);
    color: var(--text-white);
}

.btn-random .refresh-icon.spinning {
    animation: spin 0.6s ease;
}

/* Бейдж таймера */
.timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    margin-left: auto;
}

.timer-badge:hover {
    background: var(--border);
}

.timer-badge.warning {
    color: var(--warning);
    border-color: var(--warning);
    background: var(--warning-light);
}

.timer-badge.danger {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-light);
    animation: pulse 1.5s ease infinite;
}

.timer-icon {
    flex-shrink: 0;
}

/* Кнопка «Удалить ящик» */
.btn-delete {
    background: transparent;
    color: var(--text-light);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
}

.btn-delete:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* ============================================================
   INBOX — Список входящих
   ============================================================ */
.inbox-section {
    max-width: var(--container-max);
    margin: 32px auto 0;
    padding: 0 16px 60px;
    flex: 1;
    width: 100%;
}

.inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.inbox-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inbox-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--accent);
    color: var(--text-white);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    line-height: 1;
}

.btn-refresh {
    background: var(--card-bg);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-refresh:hover {
    background: var(--bg);
    color: var(--text-primary);
    border-color: var(--text-light);
}

.btn-refresh .refresh-icon.spinning {
    animation: spin 0.6s ease;
}

/* Список сообщений */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Элемент сообщения */
.message-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    animation: fadeIn 0.35s ease;
}

.message-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: var(--border);
}

.message-item:active {
    transform: translateY(0);
}

.message-item.unread {
    border-left: 3px solid var(--accent);
    background: linear-gradient(90deg, var(--accent-light) 0%, var(--card-bg) 15%);
}

.message-item.unread .message-sender {
    font-weight: 700;
}

.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-white);
    flex-shrink: 0;
    text-transform: uppercase;
}

.message-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.message-sender {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-subject {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
}

/* Пустое состояние */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-spinner {
    animation: pulse 2s ease-in-out infinite;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-hint {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ============================================================
   MODAL — Просмотр письма
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.97);
    transition: var(--transition-slow);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title-group {
    min-width: 0;
    flex: 1;
}

.modal-subject {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 6px;
    word-break: break-word;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.modal-sender {
    font-weight: 600;
}

.modal-date {
    color: var(--text-light);
}

.btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.btn-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.modal-content-frame {
    word-break: break-word;
}

.modal-content-frame iframe {
    width: 100%;
    border: none;
    min-height: 200px;
    border-radius: var(--radius-sm);
}

/* Вложения */
.modal-attachments {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.attachments-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.attachments-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    border: 1px solid var(--border);
}

.attachment-item a {
    color: var(--primary-start);
    text-decoration: none;
    font-weight: 500;
}

.attachment-item a:hover {
    text-decoration: underline;
}

.attachment-size {
    color: var(--text-light);
    margin-left: auto;
}

/* Подвал модала */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border);
}

.btn-modal-delete {
    background: transparent;
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
}

.btn-modal-delete:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* ============================================================
   TOAST — Уведомления
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-left: 4px solid var(--accent);
    max-width: 380px;
}

.toast.info {
    border-left-color: var(--info);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.success {
    border-left-color: var(--accent);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-light);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Скелетон-загрузка */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, #f5f5f5 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .hero {
        min-height: 240px;
        padding: 48px 20px 80px;
    }

    .hero-title {
        font-size: 1.65rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .hero-subtitle br {
        display: none;
    }

    .address-bar {
        margin: -40px 12px 0;
        padding: 20px 16px 16px;
        border-radius: var(--radius-lg);
    }

    .address-inputs {
        flex-direction: column;
        gap: 10px;
    }

    .input-group {
        width: 100%;
    }

    .input-username {
        font-size: 0.95rem;
        padding: 12px 14px;
    }

    .select-domain {
        font-size: 0.95rem;
        padding: 12px 28px 12px 4px;
        min-width: 110px;
    }

    .btn-copy {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }

    .address-actions {
        gap: 8px;
    }

    .timer-badge {
        margin-left: 0;
    }

    .inbox-section {
        margin-top: 24px;
        padding: 0 12px 40px;
    }

    .message-item {
        padding: 14px;
        gap: 12px;
    }

    .message-avatar {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }

    /* Модал — во весь экран на мобилках */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .modal-header {
        padding: 20px 16px 12px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-attachments {
        padding: 12px 16px;
    }

    .modal-footer {
        padding: 10px 16px 14px;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .toast {
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .hero-title {
        font-size: 1.4rem;
    }

    .address-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .timer-badge {
        justify-content: center;
    }
}
