@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Literata:wght@500;700&display=swap');

:root {
    --primary: #B99CFB;
    /* Updated to Soft Purple (Premium) */
    --primary-hover: #a587e5;
    --bg-color: #FDFBF7;
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-sans: 'Inter', sans-serif;
    --font-serif: 'Literata', serif;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --border-color: #E2E8F0;
    --error: #FF5252;
    --success: #00B894;

    /* Additional variables used in JS components */
    --surface-color: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, 0.9);
    /* New unified glass var */
    --primary-gold: #D4AF37;
    --radius-lg: 0.75rem;
    --radius-md: 0.5rem;
    --accent-blue: #8AB6D6;

    /* Layout Variables */
    --nav-height: 80px;
    --content-max-width: 1200px;
}

/* Dark Mode Variables */
/* Dark Mode Variables - DISABLED
html.dark:root {
    --bg-color: #121212;
    --text-primary: #E0E0E0;
    --text-secondary: #A0A0A0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --nav-bg: rgba(18, 18, 18, 0.9);
    --border-color: #2D2D2D;
    --surface-color: #1E1E1E;
}
*/

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    width: 100%;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    /* Prevent horizontal scroll on mobile */
}

/* Layout Specifics */
#app {
    width: 100%;
    min-height: 100vh;
    position: relative;
    background: var(--bg-color);
    padding-bottom: calc(var(--nav-height) + 40px);
    /* Ensure content isn't hidden behind nav */
}

/* Scrollbar */
/* Scrollbar - Custom Premium Style */
::-webkit-scrollbar {
    width: 6px;
    /* Thinner */
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    /* Light gray default */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
    /* Purple on hover */
}

@media (min-width: 768px) {
    ::-webkit-scrollbar {
        display: block;
    }
}


/* Auth Pages */
.auth-container {
    padding: 24px;
    max-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo-large {
    text-align: center;
    margin-bottom: 48px;
}

.logo-large h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    color: var(--primary);
    margin: 0;
}

.logo-large p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.auth-form {
    background: var(--surface-color);
    padding: 32px;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    /* Fix width to be fully responsive */
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 1rem;
    /* 16px minimum for iOS to prevent zoom */
    transition: border-color 0.2s;
    box-sizing: border-box;
    /* Crucial for padding to be included in width */
}

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

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.auth-link {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 6px;
    display: none;
}

/* Explore Friends Page */
.explore-friends-page {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 24px 16px;
    /* Reduced vertical padding for mobile */
}

.explore-header {
    text-align: center;
    margin-bottom: 32px;
}

.explore-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    /* responsive typography */
    color: var(--primary);
    margin: 0 0 8px 0;
}

@media (min-width: 768px) {
    .explore-title {
        font-size: 2.5rem;
        margin: 0 0 12px 0;
    }

    .explore-friends-page {
        padding: 40px 24px;
    }
}

.explore-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
}

/* Search Box Styled */
.search-container {
    margin-bottom: 32px;
    position: relative;
    z-index: 10;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--primary);
    pointer-events: none;
    z-index: 2;
}

.search-input {
    width: 100%;
    padding: 16px 20px 16px 56px;
    border: 2px solid var(--surface-color);
    border-radius: 20px;
    /* Softer pill shape */
    background: var(--surface-color);
    font-family: var(--font-sans);
    font-size: 1rem;
    /* Prevent zoom on mobile */
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    /* Lighter shadow */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    /* Normalize iOS appearance */
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.15);
    background: var(--surface-color);
}

.search-input::placeholder {
    color: #A0AEC0;
}

.search-results {
    margin-bottom: 48px;
}

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

.search-empty-icon,
.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px;
    color: var(--text-secondary);
}

/* Simple Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(108, 92, 231, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

/* Suggested Section */
.suggested-section {
    margin-top: 48px;
}

.section-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 20px 0;
}

/* User List */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* User Card */
.user-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.user-card-avatar img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
}

.user-card-username {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 6px 0;
}

.user-card-bio {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.user-card-genres {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.genre-chip {
    display: inline-block;
    padding: 2px 10px;
    background: #F3ECFF;
    color: var(--primary);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}

.genre-chip-empty {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.user-card-actions {
    display: flex;
    align-items: center;
}

.user-card-you {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Follow Button */
.btn-follow {
    padding: 8px 20px;
    border-radius: 50px;
    border: none;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    /* Ensure minimum touch target on mobile */
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-follow:not(.following):hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.btn-follow.following {
    background: #E5E5E5;
    color: var(--text-secondary);
}

.btn-follow.following:hover {
    background: #FFE5E5;
    color: #D32F2F;
}

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

/* Responsive User Cards */
@media (max-width: 480px) {
    .user-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .user-card-info {
        text-align: center;
        width: 100%;
    }

    .user-card-genres {
        justify-content: center;
    }

    .user-card-actions {
        width: 100%;
        margin-top: 12px;
        justify-content: center;
    }

    .btn-follow {
        width: 100%;
        max-width: 200px;
    }
}

/* Followers/Following Pages */
.followers-page,
.following-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.btn-back {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-back:hover {
    background: #F5F5F5;
    border-color: var(--primary);
}

.page-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* 
   ==========================================================================
   FLOATING NAVIGATION
   ==========================================================================
*/
.floating-nav {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 4px;
    /* Reduced gap - items handle their own spacing */
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: auto;
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    /* Just in case */
}

/* Improved spacing for nav items */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    /* Minimum width for touch target */
    height: 100%;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border-radius: 16px;
    padding: 8px 4px;
    position: relative;
    /* Touch target expansion */

}

.nav-item:hover {
    color: var(--primary);
    background: rgba(108, 92, 231, 0.05);
    /* Subtle hover bg */
}

.nav-item.active {
    color: var(--primary);
}

.nav-item span {
    font-size: 24px;
    margin-bottom: 2px;
}

.nav-item p {
    margin: 0;
    font-size: 11px;
    font-weight: 500;
}

.add-button {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    margin: 0 12px;
    padding: 0;
    /* Override nav-item padding */
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
    transform: translateY(-12px);
    /* Adjusted for true centering */
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 4px solid var(--bg-color);
    flex-shrink: 0;
    /* Prevent squashing */
}

.add-button:hover {
    transform: translateY(-12px) scale(1.1);
    /* Keep same Y position, just scale */
    box-shadow: 0 8px 16px rgba(108, 92, 231, 0.5);
    background: var(--primary-hover);
    color: white !important;
    /* Force white text to override .nav-item:hover */
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .floating-nav {
        padding: 6px 12px;
        bottom: 16px;
        width: calc(100% - 32px);
        /* Fullish width on mobile */
        justify-content: space-between;
    }

    .nav-item {
        min-width: auto;
        flex: 1;
        /* Distribute space */
        padding: 4px 0;
    }

    .nav-item span {
        font-size: 22px;
    }

    .nav-item p {
        font-size: 10px;
    }

    .add-button {
        width: 50px;
        height: 50px;
        font-size: 24px;
        margin: 0 4px;
        transform: translateY(-20px);
        border-width: 3px;
    }

    .add-button:hover {
        transform: translateY(-22px) scale(1.05);
        /* Reduced bounce on mobile */
    }
}

/* Small mobile / Safe Area support */
@media (max-width: 360px) {
    .floating-nav {
        bottom: 12px;
    }

    .nav-item p {
        font-size: 9px;
    }
}

/* Fix for IOS Safari height issues */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }

    #app {
        min-height: -webkit-fill-available;
        /* Increase bottom padding to ensure content is visible above floating nav */
        padding-bottom: calc(var(--nav-height) + 100px);
    }
}

/* Safe Area support for Floating Nav */
.floating-nav {
    /* Lift nav above the home indicator */
    bottom: calc(20px + env(safe-area-inset-bottom));
}

@media (max-width: 480px) {
    .floating-nav {
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Typography fixes for small screens */
@media (max-width: 400px) {

    h1,
    .explore-title,
    .font-serif.text-4xl,
    .font-serif.text-5xl {
        font-size: 1.8rem !important;
        /* Prevent header overflow */
        line-height: 1.2;
    }

    .font-serif.text-2xl {
        font-size: 1.5rem !important;
    }

    /* Adjust Mood Reader H1 top spacing on mobile to avoid 'Voltar' button clash */
    .font-serif.text-5xl.font-bold {
        margin-top: 1.5rem;
    }
}

/* Quotes Page Tab Buttons */
.tab-btn {
    background: transparent;
    color: #6B7280;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #374151;
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: white;
    color: #6C5CE7;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}