/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-input: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a1a1a1;
    --text-muted: #666666;
    --border-color: #2a2a2a;
    --accent: #ff2442;
    --accent-hover: #ff4d63;
    --purple: #8B5CF6;
    --purple-hover: #7C3AED;
    --success: #22c55e;
    --error: #ef4444;
    --radius: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

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

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

a {
    color: inherit;
    text-decoration: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 36, 66, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    background: var(--bg-card);
}

.btn-block {
    width: 100%;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-google:hover {
    background: #f5f5f5;
}

.google-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: inherit;
}

.link-btn:hover {
    text-decoration: underline;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
}

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

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
}

/* ===== Auth Form ===== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0;
    color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-switch {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* ===== Copy Button ===== */
.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--bg-card);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-sm {
    padding: 4px 6px;
}

.copy-sm svg {
    width: 12px;
    height: 12px;
}

/* ===== Premium Header Styles (from v0-web-bookmark-manager inspiration) ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 64px;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.header-content {
    max-width: 1400px;
    /* Wider for better spacing */
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    /* Change from space-between to flex-start for stable left alignment */
    justify-content: flex-start;
    gap: 40px;
    /* Fixed gap between Logo and Nav */
}

@media (max-width: 1024px) {
    .header-content {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .header-content {
        gap: 12px;
        padding: 0 16px;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
    /* Prevent logo shrinking */
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(255, 36, 66, 0.3));
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
    /* Cleaner white text */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    /* Reduced gap slightly since we have fixed width items */
    /* Subtle nav container */
    padding: 4px;
    border-radius: 999px;
    /* Removed background/border for cleaner look or keep if desired, keeping for now */
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Very subtle */
}

.nav-link {
    padding: 8px 0;
    /* Horizontal padding replaced by fixed width */
    width: 90px;
    /* Fixed width for 4-char items to prevent bold shift */
    border-radius: 999px;
    /* Pill shape */
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    /* Center text within fixed width */
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Special Admin Link Style */
#adminNavLink {
    color: var(--accent);
}

#adminNavLink:hover,
#adminNavLink.active {
    background: rgba(255, 36, 66, 0.1);
    color: var(--accent-hover);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    /* Push to right */
    flex-shrink: 0;
    /* Prevent compression */
}

/* User Menu Premium */
.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-quota {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 999px;
    font-size: 0.85rem;
    color: #A78BFA;
    font-weight: 500;
    white-space: nowrap;
    /* Prevent wrap */
    min-width: 120px;
    /* Prevent jitter when numbers change */
    justify-content: center;
}

.user-avatar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    /* Ring effect */
    background-clip: padding-box;
    transition: all 0.2s ease;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
    /* External ring */
}

.user-avatar:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 220px;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top right;
}

.user-avatar-wrapper:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    background: transparent;
    border: none;
    text-align: left;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.1s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Authentication Buttons */
.auth-buttons {
    display: flex;
    gap: 12px;
}

@media (max-width: 480px) {
    .auth-buttons {
        gap: 8px;
    }

    .auth-buttons .btn {
        padding: 6px 14px;
        font-size: 0.85rem;
    }
}

.auth-buttons .btn {
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .nav {
        display: flex;
        position: fixed;
        bottom: 24px;
        bottom: calc(24px + env(safe-area-inset-bottom));
        left: 5%;
        right: 5%;
        width: auto;
        /* Width determined by left/right */
        max-width: 400px;
        margin: 0 auto;
        /* Center if max-width hit */
        background: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 999px;
        padding: 4px;
        justify-content: space-between;
        gap: 0;
        /* Remove gap, let flex handle spacing */
        z-index: 1000;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }

    .nav-link {
        flex: 1;
        /* Equal width for all items */
        font-size: 0.85rem;
        padding: 12px 0;
        /* Vertical padding only */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
        border-radius: 999px;
        /* Match container radius child */
    }

    /* Hide Admin link on mobile footer to save space (accessible via avatar menu) */
    #adminNavLink {
        display: none !important;
    }
}

/* ===== Contact Modal Styles ===== */
.contact-modal-content {
    max-width: 360px;
    padding: 24px;
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    transition: var(--transition);
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.contact-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    overflow: hidden;
}

.contact-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.contact-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-copy {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.contact-hint {
    margin-top: 24px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.contact-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-qr img {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    border: 4px solid white;
}

.contact-qr p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Redeem Modal Specific ===== */
.modal-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1.1rem;
    letter-spacing: 1px;
    transition: var(--transition);
    text-align: center;
    font-family: monospace;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 36, 66, 0.1);
}

.redeem-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.redeem-footer a {
    color: var(--accent);
    font-weight: 500;
}

.redeem-footer a:hover {
    text-decoration: underline;
}