:root {
    --color-bg: #0d1117;
    --color-surface: #161b22;
    --color-surface-elevated: #21262d;
    --color-border: #30363d;
    --color-accent: #d4a574;
    --color-accent-hover: #e8c49a;
    --color-text: #e6edf3;
    --color-text-muted: #8b949e;
    --color-success: #3fb950;
    --color-warning: #d29922;
    --color-danger: #f85149;
    --color-male: #58a6ff;
    --color-female: #f778ba;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.6);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Sans Pro', -apple-system, sans-serif;
}

/* Light Theme */
[data-theme="light"] {
    --color-bg: #ffffff;
    --color-surface: #f6f8fa;
    --color-surface-elevated: #ffffff;
    --color-border: #d0d7de;
    --color-accent: #8b6914;
    --color-accent-hover: #6d5210;
    --color-text: #1f2328;
    --color-text-muted: #656d76;
    --color-success: #1a7f37;
    --color-warning: #9a6700;
    --color-danger: #cf222e;
    --color-male: #0969da;
    --color-female: #bf3989;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.2);
}

/* Theme toggle button */
.theme-toggle {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: all 0.2s;
}

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

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-text);
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-accent-hover);
}

/* Header */
.header {
    background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: invert(1) grayscale(1);
}

[data-theme="light"] .logo-img {
    filter: invert(0) grayscale(0);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-accent) 0%, #8b6914 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-accent);
}

.logo p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-bg);
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    color: var(--color-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--color-surface-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-border);
    color: var(--color-text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Main Container */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.page-header .update-info {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Breed Books Grid */
.breed-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.breed-book-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.breed-book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-color, var(--color-accent));
}

.breed-book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color, var(--color-accent));
}

.breed-book-icon {
    width: 100%;
    height: 60px;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: var(--color-bg);
}

.breed-book-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

[data-theme="light"] .breed-book-icon img {
    filter: invert(1);
}

.breed-book-card h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 1rem;
    line-height: 1.3;
}

.breed-book-links {
    display: flex;
    gap: 0.75rem;
}

.breed-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all 0.2s;
}

.breed-link.stallions {
    background-color: rgba(88, 166, 255, 0.1);
    color: var(--color-male);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.breed-link.stallions:hover {
    background-color: rgba(88, 166, 255, 0.2);
    color: var(--color-male);
}

.breed-link.mares {
    background-color: rgba(247, 120, 186, 0.1);
    color: var(--color-female);
    border: 1px solid rgba(247, 120, 186, 0.3);
}

.breed-link.mares:hover {
    background-color: rgba(247, 120, 186, 0.2);
    color: var(--color-female);
}

/* Info Section */
.info-section {
    margin-top: 2rem;
}

.info-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.info-card h3 {
    font-family: var(--font-display);
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--color-accent);
}

.info-card p {
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

.info-card p:last-child {
    margin-bottom: 0;
}

/* Data Table */
.data-table-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.data-table-header h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--color-text);
}

.result-count {
    background-color: var(--color-accent);
    color: var(--color-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.data-table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background-color: var(--color-surface-elevated);
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: var(--color-surface-elevated);
}

.data-table .horse-name {
    font-weight: 600;
    color: var(--color-accent);
}

.data-table .horse-photo {
    width: 60px;
    height: 45px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background-color: var(--color-surface-elevated);
}

.data-table .row-number {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    width: 40px;
}

/* Horse Card */
.horse-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.horse-card-header {
    background: linear-gradient(135deg, var(--color-surface-elevated) 0%, var(--color-surface) 100%);
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

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

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--color-accent);
}

.horse-photo-large {
    width: 280px;
    height: 210px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background-color: var(--color-bg);
    border: 2px solid var(--color-border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.horse-photo-large:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.horse-header-info {
    flex: 1;
    min-width: 250px;
}

.horse-header-info h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.horse-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.meta-item .label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.meta-item .value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Horse Sections */
.horse-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.horse-section {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.horse-section h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: var(--color-text-muted);
}

.detail-row .value {
    color: var(--color-text);
    font-weight: 500;
    text-align: right;
}

.detail-row .value a {
    color: var(--color-accent);
}

/* Pedigree Table */
.pedigree-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.pedigree-table td {
    border: 1px solid var(--color-border);
    padding: 0.5rem;
    vertical-align: middle;
    text-align: center;
}

.pedigree-table a {
    display: block;
    color: var(--color-text);
    transition: color 0.2s;
}

.pedigree-table a:hover {
    color: var(--color-accent);
}

.pedigree-table .male {
    background-color: rgba(88, 166, 255, 0.1);
}

.pedigree-table .female {
    background-color: rgba(247, 120, 186, 0.1);
}

/* Search Form */
.search-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.search-container h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--color-accent);
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-field {
    flex: 1;
    min-width: 200px;
}

.search-field label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 0.375rem;
}

.search-field input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
}

.search-field input::placeholder {
    color: var(--color-text-muted);
}

/* Breeding Table */
.breeding-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.breeding-table th {
    background-color: var(--color-surface-elevated);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.6875rem;
}

.breeding-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.breeding-table tbody tr:hover {
    background-color: var(--color-surface-elevated);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--color-text-muted);
}

.breadcrumb a:hover {
    color: var(--color-accent);
}

.breadcrumb span {
    color: var(--color-text-muted);
}

.breadcrumb .current {
    color: var(--color-text);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .main-container {
        padding: 1rem;
    }

    .breed-books-grid {
        grid-template-columns: 1fr;
    }

    .horse-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .horse-sections {
        grid-template-columns: 1fr;
    }

    .search-row {
        flex-direction: column;
    }

    .search-field {
        width: 100%;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-muted);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
