:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --primary-color: #ff4b60;
    /* CMB Red */
    --primary-hover: #e03e50;
    --border-color: #e0e0e0;
    --sidebar-bg: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.dark-mode {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --text-secondary: #aaaaaa;
    --primary-color: #ff6b7d;
    --primary-hover: #ff4b60;
    --border-color: #444444;
    --sidebar-bg: #2d2d2d;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

header {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

/* Mobile Header Tweaks */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header-controls {
        justify-content: space-between;
        width: 100%;
    }

    .theme-toggle {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        flex: 1;
        /* Distribute space evenly */
        text-align: center;
    }

    /* Hide text on very small screens if needed, or just keep icons */
}

.container {
    display: flex;
    max-width: 1400px;
    margin: 2rem auto;
    gap: 2rem;
    padding: 0 1rem;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    height: fit-content;
    flex-shrink: 0;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

/* Checkbox Groups */
.checkbox-group {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    background-color: var(--bg-color);
}

.checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.checkbox-item input {
    margin-right: 0.5rem;
    width: auto;
}

.checkbox-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-toggle:hover {
    background-color: var(--border-color);
}

.checkbox-toggle input {
    margin-right: 0.8rem;
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary-color);
}

.checkbox-toggle span {
    font-weight: 600;
    color: var(--text-color);
}

button#reset-filters {
    width: 100%;
    padding: 0.8rem;
    background-color: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

button#reset-filters:hover {
    background-color: #444;
}

/* Grid */
.grid-container {
    flex-grow: 1;
}

.results-count {
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.profile-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    /* For heart icon */
    display: flex;
    flex-direction: column;
}

.profile-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
}

.card-image {
    width: 100%;
    height: 320px;
    object-fit: cover;
    background-color: #eee;
}

.card-content {
    padding: 1.2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
}

.card-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.paid-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 0.5rem;
}

/* Heart Icon */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: #ccc;
    transition: all 0.2s;
    z-index: 10;
}

.favorite-btn:hover {
    transform: scale(1.1);
    background: white;
}

.favorite-btn.active {
    color: var(--primary-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 1100px;
    max-height: 90vh;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-body {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
        overflow: hidden;
    }
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem;
    /* Larger */
    font-weight: bold;
    cursor: pointer;
    color: #666;
    z-index: 1001;
    /* High z-index */
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 45px;
    /* Larger touch target */
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.close-btn:hover {
    background: white;
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Carousel Styles */
.modal-image-container {
    flex: 1;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 400px;
}

@media (min-width: 768px) {
    .modal-image-container {
        height: auto;
        min-height: auto;
    }
}

.carousel-slide {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.carousel-slide.active {
    display: block;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 5;
}

.carousel-nav:hover {
    background: rgba(255, 255, 255, 0.4);
}

.carousel-prev {
    left: 0;
}

.carousel-next {
    right: 0;
}

.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.carousel-dot.active {
    background: white;
    transform: scale(1.2);
}

/* --- Swipe Mode Styles --- */
.swipe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f2f5;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.swipe-header {
    position: absolute;
    top: 0;
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.close-swipe-btn {
    position: absolute;
    left: 20px;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

.card-stack {
    position: relative;
    width: 90%;
    max-width: 400px;
    height: 60vh;
    margin-top: 60px;
}

.swipe-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transform-origin: 50% 100%;
    transition: transform 0.3s ease;
    cursor: grab;
}

.swipe-card img {
    width: 100%;
    height: 75%;
    object-fit: cover;
    pointer-events: none;
}

.swipe-card-content {
    padding: 1rem;
    height: 25%;
    background: white;
}

.swipe-controls {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

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

.swipe-action-btn.pass {
    background: white;
    color: #ff4b60;
    border: 2px solid #ff4b60;
}

.swipe-action-btn.like {
    background: white;
    color: #2ecc71;
    border: 2px solid #2ecc71;
}

.swipe-action-btn:hover {
    transform: scale(1.1);
}

.gender-btn {
    padding: 1rem 2rem;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Status Badge on Card */
.swipe-status {
    position: absolute;
    top: 40px;
    padding: 0.5rem 1rem;
    border: 4px solid;
    border-radius: 10px;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    opacity: 0;
    transform: rotate(-15deg);
}

.swipe-status.nope {
    right: 40px;
    color: #ff4b60;
    border-color: #ff4b60;
    transform: rotate(15deg);
}

.swipe-status.like {
    left: 40px;
    color: #2ecc71;
    border-color: #2ecc71;
    transform: rotate(-15deg);
}

/* Modal Details */
.modal-details {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    color: var(--text-color);
    background-color: var(--card-bg);
}

.modal-details h2 {
    color: var(--primary-color);
    margin-top: 0;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.8rem;
    margin-bottom: 1.2rem;
    font-size: 1.2rem;
    color: var(--text-color);
    font-weight: 700;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.detail-item {
    font-size: 1rem;
    line-height: 1.5;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        box-sizing: border-box;
    }

    .modal-content {
        flex-direction: column;
        height: 100vh;
        max-height: 100vh;
        width: 100%;
        border-radius: 0;
    }

    .modal-image-container {
        flex: none;
        height: 40vh;
    }

    .modal-details {
        padding: 1.5rem;
    }
}