/* ─── Header ─────────────────────────────────────────────────────────────── */

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #1a2c42 0%, #2d4a6e 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    padding: 0;
}

.header-placeholder {
    height: 70px;
}

header .container {
    height: 70px;
    gap: 1.5rem;
}

header a {
    text-decoration: none;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.desktop-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.desktop-nav ul li {
    display: flex;
    align-items: center;
}

.desktop-nav ul li a,
.desktop-nav ul li .plain-button {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.desktop-nav ul li a:hover,
.desktop-nav ul li .plain-button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.hamburger-menu-toggle {
    display: none;
    cursor: pointer;
}

/* ─── Header Right (username + nav stacked) ──────────────────────────────── */

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.1rem;
}

.header-username {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
    letter-spacing: 0.04em;
    white-space: nowrap;
    padding-right: 0.2rem;
}

/* ─── Flash Messages ─────────────────────────────────────────────────────── */

.flash-message {
    padding: 0.8rem 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.flash-message.success {
    background: #d1fae5;
    color: #065f46;
    border-bottom: 1px solid #6ee7b7;
}

.flash-message.error {
    background: #fee2e2;
    color: #991b1b;
    border-bottom: 1px solid #fca5a5;
}

.flash-message.warning {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
}

.flash-message.info {
    background: #dbeafe;
    color: #1e40af;
    border-bottom: 1px solid #93c5fd;
}

.flash-message.debug {
    background: #f3f4f6;
    color: #374151;
    border-bottom: 1px solid #d1d5db;
}

/* ─── Horse Info Card ────────────────────────────────────────────────────── */

.horse-info-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #dee2e6;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.horse-info-card--male {
    border-color: #bfdbfe;
}

.horse-info-card--female {
    border-color: #fbcfe8;
}

.horse-info-card__header {
    padding: 1rem 1.25rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.horse-info-card__header--male {
    background: linear-gradient(90deg, #dbeafe 0%, #f0f6ff 100%);
    border-bottom-color: #bfdbfe;
}

.horse-info-card__header--female {
    background: linear-gradient(90deg, #fce7f3 0%, #fff0f7 100%);
    border-bottom-color: #fbcfe8;
}

.horse-info-card__name {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a2c42;
    margin: 0;
    line-height: 1.2;
}

.horse-sex-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2em 0.7em;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.horse-sex-badge--male {
    background: #2563eb;
    color: #fff;
}

.horse-sex-badge--female {
    background: #db2777;
    color: #fff;
}

.horse-info-card__body {
    padding: 1rem 1.25rem;
}

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

.horse-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.horse-info-item__label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
}

.horse-info-item__value {
    font-size: 0.9rem;
    color: #212529;
    font-weight: 500;
}

.verified-check {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.3em;
    fill: #16a34a;
    flex-shrink: 0;
}

/* ─── Pedigree Table ─────────────────────────────────────────────────────── */

.pedigree-wrapper {
    overflow-x: auto;
}

.pedigree-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
    min-width: 500px;
}

.pedigree-col-header {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    text-align: center;
    font-size: 0.85rem;
    color: #495057;
}

.pedigree-cell {
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    background: #fff;
    font-size: 0.875rem;
    transition: background 0.15s;
}

.pedigree-cell:hover {
    background: #f8faff;
}

.pedigree-cell--empty {
    background: #f8f9fa;
    color: #adb5bd;
    vertical-align: middle;
    text-align: center;
    font-style: italic;
}

/* Sex-based left indicator — drawn fully inside the cell */
.pedigree-cell.sex-M {
    box-shadow: inset 3px 0 0 0 #7fa3ff;
}

.pedigree-cell.sex-F {
    box-shadow: inset 3px 0 0 0 #ff8fc3;
}

.pedigree-cell__name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.pedigree-cell__name a {
    color: inherit;
    text-decoration: none;
}

.pedigree-cell__name a:hover {
    text-decoration: underline;
    color: #0d6efd;
}

.pedigree-cell__name--compact {
    font-size: 0.8rem;
    margin-bottom: 0.15rem;
}

.pedigree-cell__details {
    font-size: 0.8rem;
    color: #495057;
    line-height: 1.5;
}

.pedigree-cell__details--compact {
    font-size: 0.72rem;
    color: #6c757d;
}

.pedigree-label {
    font-weight: 600;
    color: #343a40;
    margin-right: 0.2em;
}

.pedigree-cell__unknown {
    font-style: italic;
    color: #adb5bd;
    font-size: 0.8rem;
}

/* ─── Horse Photos Strip ─────────────────────────────────────────────────── */

.horse-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #e9ecef;
}

.horse-photo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.horse-photo-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
}

.horse-photo-thumb-link {
    display: block;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #dee2e6;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.horse-photo-thumb-link:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

.horse-photo-thumb {
    display: block;
    width: 160px;
    height: 120px;
    object-fit: cover;
}

/* ─── Horse List ─────────────────────────────────────────────────────────── */

/* Search form */
.horse-search {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
}

.horse-search__bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.horse-search__query {
    flex: 1 1 0;
    min-width: 0;
}

.horse-search__query .form-control {
    border-radius: 6px;
}

.horse-search__toggle {
    white-space: nowrap;
    flex-shrink: 0;
}

.horse-search__filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem 1rem;
    padding: 0 1rem 1rem;
    border-top: 1px solid #f0f0f0;
    padding-top: 0.75rem;
}

.horse-search__filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.horse-search__filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 0;
}

/* Record count */
.horse-list__meta {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.horse-list__meta strong {
    color: #212529;
}

/* Table wrapper — horizontal scroll on small screens */
.horse-list-wrapper {
    /* overflow: clip does not create a scroll container, so position: sticky
       on <th> elements remains relative to the page viewport.
       Unlike overflow: hidden/auto, clip never creates a BFC or scroll container. */
    overflow: clip;
    border: 1px solid #dee2e6;
    border-radius: 10px;
}

.horse-list-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.horse-list-th {
    /* Sticky: sits just below the fixed site header (70 px) */
    position: sticky;
    top: 70px;
    z-index: 1;
    background: linear-gradient(180deg, #f4f7fb 0%, #eaf0f8 100%);
    border-bottom: 2px solid #c8d6e8;
    padding: 0.65rem 0.9rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #344563;
    white-space: nowrap;
}

.sort-indicator {
    font-size: 0.7rem;
    opacity: 0.75;
    margin-left: 0.2em;
}

.horse-list-th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
}

.horse-list-th a:hover {
    color: #0d6efd;
}

/* Active sort column gets a subtle highlight */
.horse-list-th--sorted {
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
    border-bottom-color: #93c5fd;
    color: #1e40af;
}

.horse-list-td {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #f0f4f8;
    color: #212529;
    vertical-align: middle;
}

.horse-list-td a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.horse-list-td a:hover {
    text-decoration: underline;
}

/* Row hover */
.horse-list-row:hover .horse-list-td {
    background: #f5f8ff;
}

/* Last row — remove bottom border */
.horse-list-row:last-child .horse-list-td {
    border-bottom: none;
}

.horse-list-empty {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* ─── Pedigree Cell Photo ─────────────────────────────────────────────────── */

.pedigree-cell__photo {
    display: block;
    margin-top: 0.4rem;
    max-width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

