/* =========================================
   HORSE PROFILE & DATABASE STYLES
   ========================================= */

/* --- General Layout --- */
.container-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-secondary);
    display: inline-block;
}

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #eee;
}

/* --- Search Section --- */
.header-section {
    background: linear-gradient(135deg, var(--color-primary) 0%, #1a253a 100%);
    color: white;
    padding: 2.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--color-secondary);
}

.search-container {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.search-inputs {
    display: flex;
    gap: 0.5rem;
    position: relative;
    /* Anchor for absolute validation msg */
}

/* Error State */
.input-text.input-error {
    border-color: #dc3545;
    background-color: #fff8f8;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.search-validation-msg {
    position: absolute;
    bottom: -22px;
    left: 0;
    color: #ff6b6b;
    font-size: 0.8rem;
    font-weight: 600;
    animation: slideUp 0.2s ease-out;
}

.search-inputs button {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #aa8500 100%);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 1.5rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-inputs button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.search-inputs button:active {
    transform: translateY(0);
}

.input-text {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 0.95rem;
    background: white;
    color: #333;
    outline: none;
}

.search-select {
    background: #f8f9fa;
    cursor: pointer;
}

/* --- Profile Content Layout --- */
.profile-content {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

.profile-details-column {
    flex: 2;
    min-width: 300px;
}

.profile-image-column {
    flex: 1;
    min-width: 250px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.horse-image {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 4px solid white;
}

/* --- Tables (General) --- */
.table-container {
    overflow-x: auto;
}

.race-table,
.horse-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.race-table th,
.horse-list-table th {
    background: #f4f6f8;
    color: #555;
    font-weight: 600;
    text-align: left;
    padding: 0.8rem;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.race-table td,
.horse-list-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #eee;
    color: #333;
}

.horse-list-table tbody tr:hover {
    background-color: #f9fbfd;
}

/* --- Race Record Header Layout (NEW) --- */
.race-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Status Text ("Showing 10 runs") */
#history-status-text {
    font-size: 0.85rem;
    color: #666;
    background: #f0f0f0;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

/* --- Legend Button (NEW) --- */
.btn-legend {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

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

/* --- Replay Button Styling (NEW) --- */
.btn-replay {
    background-color: var(--color-secondary);
    /* Gold/Brand color */
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-replay:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    background-color: #d4a017;
    /* Darker gold on hover */
}

.btn-replay i {
    font-size: 0.7rem;
}

/* --- History Rows Highlighting --- */
.recent-form-row {
    background-color: rgba(var(--color-primary-rgb), 0.03);
    /* Very light tint */
    border-left: 3px solid var(--color-secondary);
}

.recent-form-row.latest-run {
    font-weight: 500;
    background-color: rgba(var(--color-primary-rgb), 0.06);
}

/* --- Load More Button --- */
.load-more-container {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.btn-load-more {
    background: white;
    border: 1px solid #ddd;
    color: #555;
    padding: 0.6rem 2rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-load-more:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: #f9f9f9;
}

/* --- Modals (Video & Legend) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

.video-modal-content {
    width: 90%;
    max-width: 800px;
}

.legend-modal-content {
    width: 90%;
    max-width: 600px;
}

.modal-header {
    padding: 1rem;
    background: #f4f4f4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #d00;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    background: black;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Legend Grid Styling --- */
.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border-bottom: 1px solid #f9f9f9;
}

.legend-key {
    background: #eee;
    color: #333;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    min-width: 45px;
    text-align: center;
    font-size: 0.8rem;
}

.legend-val {
    color: #555;
    font-size: 0.9rem;
}

.legend-footer {
    background: #f9f9f9;
    padding: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-note {
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
}

.legend-note i {
    margin-right: 0.4rem;
    color: var(--color-primary);
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

.font-bold {
    font-weight: 700;
}

.text-center {
    text-align: center;
}

.text-danger {
    color: #dc3545;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header-section {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }

    .search-container {
        flex-direction: column;
        width: 100%;
    }

    .search-inputs {
        width: 100%;
    }

    .input-text {
        width: 100%;
    }

    .race-record-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-right {
        width: 100%;
    }

    .btn-legend {
        width: 100%;
        justify-content: center;
    }
}