/* MyRaceHub - Shared Component Library
   Unified UI components for consistent styling across all pages
   ============================================================ */

/* ============================================================================
   STAT CARDS
   Used on: My Calendar, Athlete Dashboard, My Results
   ============================================================================ */

.stat-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    text-align: center;
    transition: all var(--transition-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ocean-deep), var(--ocean-bright));
    opacity: 0;
    transition: opacity var(--transition-normal) var(--ease-out);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-number {
    display: block;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--ocean-deep), var(--ocean-bright));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Stat card with animation (dashboard/results) */
.stat-card--animated {
    animation: popIn 0.5s var(--ease-bounce) both;
}

.stat-card--animated:nth-child(1) { animation-delay: 0.1s; }
.stat-card--animated:nth-child(2) { animation-delay: 0.15s; }
.stat-card--animated:nth-child(3) { animation-delay: 0.2s; }
.stat-card--animated:nth-child(4) { animation-delay: 0.25s; }

/* Stat card accent variant */
.stat-card--accent {
    border-color: var(--sunset-orange);
}

/* Stats bar container */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .stat-card {
        padding: 14px 12px;
    }

    .stat-card .stat-number {
        font-size: 1.5rem;
    }

    .stat-card .stat-label {
        font-size: 0.65rem;
    }

    .stats-bar {
        gap: 10px;
    }
}

/* ============================================================================
   DATA TABLES
   Base table styling used across: My Calendar, Athlete Dashboard, My Results
   ============================================================================ */

.table-container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-family: var(--font-body);
}

.data-table thead {
    background: linear-gradient(135deg, var(--ocean-deep) 0%, var(--ocean-bright) 100%);
}

.data-table th {
    padding: 14px 18px;
    text-align: left;
    font-weight: 600;
    color: white;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: linear-gradient(135deg, rgba(79, 179, 217, 0.08) 0%, rgba(0, 78, 137, 0.05) 100%);
}

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

/* Row status indicators */
.data-table tbody tr.row-planning {
    border-left: 4px solid var(--status-planning-border);
}

.data-table tbody tr.row-registered {
    border-left: 4px solid var(--status-completed-border);
}

.data-table tbody tr.row-waitlisted {
    border-left: 4px solid var(--status-registered-border);
}

.data-table tbody tr.row-withdrew {
    border-left: 4px solid var(--status-skipped-border);
    background: var(--surface-light);
    opacity: 0.7;
}

/* Featured rows */
.data-table tbody tr.featured-gold {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
}

.data-table tbody tr.featured-gold:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

.data-table tbody tr.featured-silver {
    background: #f8fafc;
    border-left: 4px solid #94a3b8;
}

.data-table tbody tr.featured-silver:hover {
    background: #f1f5f9;
}

.data-table tbody tr.featured-bronze {
    border-left: 4px solid #d97706;
}

/* Row animations */
.data-table tbody tr.animate-row {
    animation: fadeInRow 0.4s var(--ease-out) both;
}

.data-table tbody tr.animate-row:nth-child(1) { animation-delay: 0.05s; }
.data-table tbody tr.animate-row:nth-child(2) { animation-delay: 0.1s; }
.data-table tbody tr.animate-row:nth-child(3) { animation-delay: 0.15s; }
.data-table tbody tr.animate-row:nth-child(4) { animation-delay: 0.2s; }
.data-table tbody tr.animate-row:nth-child(5) { animation-delay: 0.25s; }

@media (max-width: 768px) {
    .data-table th,
    .data-table td {
        padding: 12px 14px;
        font-size: 0.85rem;
    }
}

/* ============================================================================
   MODALS
   Standard modal pattern for popups/dialogs
   ============================================================================ */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 37, 64, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 78, 137, 0.3);
    animation: modalSlideIn 0.3s var(--ease-out);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-box h2 {
    margin: 0 0 24px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ocean-deep);
}

.modal-actions {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--surface);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* ============================================================================
   FORM CONTROLS
   Unified form styling for inputs, selects, textareas
   ============================================================================ */

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-body);
    box-sizing: border-box;
    transition: all var(--transition-fast);
    background: var(--surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--ocean-bright);
    box-shadow: 0 0 0 3px rgba(26, 127, 160, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

/* Filter select - compact dropdown with custom arrow */
.filter-select {
    padding: 10px 36px 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: var(--font-body);
    font-weight: 500;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235A6C7D' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all var(--transition-fast);
}

.filter-select:hover {
    border-color: var(--ocean-light);
}

.filter-select:focus {
    outline: none;
    border-color: var(--ocean-bright);
    box-shadow: 0 0 0 3px rgba(26, 127, 160, 0.15);
}

/* Filter checkbox */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-checkbox:hover {
    background: var(--surface);
    border-color: var(--ocean-light);
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ocean-bright);
}

.filter-checkbox span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================================================
   DISTANCE BADGES
   Pill-style badges for race distances
   ============================================================================ */

.distance-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--sunset-orange), var(--sunset-coral));
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3);
}

.distance-badge--small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ============================================================================
   PB BADGES
   Personal best indicators
   ============================================================================ */

.pb-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pb-badge--current {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
}

.pb-badge--former {
    background: #e5e7eb;
    color: #6b7280;
}

/* ============================================================================
   PAGINATION
   Page navigation controls
   ============================================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.pagination-btn {
    padding: 10px 18px;
    border: 2px solid var(--ocean-bright);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--ocean-bright);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.pagination-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--ocean-deep), var(--ocean-bright));
    color: white;
    box-shadow: var(--shadow-md);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================================
   SOCIAL SHARE BUTTONS
   Social media sharing buttons with brand colors
   ============================================================================ */

.social-share-buttons {
    display: flex;
    gap: 4px;
}

.social-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-btn:hover {
    transform: scale(1.1);
}

.social-btn.facebook { background: #1877f2; }
.social-btn.twitter { background: #000000; }
.social-btn.linkedin { background: #0a66c2; }
.social-btn.whatsapp { background: #25d366; }
.social-btn.email { background: #6b7280; }

.social-btn.facebook:hover { background: #1565d8; }
.social-btn.twitter:hover { background: #333333; }
.social-btn.linkedin:hover { background: #094d92; }
.social-btn.whatsapp:hover { background: #1da855; }
.social-btn.email:hover { background: #4b5563; }

/* ============================================================================
   ANIMATIONS
   Shared keyframe animations
   ============================================================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================================
   REDUCED MOTION
   Respect user preferences for reduced motion
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .stat-card--animated,
    .data-table tbody tr.animate-row,
    .modal-box {
        animation: none !important;
        transition: none !important;
    }

    .stat-card:hover,
    .pagination-btn:hover,
    .social-btn:hover {
        transform: none !important;
    }
}
