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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.logo svg {
    color: white;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-content {
    margin-bottom: 40px;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.primary-section {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-xl);
}

.intro-section {
    text-align: center;
    margin-bottom: 32px;
}

.intro-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.intro-text {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.email-display-section {
    margin-bottom: 40px;
}

.email-display {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    word-break: break-all;
    transition: all 0.3s;
}

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

.email-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

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

.inbox-section {
    margin-top: 40px;
}

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

.inbox-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.inbox-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.inbox-list {
    min-height: 300px;
}

.empty-inbox {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-inbox svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-inbox p {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-inbox small {
    font-size: 14px;
}

.email-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.email-item.unread {
    background: white;
    border-color: var(--primary-color);
    border-width: 2px;
}

.email-item-content {
    flex: 1;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.email-sender {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

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

.email-subject {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.email-item.unread .email-subject {
    font-weight: 600;
    color: var(--text-primary);
}

.email-badges {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

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

.badge-attachment {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    max-width: 800px;
    margin: 50px auto;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    padding-right: 20px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.email-meta {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.email-meta-item {
    margin-bottom: 8px;
    font-size: 14px;
}

.email-meta-item:last-child {
    margin-bottom: 0;
}

.email-meta-item strong {
    color: var(--text-secondary);
    margin-right: 8px;
}

.email-body {
    line-height: 1.8;
    color: var(--text-primary);
}

.email-body iframe {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 400px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-light);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

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

.sidebar-section {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
}

.ad-container {
    margin: 20px 0;
    text-align: center;
}

.ad-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 14px;
}

@media (min-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .primary-section {
        padding: 20px;
    }

    .intro-title {
        font-size: 22px;
    }

    .intro-text {
        font-size: 14px;
    }

    .email-display {
        font-size: 16px;
        padding: 16px;
    }

    .email-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .inbox-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .modal-content {
        margin: 20px;
        max-height: calc(100vh - 40px);
    }

    .sidebar-section {
        display: none;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 20px;
    }

    .email-item {
        padding: 12px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }
}
