/* Match Calendar Component Styles */

.match-calendar {
    width: 100%;
    background: var(--bg-surface, #ffffff);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Calendar Header */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
}

.calendar-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary, #1f2937);
}

.calendar-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-nav-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary, #6b7280);
}

.calendar-nav-btn:hover {
    background: var(--primary-color, #3b82f6);
}

.calendar-nav-btn:hover svg {
    stroke: white;
}

/* View Toggle */
.calendar-view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--bg-secondary, #f3f4f6);
    padding: 0.25rem;
    border-radius: 8px;
    width: fit-content;
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    transition: all 0.2s ease;
}

.view-toggle-btn.active {
    background: white;
    color: var(--primary-color, #3b82f6);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-toggle-btn:hover:not(.active) {
    color: var(--text-primary, #1f2937);
}

/* Tournament Color Legend */
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem 1.25rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    white-space: nowrap;
}

/* Tournament name tag in list view */
.match-tournament-tag {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Calendar Grid (Month View) */
.calendar-grid {
    width: 100%;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 1px;
    background: var(--border-color, #e5e7eb);
}

.weekday-cell {
    background: var(--bg-secondary, #f9fafb);
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color, #e5e7eb);
    border: 1px solid var(--border-color, #e5e7eb);
}

.day-cell {
    background: white;
    min-height: 100px;
    padding: 0.5rem;
    position: relative;
    transition: background-color 0.2s ease;
}

.day-cell.other-month {
    background: var(--bg-secondary, #f9fafb);
    opacity: 0.6;
}

.day-cell.today {
    background: var(--primary-light, #eff6ff);
}

.day-cell.today .day-number {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary, #1f2937);
}

.day-matches {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.day-match-item {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid;
}

.day-match-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.day-match-item.status-scheduled {
    background: #dbeafe;
    border-left-color: #3b82f6;
}

.day-match-item.status-in-progress {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

.day-match-item.status-completed {
    background: #d1fae5;
    border-left-color: #10b981;
}

.day-match-item.status-cancelled {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.day-match-item.status-postponed {
    background: #e5e7eb;
    border-left-color: #6b7280;
}

.match-time {
    font-weight: 600;
    margin-bottom: 0.125rem;
    color: var(--text-primary, #1f2937);
}

.match-teams {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.team-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vs-text {
    font-size: 0.625rem;
    color: var(--text-secondary, #6b7280);
    text-align: center;
}

.bye-label {
    font-style: italic;
    color: var(--text-secondary, #6b7280);
}

.more-matches {
    padding: 0.25rem 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--primary-color, #3b82f6);
    cursor: pointer;
    font-weight: 500;
}

.more-matches:hover {
    text-decoration: underline;
}

/* Week View */
.calendar-week-view {
    width: 100%;
    position: relative;
}

.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 1px;
    background: var(--border-color, #e5e7eb);
}

.week-day-header {
    background: var(--bg-secondary, #f9fafb);
    padding: 0.75rem;
    text-align: center;
}

.week-day-header.today {
    background: var(--primary-light, #eff6ff);
}

.week-day-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 0.25rem;
}

.week-day-number {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary, #1f2937);
}

.week-day-header.today .week-day-number {
    color: var(--primary-color, #3b82f6);
}

.week-content {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color, #e5e7eb);
    border: 1px solid var(--border-color, #e5e7eb);
}

.week-day-column {
    background: white;
    min-height: 400px;
    padding: 0.75rem 0.5rem;
}

.week-day-column.today {
    background: var(--primary-light, #eff6ff);
}

.week-match-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid;
}

.week-match-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.week-match-item.status-scheduled {
    background: #dbeafe;
    border-left-color: #3b82f6;
}

.week-match-item.status-in-progress {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

.week-match-item.status-completed {
    background: #d1fae5;
    border-left-color: #10b981;
}

.week-match-item.status-cancelled {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.week-match-item.status-postponed {
    background: #e5e7eb;
    border-left-color: #6b7280;
}

.week-match-item .match-time {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.week-match-item .match-info {
    margin-bottom: 0.5rem;
}

.week-match-item .team {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.week-match-item .vs {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    text-align: center;
    margin: 0.25rem 0;
}

.week-match-item .match-score {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.no-matches {
    text-align: center;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    padding: 2rem 0;
}

/* List View */
.calendar-list-view {
    width: 100%;
}

.list-date-group {
    margin-bottom: 2rem;
}

.list-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.list-date-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

.match-count {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
}

.list-matches {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-match-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: white;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.list-match-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color, #3b82f6);
}

.match-time-badge {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary, #1f2937);
}

.match-details {
    flex: 1;
}

.match-teams-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.match-teams-row .team-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary, #1f2937);
}

.match-teams-row .vs-text {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
}

.match-teams-row .bye-badge {
    padding: 0.25rem 0.5rem;
    background: var(--bg-warning, #fef3c7);
    color: var(--text-warning, #92400e);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.match-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
}

.match-location svg {
    width: 16px;
    height: 16px;
}

.match-status-column {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.match-score-display {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary, #1f2937);
}

.no-matches-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary, #6b7280);
}

.no-matches-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-matches-placeholder p {
    margin: 0;
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calendar-title {
        font-size: 1.25rem;
    }

    .weekday-cell {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .day-cell {
        min-height: 80px;
    }

    .day-match-item {
        font-size: 0.625rem;
    }

    .week-day-column {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .match-calendar {
        padding: 1rem;
    }

    .calendar-header {
        margin-bottom: 1rem;
    }

    .calendar-legend {
        gap: 0.5rem 1rem;
        padding: 0.625rem 0.75rem;
    }

    .legend-label {
        font-size: 0.75rem;
    }

    .calendar-title {
        font-size: 1.125rem;
    }

    .calendar-nav-btn {
        width: 32px;
        height: 32px;
    }

    .calendar-view-toggle {
        width: 100%;
    }

    .view-toggle-btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .weekday-cell {
        font-size: 0.625rem;
        padding: 0.375rem;
    }

    .day-cell {
        min-height: 60px;
        padding: 0.25rem;
    }

    .day-number {
        font-size: 0.75rem;
    }

    .day-match-item {
        padding: 0.25rem;
    }

    /* Make week view horizontally scrollable on mobile */
    .calendar-week-view {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
        padding-bottom: 0.5rem;
    }

    /* Scrollbar styling for webkit browsers */
    .calendar-week-view::-webkit-scrollbar {
        height: 8px;
    }

    .calendar-week-view::-webkit-scrollbar-track {
        background: var(--bg-secondary, #f3f4f6);
        border-radius: 4px;
    }

    .calendar-week-view::-webkit-scrollbar-thumb {
        background: var(--primary-color, #3b82f6);
        border-radius: 4px;
    }

    .calendar-week-view::-webkit-scrollbar-thumb:hover {
        background: var(--primary-dark, #2563eb);
    }

    /* Add scroll indicator shadow on mobile */
    .calendar-week-view::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 8px;
        width: 40px;
        background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
        pointer-events: none;
        opacity: 0.7;
    }

    .week-header,
    .week-content {
        min-width: 700px; /* Force horizontal scroll instead of collapse */
    }

    .week-header {
        grid-template-columns: repeat(7, minmax(100px, 1fr));
    }

    .week-content {
        grid-template-columns: repeat(7, minmax(100px, 1fr));
    }

    .week-day-header {
        padding: 0.5rem 0.25rem;
    }

    .week-day-name {
        font-size: 0.75rem;
    }

    .week-day-number {
        font-size: 1rem;
    }

    .week-day-column {
        min-height: 300px;
        padding: 0.5rem 0.25rem;
    }

    .week-match-item {
        padding: 0.5rem;
        margin-bottom: 0.375rem;
        font-size: 0.75rem;
    }

    .week-match-item .match-time {
        font-size: 0.625rem;
    }

    .week-match-item .team {
        font-size: 0.75rem;
    }

    .week-match-item .vs {
        font-size: 0.625rem;
    }

    /* Simplify list view on mobile */
    .list-match-item {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .match-time-badge {
        width: fit-content;
    }

    .match-status-column {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .calendar-title {
        font-size: 1rem;
    }

    .weekday-cell {
        padding: 0.25rem;
        font-size: 0.5rem;
    }

    .day-cell {
        min-height: 50px;
    }

    .match-teams {
        display: none;
    }

    .day-match-item {
        padding: 0.125rem 0.25rem;
    }

    .match-time {
        font-size: 0.625rem;
    }

    .list-date-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .list-date-header h4 {
        font-size: 1rem;
    }

    /* Further optimize week view for very small screens */
    .week-header,
    .week-content {
        min-width: 600px;
    }

    .week-header {
        grid-template-columns: repeat(7, 85px);
    }

    .week-content {
        grid-template-columns: repeat(7, 85px);
    }

    .week-day-header {
        padding: 0.375rem 0.125rem;
    }

    .week-day-name {
        font-size: 0.625rem;
    }

    .week-day-number {
        font-size: 0.875rem;
    }

    .week-day-column {
        padding: 0.375rem 0.125rem;
    }

    .week-match-item {
        padding: 0.375rem;
        font-size: 0.625rem;
    }

    .week-match-item .match-time {
        font-size: 0.5rem;
    }

    .week-match-item .team {
        font-size: 0.625rem;
    }
}

/* -- Yearly view -- */
.calendar-year-view {
    padding: 0;
}

.year-month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.year-month-block {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.year-month-title {
    background: var(--primary-color, #3b82f6);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    padding: 4px 6px;
}

.year-day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
}

.year-dow-cell {
    text-align: center;
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, #f9fafb);
    padding: 2px 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.year-day-cell {
    min-height: 20px;
    padding: 1px 1px;
    text-align: center;
    border-right: 1px solid var(--border-color, #f3f4f6);
    border-bottom: 1px solid var(--border-color, #f3f4f6);
    cursor: default;
    position: relative;
}

.year-day-blank {
    background: var(--bg-secondary, #f9fafb);
}

.year-day-has-matches .year-day-number {
    font-weight: 700;
}



.year-day-has-matches:hover {
    background: #dbeafe;
}

.year-day-today .year-day-number {
    background: var(--primary-color, #3b82f6);
    color: #fff;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.year-day-number {
    font-size: 0.6rem;
    color: var(--text-primary, #1f2937);
    display: block;
    line-height: 1.3;
}

.year-day-dots {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1px;
    margin-top: 1px;
}

.year-day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    display: inline-block;
}

@media (max-width: 900px) {
    .year-month-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .year-month-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
