/**
 * Event Tracker - Frontend Styles
 * Based on Tailwind CSS design system
 * Spacing: 4px base unit (4, 8, 12, 16, 20, 24, 32, 40, 48)
 * Typography: 12, 14, 16, 18, 20, 24px
 */

/* =========================================================================
   EVENT LIST
   ========================================================================= */

.tr-event-list {
    margin: 24px 0;
}

.tr-event-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
    gap: 24px !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Event Card */
.tr-event-card {
    display: block !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    transition: box-shadow 0.2s ease;
    float: none !important;
    width: auto !important;
}

.tr-event-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tr-event-card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #f3f4f6;
}

.tr-event-card-content {
    padding: 16px;
}

.tr-event-card-title {
    margin: 8px 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.tr-event-card-title a {
    color: #111827;
    text-decoration: none;
}

.tr-event-card-title a:hover {
    color: #4f46e5;
}

.tr-event-card-meta {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.tr-event-card-meta span {
    display: block;
}

/* =========================================================================
   STATUS BADGES
   ========================================================================= */

.tr-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.tr-status-registered {
    background: #dbeafe;
    color: #1d4ed8;
}

.tr-status-completed {
    background: #dcfce7;
    color: #15803d;
}

.tr-status-dns {
    background: #fef3c7;
    color: #b45309;
}

.tr-status-dnf {
    background: #fce7f3;
    color: #be185d;
}

.tr-status-cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

/* =========================================================================
   SINGLE EVENT VIEW
   ========================================================================= */

.tr-event-single {
    max-width: 720px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #111827;
}

/* Reset theme spacing and typography */
.tr-event-single *,
.tr-event-single *::before,
.tr-event-single *::after {
    box-sizing: border-box;
}

.tr-event-single h1,
.tr-event-single h2,
.tr-event-single h3,
.tr-event-single h4,
.tr-event-single p,
.tr-event-single ul,
.tr-event-single li,
.tr-event-single div,
.tr-event-single span {
    margin: 0;
    padding: 0;
    font-family: inherit;
    line-height: inherit;
}

.tr-event-single ul {
    list-style: none;
}

/* Back Link */
.tr-back-link {
    margin-bottom: 16px;
}

.tr-back-link a {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.15s ease;
}

.tr-back-link a:hover {
    color: #111827;
}

/* Event Header */
.tr-event-header {
    margin-bottom: 24px;
}

.tr-event-header .tr-status-badge {
    margin-bottom: 8px;
}

.tr-event-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #111827;
    line-height: 1.25;
}

.tr-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* Event Photo */
.tr-event-photo {
    width: 100%;
    max-width: 480px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 32px;
}

/* Event Sections */
.tr-event-section {
    margin-bottom: 32px;
    padding: 20px 24px;
    background: #f9fafb;
    border-radius: 8px;
}

.tr-event-section h2 {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.tr-event-description {
    line-height: 1.625;
    color: #374151;
    font-size: 14px;
}

.tr-event-description p {
    margin-bottom: 12px;
}

.tr-event-description p:last-child {
    margin-bottom: 0;
}

/* Event Links */
.tr-event-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tr-event-links a {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #4f46e5;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.tr-event-links a:hover {
    background: #4338ca;
}

/* =========================================================================
   RESULTS SECTION
   ========================================================================= */

.tr-results-section {
    margin-bottom: 32px;
}

.tr-results-section > h2 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

/* Participant Result Card */
.tr-participant-result {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.tr-participant-result:last-child {
    margin-bottom: 0;
}

.tr-participant-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
}

/* Race Result */
.tr-race-result {
    margin-bottom: 20px;
}

.tr-race-result:last-child {
    margin-bottom: 0;
}

.tr-race-result.tr-multi-race {
    padding: 16px 20px;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 3px solid #4f46e5;
}

.tr-race-type-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
}

/* Result Stats Grid */
.tr-result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.tr-result-stat {
    text-align: center;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 6px;
    min-width: 80px;
}

.tr-result-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.tr-result-stat-label {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Placement Badges */
.tr-result-placements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tr-placement-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 6px;
    font-size: 13px;
}

/* Result Links */
.tr-result-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.tr-result-links a {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #4f46e5;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.tr-result-links a:hover {
    background: #4338ca;
}

/* Result Images */
.tr-result-images {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.tr-result-image-item {
    text-align: center;
}

.tr-result-image-item img {
    max-width: 160px;
    height: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: opacity 0.15s ease;
}

.tr-result-image-item img:hover {
    opacity: 0.8;
}

.tr-result-image-label {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

/* =========================================================================
   EMPTY STATE
   ========================================================================= */

.tr-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
    font-size: 14px;
}

/* =========================================================================
   COMPACT LIST LAYOUT
   ========================================================================= */

.tr-layout-compact .tr-compact-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tr-layout-compact .tr-compact-item {
    border-bottom: 1px solid #e5e7eb;
}

.tr-layout-compact .tr-compact-item:last-child {
    border-bottom: none;
}

.tr-layout-compact .tr-compact-link {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.tr-layout-compact .tr-compact-link:hover {
    background: #f9fafb;
    margin: 0 -12px;
    padding: 16px 12px;
}

.tr-layout-compact .tr-compact-date {
    min-width: 100px;
    color: #6b7280;
    font-size: 14px;
}

.tr-layout-compact .tr-compact-name {
    flex: 1;
    font-weight: 600;
    color: #4f46e5;
    font-size: 14px;
}

.tr-layout-compact .tr-compact-link:hover .tr-compact-name {
    text-decoration: underline;
}

.tr-layout-compact .tr-compact-location {
    color: #9ca3af;
    font-size: 14px;
}

/* =========================================================================
   TABLE LAYOUT
   ========================================================================= */

.tr-layout-table .tr-events-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 14px;
}

.tr-layout-table .tr-events-table th,
.tr-layout-table .tr-events-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.tr-layout-table .tr-events-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.tr-layout-table .tr-events-table tbody tr:hover {
    background: #f9fafb;
}

.tr-layout-table .tr-events-table tbody tr:last-child td {
    border-bottom: none;
}

.tr-layout-table .tr-table-name a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.tr-layout-table .tr-table-name a:hover {
    text-decoration: underline;
}

.tr-layout-table .tr-table-date {
    white-space: nowrap;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media screen and (max-width: 640px) {
    .tr-event-grid {
        grid-template-columns: 1fr;
    }

    .tr-event-title {
        font-size: 20px;
    }

    .tr-event-meta {
        flex-direction: column;
        gap: 4px;
    }

    .tr-event-photo {
        max-width: 100%;
    }

    .tr-event-section {
        padding: 16px 20px;
    }

    .tr-participant-result {
        padding: 16px 20px;
    }

    .tr-result-stat {
        min-width: 70px;
        padding: 10px 12px;
    }

    .tr-result-stat-value {
        font-size: 16px;
    }

    .tr-layout-compact .tr-compact-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .tr-layout-compact .tr-compact-date {
        min-width: auto;
    }

    .tr-layout-table .tr-events-table {
        display: block;
        overflow-x: auto;
    }
}

/* =========================================================================
   PARTICIPANT RESULTS - SHARED STYLES
   ========================================================================= */

.tr-participant-results {
    margin: 24px 0;
}

.tr-participant-stats {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
}

.tr-participant-stats .tr-stat {
    margin-right: 20px;
}

.tr-participant-stats .tr-stat strong {
    color: #111827;
    font-size: 18px;
}

.tr-error {
    padding: 16px;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 6px;
    font-size: 14px;
}

.tr-empty {
    padding: 32px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* =========================================================================
   PARTICIPANT RESULTS - LIST VIEW
   ========================================================================= */

.tr-participant-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
}

.tr-participant-table th,
.tr-participant-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.tr-participant-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    white-space: nowrap;
}

.tr-participant-table tbody tr:hover {
    background: #f9fafb;
}

.tr-participant-table tbody tr:last-child td {
    border-bottom: none;
}

.tr-participant-table .tr-event-link {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.tr-participant-table .tr-event-link:hover {
    text-decoration: underline;
}

.tr-participant-table .tr-col-event {
    min-width: 180px;
}

.tr-participant-table .tr-col-date {
    white-space: nowrap;
    color: #6b7280;
}

.tr-participant-table .tr-col-race .tr-race-type {
    display: inline-block;
    padding: 2px 8px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tr-participant-table .tr-col-time strong {
    color: #111827;
}

.tr-participant-table .tr-col-pace {
    color: #6b7280;
}

.tr-participant-table .tr-col-place .tr-place {
    font-weight: 600;
    color: #111827;
}

.tr-participant-table .tr-col-place .tr-place-total {
    color: #9ca3af;
    font-size: 11px;
}

.tr-participant-table .tr-col-place .tr-place-pct {
    color: #6b7280;
    font-size: 11px;
}

.tr-participant-table .tr-no-data {
    color: #d1d5db;
}

.tr-participant-table .tr-status-badge {
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 10px;
}

.tr-result-row-dns,
.tr-result-row-dnf,
.tr-result-row-cancelled {
    opacity: 0.6;
}

/* =========================================================================
   PARTICIPANT RESULTS - GRID VIEW
   ========================================================================= */

.tr-participant-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.tr-participant-grid .tr-participant-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.tr-participant-grid .tr-participant-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tr-participant-grid .tr-participant-card.tr-status-dns,
.tr-participant-grid .tr-participant-card.tr-status-dnf,
.tr-participant-grid .tr-participant-card.tr-status-cancelled {
    opacity: 0.7;
}

.tr-participant-grid .tr-card-image {
    display: block;
}

.tr-participant-grid .tr-card-image img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.tr-participant-grid .tr-card-content {
    padding: 16px;
}

.tr-participant-grid .tr-card-header {
    margin-bottom: 8px;
}

.tr-participant-grid .tr-card-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    line-height: 1.3;
}

.tr-participant-grid .tr-card-title:hover {
    color: #4f46e5;
}

.tr-participant-grid .tr-card-meta {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.tr-participant-grid .tr-card-meta .tr-separator {
    margin: 0 6px;
}

.tr-participant-grid .tr-card-meta .tr-race-type {
    color: #4f46e5;
    font-weight: 500;
}

.tr-participant-grid .tr-card-time {
    margin-bottom: 12px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
    text-align: center;
}

.tr-participant-grid .tr-time-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.tr-participant-grid .tr-pace-value {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.tr-participant-grid .tr-card-placements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tr-participant-grid .tr-placement {
    flex: 1;
    min-width: 80px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 6px;
    text-align: center;
}

.tr-participant-grid .tr-placement-label {
    display: block;
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.tr-participant-grid .tr-placement-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.tr-participant-grid .tr-placement-value .tr-of {
    font-weight: 400;
    color: #9ca3af;
    font-size: 11px;
}

.tr-participant-grid .tr-placement-bar {
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.tr-participant-grid .tr-placement-fill {
    height: 100%;
    background: #4f46e5;
    border-radius: 2px;
}

.tr-participant-grid .tr-status-badge {
    margin-top: 6px;
    font-size: 10px;
}

/* =========================================================================
   PARTICIPANT RESULTS - RESPONSIVE
   ========================================================================= */

@media screen and (max-width: 768px) {
    .tr-participant-table {
        display: block;
        overflow-x: auto;
    }

    .tr-participant-cards {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   PERSONAL BESTS
   ========================================================================= */

.tr-personal-bests {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e5e7eb;
}

.tr-pb-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 16px 0;
}

.tr-pb-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.tr-pb-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 16px;
    min-width: 160px;
    flex: 0 1 auto;
}

.tr-pb-event-type {
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.tr-pb-time {
    font-size: 24px;
    font-weight: 700;
    color: #78350f;
    line-height: 1.2;
}

.tr-pb-pace {
    font-size: 13px;
    color: #92400e;
    margin-top: 2px;
}

.tr-pb-event {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(245, 158, 11, 0.3);
}

.tr-pb-event a {
    font-size: 13px;
    color: #78350f;
    text-decoration: none;
    display: block;
    line-height: 1.3;
}

.tr-pb-event a:hover {
    text-decoration: underline;
}

.tr-pb-date {
    font-size: 12px;
    color: #92400e;
    display: block;
    margin-top: 2px;
}

@media screen and (max-width: 480px) {
    .tr-pb-cards {
        flex-direction: column;
    }

    .tr-pb-card {
        min-width: auto;
        width: 100%;
    }
}

/* Personal Best Badge (inline on results) */
.tr-pb-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.3);
}

.tr-card-time .tr-pb-badge {
    margin-left: 6px;
}

.tr-col-time .tr-pb-badge {
    margin-left: 6px;
}

/* Personal Best Star (on event lists) */
.tr-pb-star {
    display: inline-block;
    color: #f59e0b;
    font-size: 14px;
    margin-left: 4px;
    vertical-align: middle;
    cursor: help;
    text-shadow: 0 1px 2px rgba(217, 119, 6, 0.3);
}

.tr-event-card-title .tr-pb-star {
    font-size: 12px;
}

.tr-compact-name .tr-pb-star {
    font-size: 11px;
}

.tr-table-name .tr-pb-star {
    font-size: 12px;
}
