/* CSS Variables - Modern Color Palette */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-focus: #6366f1;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
}

/* Screens */
.screen {
    min-height: 100vh;
}

.screen.hidden {
    display: none;
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    padding: 48px 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card .logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.login-card .logo svg {
    width: 32px;
    height: 32px;
}

.login-card h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.login-card .session-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 20px;
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Email Input Wrapper */
.email-input-wrapper {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.email-input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.email-input-wrapper input {
    flex: 1;
    border: none;
    border-radius: 0;
    padding: 12px 16px;
}

.email-input-wrapper input:focus {
    box-shadow: none;
}

.domain-suffix {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 2px solid var(--border);
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

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

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

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

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

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

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Navigation */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.nav-brand svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.nav-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-tab svg {
    width: 18px;
    height: 18px;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--bg-secondary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout svg {
    width: 20px;
    height: 20px;
}

.btn-logout:hover {
    background: var(--bg-tertiary);
    color: var(--danger);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 32px 24px;
    max-width: 800px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Card */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

/* Forward Addresses */
.forward-addresses {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Accounts List */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.account-item:hover {
    background: var(--primary-light);
    transform: translateX(4px);
}

.account-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.account-icon svg {
    width: 20px;
    height: 20px;
}

.account-email {
    font-weight: 500;
    color: var(--text-primary);
}

.account-forward-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.account-arrow {
    color: var(--text-muted);
}

.account-arrow svg {
    width: 20px;
    height: 20px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px;
    color: var(--text-secondary);
}

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

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

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

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

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

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

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

.modal-body h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.forward-list-section {
    margin-bottom: 24px;
}

.modal-forward-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.forward-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
}

.forward-item-email {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.forward-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.forward-item-remove svg {
    width: 16px;
    height: 16px;
}

.forward-item-remove:hover {
    background: var(--danger);
    color: white;
}

.add-forward-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.add-forward-row {
    display: flex;
    gap: 12px;
}

.add-forward-row input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.add-forward-row input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

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

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

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

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

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

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

.toast-message {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        gap: 12px;
    }

    .nav-tabs {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .login-card {
        padding: 32px 24px;
    }

    .card {
        padding: 24px;
    }

    .tab-content {
        padding: 24px 16px;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 12px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .email-input-wrapper {
        flex-direction: column;
    }

    .domain-suffix {
        border-left: none;
        border-top: 2px solid var(--border);
        justify-content: center;
        padding: 10px 16px;
    }
}

@media (max-width: 480px) {
    .nav-tab span {
        display: none;
    }

    .nav-tab {
        padding: 10px 16px;
    }
}
