/**
 * Component Styles - Reusable UI Components
 * 
 * This file contains styles for all reusable components.
 * Import this file after base styles and before page-specific styles.
 */

/* ============================================
   CSS Custom Properties for Components
   ============================================ */

:root {
    /* Component Colors */
    --component-bg: rgba(0, 0, 0, 0.4);
    --component-border: rgba(255, 215, 0, 0.15);
    --component-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    
    /* State Colors */
    --state-loading-color: #3b82f6;
    --state-error-color: #ef4444;
    --state-success-color: #22c55e;
    --state-warning-color: #f59e0b;
    --state-info-color: #3b82f6;
    
    /* Component Spacing */
    --component-padding-sm: 0.5rem;
    --component-padding-md: 1rem;
    --component-padding-lg: 1.5rem;
    
    /* Component Border Radius */
    --component-radius-sm: 4px;
    --component-radius-md: 8px;
    --component-radius-lg: 12px;
}

/* ============================================
   Flag Image Component
   ============================================ */

.flag-image {
    display: inline-block;
    vertical-align: middle;
    object-fit: cover;
    border-radius: 2px;
}

.flag-image--xs { width: 16px; height: 12px; }
.flag-image--sm { width: 20px; height: 15px; }
.flag-image--md { width: 24px; height: 18px; }
.flag-image--lg { width: 32px; height: 24px; }
.flag-image--xl { width: 48px; height: 36px; }

.flag-image--rounded { border-radius: 50%; }
.flag-image--bordered { border: 1px solid var(--component-border); }

.flag-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background-color: #f3f4f6;
    border-radius: 2px;
}

.flag-placeholder--xs { width: 16px; height: 12px; font-size: 0.625rem; }
.flag-placeholder--sm { width: 20px; height: 15px; font-size: 0.75rem; }
.flag-placeholder--md { width: 24px; height: 18px; font-size: 0.875rem; }
.flag-placeholder--lg { width: 32px; height: 24px; font-size: 1rem; }
.flag-placeholder--xl { width: 48px; height: 36px; font-size: 1.5rem; }

/* ============================================
   Team Display Component
   ============================================ */

.team-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.team-display--horizontal {
    flex-direction: row;
}

.team-display--vertical {
    flex-direction: column;
    text-align: center;
}

.team-display--compact {
    gap: 0.25rem;
}

.team-display--flag-only .team-display__name {
    display: none;
}

.team-display__flag {
    flex-shrink: 0;
}

.team-display__name {
    font-weight: 500;
    white-space: nowrap;
}

.team-display--placeholder .team-display__name {
    color: #6b7280;
    font-style: italic;
}

.team-display--predicted .team-display__name {
    color: #059669;
}

.team-display--clickable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.team-display--clickable:hover {
    opacity: 0.8;
}

/* ============================================
   Match Card Component
   ============================================ */

.match-card {
    display: flex;
    flex-direction: column;
    padding: var(--component-padding-md);
    background-color: var(--component-bg);
    border: 1px solid var(--component-border);
    border-radius: var(--component-radius-md);
    box-shadow: var(--component-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.match-card--clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.match-card--selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.match-card--compact {
    padding: var(--component-padding-sm);
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.match-card--bracket {
    padding: 0.5rem;
    font-size: 0.875rem;
}

.match-card__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.match-card__code {
    font-weight: 600;
    color: #374151;
}

.match-card__phase {
    background-color: #f3f4f6;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.match-card__datetime {
    margin-left: auto;
}

.match-card__date {
    margin-right: 0.5rem;
}

.match-card__time {
    font-weight: 500;
}

.match-card__teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.match-card__teams--stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}

.match-card__team {
    flex: 1;
}

.match-card__team--home {
    text-align: right;
}

.match-card__team--away {
    text-align: left;
}

.match-card__teams--stacked .match-card__team--home,
.match-card__teams--stacked .match-card__team--away {
    text-align: left;
}

.match-card__vs {
    color: #9ca3af;
    font-weight: 500;
}

.match-card__footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    border-top: 1px solid #f3f4f6;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.match-card__venue {
    flex: 1;
}

.match-card__price {
    font-weight: 500;
    color: #059669;
}

.match-card__checkbox {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.match-card__number {
    font-weight: 600;
    font-size: 0.75rem;
    color: #9ca3af;
    min-width: 2rem;
}

/* ============================================
   Modal Component
   ============================================ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal--open {
    display: flex;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal__container {
    position: relative;
    background-color: var(--component-bg);
    border-radius: var(--component-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow: auto;
    animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal--small .modal__container { width: 90%; max-width: 400px; }
.modal--medium .modal__container { width: 90%; max-width: 600px; }
.modal--large .modal__container { width: 90%; max-width: 800px; }
.modal--fullscreen .modal__container { width: 95%; max-width: none; height: 90vh; }

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--component-padding-md);
    border-bottom: 1px solid var(--component-border);
}

.modal__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal__close:hover {
    color: #1f2937;
}

.modal__body {
    padding: var(--component-padding-lg);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: var(--component-padding-md);
    border-top: 1px solid var(--component-border);
    background-color: #f9fafb;
    border-radius: 0 0 var(--component-radius-lg) var(--component-radius-lg);
}

.modal__button {
    padding: 0.5rem 1rem;
    border-radius: var(--component-radius-sm);
    border: 1px solid var(--component-border);
    background-color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal__button:hover {
    background-color: #f3f4f6;
}

.modal__button--primary {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.modal__button--primary:hover {
    background-color: #2563eb;
}

.modal__button--danger {
    background-color: #ef4444;
    border-color: #ef4444;
    color: white;
}

.modal__button--danger:hover {
    background-color: #dc2626;
}

.modal__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.modal__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

body.modal-open {
    overflow: hidden;
}

/* ============================================
   State Display Component
   ============================================ */

.state-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.state-display--inline {
    flex-direction: row;
    padding: 1rem;
    text-align: left;
    gap: 1rem;
}

.state-display--banner {
    flex-direction: row;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    border-radius: var(--component-radius-sm);
}

.state-display__spinner {
    color: var(--state-loading-color);
}

.state-display__spinner-svg {
    width: 100%;
    height: 100%;
}

.state-display__icon {
    color: inherit;
    margin-bottom: 0.5rem;
}

.state-display--inline .state-display__icon,
.state-display--banner .state-display__icon {
    margin-bottom: 0;
}

.state-display__title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.state-display__message {
    margin: 0;
    color: #6b7280;
}

.state-display__retry,
.state-display__action {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: var(--component-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.state-display__retry:hover,
.state-display__action:hover {
    background-color: #2563eb;
}

.state-display__details {
    margin-top: 1rem;
    text-align: left;
    width: 100%;
}

.state-display__details summary {
    cursor: pointer;
    color: #6b7280;
    font-size: 0.875rem;
}

.state-display__details pre {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: #f3f4f6;
    border-radius: var(--component-radius-sm);
    overflow-x: auto;
    font-size: 0.75rem;
}

.state-display__dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.state-display__dismiss:hover {
    opacity: 1;
}

/* State variants */
.state-display--loading .state-display__icon { color: var(--state-loading-color); }
.state-display--error { color: var(--state-error-color); }
.state-display--error.state-display--banner { background-color: #fef2f2; }
.state-display--success { color: var(--state-success-color); }
.state-display--success.state-display--banner { background-color: #f0fdf4; }
.state-display--warning { color: var(--state-warning-color); }
.state-display--warning.state-display--banner { background-color: #fffbeb; }
.state-display--info { color: var(--state-info-color); }
.state-display--info.state-display--banner { background-color: #eff6ff; }

.state-display--empty .state-display__icon {
    color: #9ca3af;
}

/* ============================================
   DateTime Display Component
   ============================================ */

.datetime-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.datetime-display--compact {
    gap: 0.25rem;
    font-size: 0.875rem;
}

.datetime-display__separator {
    color: #9ca3af;
}

.datetime-display__date,
.datetime-display__time {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.datetime-display__day {
    color: #6b7280;
}

.datetime-display__timezone {
    font-size: 0.75em;
    color: #9ca3af;
}

.datetime-display__relative {
    color: #6b7280;
}

.datetime-display__countdown {
    display: flex;
    gap: 0.5rem;
}

.datetime-display__countdown--past {
    color: #6b7280;
}

.datetime-display__countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 3rem;
    padding: 0.5rem;
    background-color: #f3f4f6;
    border-radius: var(--component-radius-sm);
}

.datetime-display__countdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.datetime-display__countdown-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ============================================
   Calendar Header Component
   ============================================ */

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

.calendar-header h2 {
    margin: 0;
    flex-shrink: 0;
}

.calendar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.calendar-filters .filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--component-border);
    border-radius: var(--component-radius-md);
    background: var(--component-bg);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 140px;
}

.calendar-filters .filter-select:hover {
    border-color: #B8860B;
}

.calendar-filters .filter-select:focus {
    outline: none;
    border-color: #B8860B;
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.2);
}

/* Responsive: Stack filters below title on mobile */
@media (max-width: 768px) {
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .calendar-filters {
        justify-content: center;
    }
    
    .calendar-filters .filter-select {
        flex: 1;
        min-width: 100px;
    }
}
