/**
 * Result Form Search Modal Styles
 */

:root {
    /* Light Mode (Default) Variables */
    --mrt-bg-card: #ffffff;
    --mrt-bg-input: #f8f9fa;
    --mrt-border-input: #e2e8f0;
    --mrt-text-primary: #1a202c;
    --mrt-text-secondary: #718096;
    --mrt-text-muted: #a0aec0;
    --mrt-border-subtle: #edf2f7;
    --mrt-border-highlight: #cbd5e0;
    --mrt-bg-chip: #f1f5f9;
    --mrt-acc-blue: #3b82f6;
}

html.maxreptracker-dark-mode-enabled {
    /* Dark Mode Variables */
    --mrt-bg-card: #1e1e1e;
    --mrt-bg-input: #2c2c2c;
    --mrt-border-input: #3e3e3e;
    --mrt-text-primary: #ffffff;
    --mrt-text-secondary: #a0a0a0;
    --mrt-text-muted: #555555;
    --mrt-border-subtle: rgba(255, 255, 255, 0.1);
    --mrt-border-highlight: rgba(255, 255, 255, 0.2);
    --mrt-bg-chip: #2a2a2a;
    /* acc-blue remains same or adjust if needed */
}

/* Ensure darker defaults are overridden by variables if they were hardcoded */
.mrt-search-modal-content {
    background: var(--mrt-bg-card, #ffffff);
    color: var(--mrt-text-primary, #1a202c);
}

/* Modal Overlay */
.mrt-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Mobile bottom sheet style */
    opacity: 0;
    animation: mrtFadeIn 0.2s forwards;
}

@media (min-width: 768px) {
    .mrt-modal-overlay {
        align-items: center;
    }
}

/* Modal Content */
.mrt-search-modal-content {
    background: var(--mrt-bg-card, #1e1e1e);
    width: 100%;
    max-width: 600px; /* Slightly wider for grid */
    height: calc(100% - 40px); /* Fixed small top margin for mobile */
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    animation: mrtSlideUp 0.3s forwards;
    overflow: hidden;
}

@media (min-width: 768px) {
    .mrt-search-modal-content {
        height: 85vh;
        border-radius: 16px;
        transform: translateY(20px);
        animation: mrtFadeSlideIn 0.3s forwards;
    }
}

/* Header */
.mrt-modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--mrt-border-subtle, rgba(255, 255, 255, 0.1));
}

.mrt-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--mrt-text-primary, #ffffff);
}

.mrt-modal-close {
    background: transparent;
    border: none;
    color: var(--mrt-text-secondary, #a0a0a0);
    width: 32px;
    height: 32px;
    padding: 4px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}

.mrt-modal-close:hover {
    background: var(--mrt-bg-chip, rgba(255, 255, 255, 0.1));
    color: var(--mrt-text-primary, #fff);
}

/* Search Bar */
.mrt-search-bar-container {
    padding: 20px 20px 0px 20px;
}

.mrt-search-input-wrapper {
    position: relative;
    /* Removed display: flex to rely on standard absolute positioning relative to input height */
}

.mrt-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--mrt-text-secondary, #a0a0a0);
    pointer-events: none;
}

#mrt-exercise-search-input {
    width: 100%;
    background: var(--mrt-bg-input, #2c2c2c);
    border: 1px solid var(--mrt-border-input, #3e3e3e);
    border-radius: 18px;
    padding: 12px 56px 12px 56px !important; /* Force padding to prevent override and fix overlap */
    color: var(--mrt-text-primary, #fff);
    font-size: 1rem;
    transition: all 0.2s;
}

#mrt-exercise-search-input:focus {
    border-color: none;
    outline: none;
    box-shadow: none;
}

#mrt-search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--mrt-text-secondary, #a0a0a0);
    width: 24px;
    height: 24px;
    padding: 2px;
    cursor: pointer;
}

/* Filters */
.mrt-search-filters {
    padding: 15px 20px 20px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll */
    scrollbar-width: none;
    user-select: none;
}
.mrt-search-filters::-webkit-scrollbar {
    display: none;
}

.mrt-filter-pill {
    background: var(--mrt-bg-chip, #2a2a2a);
    border: 1px solid var(--mrt-border-subtle, rgba(255, 255, 255, 0.1));
    color: var(--mrt-text-secondary, #a0a0a0);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.mrt-filter-pill.active {
    background: var(--mrt-acc-blue, #3b82f6);
    color: #fff;
    border-color: var(--mrt-acc-blue, #3b82f6);
}

/* Results Grid */
.mrt-search-results-grid {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 10px 20px 20px 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    align-content: start;
}

@media (min-width: 768px) {
    .mrt-search-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Result Card */
/* Result Card - Styled to match mrt-el-card */
.mrt-search-result-card {
    background: transparent;
    border: 1px solid var(--mrt-border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: 18px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    min-height: auto; /* Let content dictate height */
}

.mrt-search-result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: var(--mrt-border-highlight, rgba(255, 255, 255, 0.2));
}

.mrt-result-card-image {
    width: 100%;
    /* Removed aspect-ratio to match mrt-el-card natural height */
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-radius: 18px;
    margin-bottom: 12px;
    transition: opacity 0.3s ease;
}

.mrt-result-card-image:hover {
    opacity: 0.9;
}

.mrt-result-card-image img {
    width: 100%;
    height: auto; /* Allow natural height to prevent cutting off, consistent with mrt-el-card */
    object-fit: contain;
}

.mrt-card-no-image {
    color: var(--mrt-text-muted, #555);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    padding: 20px 0; /* Add padding since height is auto now */
}

.mrt-image-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    font-weight: bold;
}

.mrt-logged-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--mrt-acc-blue, #3b82f6);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 2;
    animation: mrtFadeScaleIn 0.2s ease-out;
}

@keyframes mrtFadeScaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mrt-result-card-info {
    padding: 0;
}

.mrt-result-card-title {
    margin: 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--mrt-text-primary, #fff);
    line-height: 1.3;
    transition: color 0.2s ease;
}

.mrt-search-result-card:hover .mrt-result-card-title {
    color: var(--mrt-acc-blue, #4da3ff);
}

.mrt-result-card-subtitle {
    display: block;
    font-size: 14px;
    color: var(--mrt-text-secondary, #aaa);
    line-height: 1.4;
}

/* No Results */
.mrt-search-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--mrt-text-secondary, #a0a0a0);
}

/* Animations */
@keyframes mrtFadeIn {
    to {
        opacity: 1;
    }
}

@keyframes mrtSlideUp {
    to {
        transform: translateY(0);
    }
}

@keyframes mrtFadeSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
