:root {
    --primary-pink: #FF66A1;
    --primary-gradient: linear-gradient(135deg, #FF7DB2, #FF5D99);
    --bg-light: #FFF9FB;
    --text-dark: #1D264D;
    --border-gray: #F0F0F0;
    --shadow: 0 4px 15px rgba(0,0,0,0.08);
}

/* 1. Global Reset - Adjusted for Visibility */
body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
    overflow-y: auto;   /* Allow vertical scroll for header/content */
    background-color: var(--bg-light);
    color: var(--text-dark);
}

/* 2. Layout Framework */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 500px; /* Centers the content on desktop */
    margin: 0 auto;
    background: #fff;
}

.main-content {
    flex: 1;
    display: block; /* Change from flex to block to fix grid alignment */
    padding: 0;
    margin: 0;
    /* This padding ensures the last grid items are visible above the fixed footer */
    padding-bottom: 80px !important; 
}

/* 3. Button Styles - RESTORED MISSING CLASS */
.btn-primary-custom {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: bold;
    box-shadow: 0 8px 20px rgba(255, 102, 161, 0.3);
    transition: transform 0.2s ease;
    width: 100%;
}

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

.text-primary-pink {
    color: var(--primary-pink) !important;
}

/* 4. Onboarding Screens Visibility */
.screen { 
    display: none; 
    width: 100%; 
}
.screen.active { 
    display: flex; 
    flex-direction: column;
    align-items: center;
}

/* 5. Profile Card (Discovery) */
.profile-card {
    position: relative;
    height: 70vh; 
    width: 100%;
    border: 4px solid var(--primary-pink);
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    touch-action: none;
}

.main-profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 6. Overlays */
.overlay-msg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.overlay-content {
    background: var(--text-dark); color: white; padding: 30px;
    border-radius: 25px; text-align: center; max-width: 85%;
}

/* 1. Back Button (Fixes the boxy look) */
.back-btn {
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 1.5rem;
    padding: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* 2. Standard Buttons (Sri Lanka / Other) */
.btn-outline-dark {
    border: 2px solid var(--border-gray) !important;
    color: var(--text-dark) !important;
    background: #fff !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-outline-dark:active {
    border-color: var(--primary-pink) !important;
    color: var(--primary-pink) !important;
    background: var(--bg-light) !important;
}

/* 3. Input Fields (07XXXXXXXX) */
.digit-field {
    width: 100%;
    height: 55px;
    border: 2px solid var(--border-gray);
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-dark);
    background: #fff;
    margin: 8px;
    outline: none;
    transition: border-color 0.3s ease;
}

.digit-field:focus {
    border-color: var(--primary-pink);
}

/* 4. Branding Colors */
.text-primary-pink {
    color: var(--primary-pink) !important;
}

/* 1. Country Toggle Alignment */
.d-flex.gap-2.mb-4 {
    width: 100%;
    max-width: 320px; /* Adjust this to match your input field width */
    margin: 0 auto; /* Centers the toggle group */
}

/* 2. Fix Button Widths (Sri Lanka / Other) */
#btn-login-sl, #btn-login-other {
    height: 45px; /* Ensures a consistent touch target */
    font-weight: 600;
    font-size: 0.9rem;
}

/* 3. Login Button Alignment */
.btn-primary-custom.fixed-bottom-btn {
    position: relative; /* Changing from fixed to match input width */
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 320px; /* Must match the input and toggle width */
    margin: 30px auto 0 auto; /* Centers the button and adds top spacing */
}

/* 4. Mobile Input Field Centering */
.mobile-input, 
.d-flex.gap-2.mb-4,
.onboarding-btn {
    width: 100%;
    max-width: 320px;
    margin: 0 auto; /* Ensures the input is centered */
}

/* Ensure buttons follow standard flow instead of sticking to bottom */
.btn-primary-custom.onboarding-btn {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    margin-top: 25px; /* Adds space below the input field */
}



/* Profile Card Styling */
.profile-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    touch-action: none;
}

.main-profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Text Overlay with Gradient */
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 30px 20px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    color: white;
}

.profile-bio {
    opacity: 0.85;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Swipe Indicators */
.swipe-indicator {
    position: absolute;
    top: 30px;
    padding: 8px 15px;
    border: 4px solid;
    border-radius: 8px;
    font-size: 1.8rem;
    font-weight: 800;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.indicator-like {
    left: 20px;
    color: #4CAF50;
    border-color: #4CAF50;
    transform: rotate(-15deg);
}

.indicator-dislike {
    right: 20px;
    color: #FF4B2B;
    border-color: #FF4B2B;
    transform: rotate(15deg);
}

/* Action Buttons Container */
.action-buttons-container {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 25px;
    width: 100%;
}

.action-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: transform 0.2s ease;
}

.action-btn:active {
    transform: scale(0.9);
}

.btn-dislike { color: #FF4B2B; }
.btn-like { color: var(--primary-pink); }

/* Empty State Styling */
.no-matches-box {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

/* --- MAIN FOOTER NAVIGATION --- */

.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: #ffffff;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    /* Use env() to handle mobile safe areas (notches/home bars) */
    padding-bottom: env(safe-area-inset-bottom); 
}

.nav-item {
    color: #aaa;
    font-size: 1.5rem;
    text-decoration: none;
    transition: color 0.2s;
}

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

.nav-item i {
    transition: transform 0.2s ease;
}

.nav-item:active i {
    transform: scale(0.9);
}

/* Ensure the wrapper allows the footer to stick */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    background: #fff;
}

/* --- FIXED DISCOVERY ANIMATION --- */

/* Hide the old buttons container as requested */
.action-buttons-container {
    display: none !important;
}

/* The wrapper starts at 0 opacity when triggered */
.profile-card-content {
    width: 100%;
    height: 100%;
    opacity: 1;
}

/* Single class to trigger the smooth entrance */
.animate-fade-in {
    animation: smoothFadeIn 0.5s ease-out forwards;
}

@keyframes smoothFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
    gap: 12px;
    padding: 12px;
    width: 100%;
}

.profile-tile {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 15px;
    overflow: hidden;
    background: #eee;
    box-shadow: var(--shadow);
    animation: smoothFadeIn 0.5s ease-out forwards;
}

.tile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 10px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
    color: white;
}

.tile-info h6 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.tile-info p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Update Wrapper for Grid Scrolling */
.wrapper {
    overflow-y: auto; /* Allow the wrapper itself to scroll for intersection observer */
    height: 100dvh;
}

.main-content {
    flex: 1;
    display: block; /* Change from flex to block to fix grid alignment */
    padding: 0;
    margin: 0;
    /* This padding ensures the last grid items are visible above the fixed footer */
    padding-bottom: 80px !important; 
}


/* --- PROFILE DETAIL VIEW STYLES --- */

.detail-img-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: #000;
}

.detail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.back-pill {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.4);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 10;
}

.section-title {
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 1rem;
}

.action-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    background: linear-gradient(transparent, #fff 40%);
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 500px;
}

.action-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.btn-dislike { color: #FF4B2B; }
.btn-like { color: var(--primary-pink); }
.btn-chat { color: #3498db; }

/* --- PROFESSIONAL PROFILE VIEW STYLES --- */

/* 1. Ensure the container takes up the full space properly */
.wrapper {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* 2. Fix the Image Container to maintain a high-quality look */
.detail-img-container {
    width: 100%;
    aspect-ratio: 4 / 5; /* Professional portrait ratio */
    position: relative;
    background: #f8f9fa;
}

.detail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 3. Improved Profile Info Layout */
.profile-details-section {
    padding: 24px 20px;
    background: #fff;
    border-radius: 30px 30px 0 0;
    margin-top: -30px; /* Pulls details slightly over the image for modern look */
    position: relative;
    z-index: 5;
}

.profile-name-age {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.profile-location {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-top: 24px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-bio-text {
    line-height: 1.6;
    color: #576574;
    font-size: 0.95rem;
}

/* 4. Modern Interest Tags */
.interests-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 100px; /* Space for the floating action bar */
}

.tag-pill {
    background: #fdf2f7;
    color: var(--primary-pink);
    border: 1px solid #ffdeeb;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 2. Style the new static interaction bar */
.action-bar-static {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 20px 0;
    width: 100%;
    /* Add a subtle background or border if you want to separate it from the nav */
    margin-bottom: 40px; 
}

.action-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); /* Slightly softer shadow for static placement */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.action-circle:active {
    transform: scale(0.9);
}

/* Individual Button Colors */
.btn-dislike { color: #eb4d4b; border: 1px solid #f8d7da; }
.btn-chat { color: #3498db; border: 1px solid #d1e9f7; }
.btn-like { color: #27ae60; border: 1px solid #d4edda; }

/* 3. Ensure the details section allows for bottom scrolling */
.profile-details-section {
    padding-bottom: 60px; /* Extra padding so buttons aren't cut off by footer nav */
}

/* --- PROFESSIONAL HEADER & SIDEBAR --- */

.main-app-header {
    height: 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-gray);
    position: sticky; /* Keep it at the top */
    top: 0;
    width: 100%;
    z-index: 1030;
}

.menu-trigger, .filter-trigger {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-dark);
    padding: 5px;
}

.header-logo i {
    color: var(--primary-pink);
    font-size: 1.8rem;
}

/* Sidebar Custom Styling */
.sidebar-custom {
    width: 280px !important;
    border: none !important;
    box-shadow: 10px 0 30px rgba(0,0,0,0.05) !important;
}

.sidebar-user-card {
    padding: 40px 24px 30px;
    background: linear-gradient(to bottom, #fff9fb, #fff);
    text-align: center;
    border-bottom: 1px solid #f8f9fa;
}

.user-avatar-wrapper {
    width: 110px;
    height: 110px;
    margin: 0 auto 15px;
    border-radius: 50%;
    padding: 5px;
    background: #fff;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

.user-avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-name {
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
    font-size: 1.2rem;
}

.user-email {
    font-size: 0.85rem;
    color: #95a5a6;
    margin-top: 4px;
}

/* Navigation Links */
.sidebar-nav {
    padding: 20px 15px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    text-decoration: none;
    color: #576574;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-link-item .icon-box {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 10px;
    margin-right: 15px;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.nav-link-item:active, .nav-link-item.active {
    background: #fff0f6;
    color: var(--primary-pink);
}

.nav-link-item.active .icon-box {
    background: var(--primary-pink);
    color: #fff;
}

.arrow-icon {
    font-size: 0.8rem;
    opacity: 0.3;
}

.nav-divider {
    height: 1px;
    background: #f1f2f6;
    margin: 15px;
}

.logout-link {
    color: #ee5253;
}

.logout-link .icon-box {
    color: #ee5253;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 30px;
    text-align: center;
    background: #fcfcfc;
}

.brand-text {
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
    letter-spacing: 1px;
}

.version-text {
    font-size: 0.75rem;
    color: #bdc3c7;
    margin-top: 5px;
}

.overlay-content .btn-primary-custom {
    padding: 8px 20px;
    font-size: 0.9rem;
    box-shadow: none; /* Cleaner look inside dark overlay */
}