/* Tournament Calendar Styles */
.ncbx-calendar-wrapper {
    max-width: 1200px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin: 30px auto;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.ncbx-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
}

.ncbx-calendar-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.ncbx-calendar-nav {
    display: flex;
    gap: 10px;
    align-items: center;
}
/* Safari < 14.1 flex gap fallback */
@supports not (gap: 1px) {
    .ncbx-calendar-nav > * + * { margin-left: 10px; }
}

.ncbx-calendar-nav button {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px; /* Minimum touch target size for mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    touch-action: manipulation; /* Improve touch responsiveness */
}

.ncbx-calendar-nav button:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.ncbx-calendar-nav button:active {
    transform: translateY(0);
}

.ncbx-calendar-month {
    font-size: 18px;
    font-weight: 600;
    color: #e0e7ff;
    min-width: 150px;
    text-align: center;
}

.ncbx-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 30px;
    width: 100%;
    box-sizing: border-box;
}

.ncbx-calendar-weekday {
    text-align: center;
    font-weight: 700;
    color: #93c5fd;
    padding: 12px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(147, 197, 253, 0.2);
}

.ncbx-calendar-day {
    min-width: 0;
    padding: 12px 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 100px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
/* aspect-ratio fallback for Safari < 15 - min-height above provides square-ish cells */
@supports (aspect-ratio: 1) {
    .ncbx-calendar-day { aspect-ratio: 1; }
}

.ncbx-calendar-day:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
}

.ncbx-calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.ncbx-calendar-day.other-month:hover {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    transform: none;
}

.ncbx-calendar-day.today {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(16, 185, 129, 0.15) 100%);
    border: 2px solid rgba(34, 197, 94, 0.5);
    font-weight: 700;
}

.ncbx-calendar-day-number {
    font-size: 16px;
    font-weight: 600;
    color: #e0e7ff;
    margin-bottom: 6px;
}

.ncbx-calendar-day.today .ncbx-calendar-day-number {
    color: #22c55e;
}

.ncbx-calendar-events {
    font-size: 10px;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}
@supports not (gap: 1px) {
    .ncbx-calendar-events > * + * { margin-top: 3px; }
}

.ncbx-calendar-event-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #3b82f6;
    display: inline-block;
    margin-right: 3px;
}

.ncbx-calendar-event-item {
    background: rgba(59, 130, 246, 0.3);
    padding: 2px 4px;
    border-radius: 3px;
    color: #93c5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid #3b82f6;
    padding-left: 6px;
}

.ncbx-calendar-event-item:hover {
    background: rgba(59, 130, 246, 0.5);
    color: #e0e7ff;
}

.ncbx-calendar-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
}

.ncbx-calendar-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 14px;
}

.ncbx-calendar-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: #3b82f6;
}

.ncbx-calendar-events-list {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
}

.ncbx-calendar-event-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.6) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    padding: 18px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ncbx-calendar-event-card:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(30, 58, 138, 0.1) 100%);
    border-color: rgba(59, 130, 246, 0.6);
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.2);
}

.ncbx-calendar-event-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ncbx-calendar-event-card-time {
    font-size: 13px;
    color: #93c5fd;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ncbx-calendar-event-card-location {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.ncbx-calendar-event-card-button {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ncbx-calendar-event-card-button:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: scale(1.02);
}

@media (max-width: 768px) {
    .ncbx-calendar-wrapper {
        padding: 15px;
        margin: 20px 10px;
        width: calc(100% - 20px);
        max-width: 100%;
    }

    .ncbx-calendar-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        width: 100%;
    }

    .ncbx-calendar-title {
        font-size: 22px;
        width: 100%;
    }

    .ncbx-calendar-nav {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 10px;
    }

    .ncbx-calendar-nav button {
        padding: 12px 20px;
        font-size: 14px;
        min-width: 110px;
        min-height: 44px; /* Touch-friendly size */
        flex: 0 1 auto;
    }

    .ncbx-calendar-month {
        min-width: auto;
        font-size: 16px;
        width: 100%;
        order: -1;
        margin-bottom: 10px;
    }

    .ncbx-calendar-grid {
        gap: 4px;
        width: 100%;
    }

    .ncbx-calendar-weekday {
        font-size: 11px;
        padding: 8px 2px;
    }

    .ncbx-calendar-day {
        min-height: 70px;
        padding: 6px 2px;
        aspect-ratio: auto;
    }

    .ncbx-calendar-day-number {
        font-size: 12px;
        margin-bottom: 3px;
    }

    .ncbx-calendar-events {
        font-size: 8px;
        gap: 2px;
    }

    .ncbx-calendar-event-item {
        font-size: 7px;
        padding: 1px 2px;
    }

    .ncbx-calendar-events-list {
        display: none !important;
    }

    .ncbx-calendar-legend {
        flex-direction: row;
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
        padding: 12px;
    }

    .ncbx-calendar-legend-item {
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .ncbx-calendar-wrapper {
        padding: 10px;
        margin: 15px 5px;
        border-radius: 8px;
        width: calc(100% - 10px);
        max-width: 100%;
    }

    .ncbx-calendar-header {
        gap: 12px;
        margin-bottom: 15px;
        padding-bottom: 12px;
        width: 100%;
    }

    .ncbx-calendar-title {
        font-size: 18px;
        width: 100%;
    }

    .ncbx-calendar-nav {
        width: 100%;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .ncbx-calendar-nav button {
        padding: 12px 16px;
        font-size: 13px;
        flex: 1;
        min-width: 0;
        min-height: 44px; /* Touch-friendly size */
        white-space: nowrap;
        font-weight: 600;
    }

    .ncbx-calendar-month {
        font-size: 14px;
        width: 100%;
        order: -1;
        margin-bottom: 8px;
        padding: 0 5px;
    }

    .ncbx-calendar-grid {
        gap: 2px;
        width: 100%;
    }

    .ncbx-calendar-weekday {
        font-size: 9px;
        padding: 6px 1px;
        letter-spacing: 0;
    }

    .ncbx-calendar-day {
        min-height: 60px;
        padding: 4px 1px;
        border-radius: 4px;
        aspect-ratio: auto;
    }

    .ncbx-calendar-day-number {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .ncbx-calendar-events {
        font-size: 7px;
        gap: 1px;
    }

    .ncbx-calendar-event-item {
        padding: 1px 2px;
        font-size: 6px;
        border-left-width: 1px;
    }

    .ncbx-calendar-event-dot {
        width: 2px;
        height: 2px;
    }

    .ncbx-calendar-events-list {
        display: none !important;
    }

    .ncbx-calendar-legend {
        flex-direction: row;
        gap: 10px;
        padding: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .ncbx-calendar-legend-item {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .ncbx-calendar-wrapper {
        padding: 8px;
        margin: 10px 5px;
        width: calc(100% - 10px);
        max-width: 100%;
    }

    .ncbx-calendar-title {
        font-size: 16px;
    }

    .ncbx-calendar-nav {
        gap: 6px;
        width: 100%;
    }

    .ncbx-calendar-nav button {
        padding: 10px 12px;
        font-size: 12px;
        min-height: 44px; /* Touch-friendly size */
        flex: 1;
        font-weight: 600;
    }

    .ncbx-calendar-month {
        font-size: 12px;
        padding: 0 3px;
    }

    .ncbx-calendar-grid {
        gap: 1px;
    }

    .ncbx-calendar-weekday {
        font-size: 8px;
        padding: 5px 0;
    }

    .ncbx-calendar-day {
        min-height: 50px;
        padding: 3px 1px;
    }

    .ncbx-calendar-day-number {
        font-size: 10px;
    }

    .ncbx-calendar-events {
        font-size: 6px;
    }

    .ncbx-calendar-event-item {
        font-size: 5px;
        padding: 1px;
    }

    .ncbx-calendar-events-list {
        display: none !important;
    }

    .ncbx-calendar-legend {
        padding: 8px;
        gap: 8px;
    }

    .ncbx-calendar-legend-item {
        font-size: 10px;
    }
}

/* Additional mobile optimizations for very small screens */
@media (max-width: 360px) {
    .ncbx-calendar-nav {
        gap: 4px;
    }

    .ncbx-calendar-nav button {
        padding: 10px 10px;
        font-size: 11px;
        min-height: 44px;
    }

    .ncbx-calendar-month {
        font-size: 11px;
    }
}

/* Ensure buttons are always visible and clickable */
.ncbx-calendar-nav button:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

.ncbx-calendar-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Improve button visibility on mobile */
@media (hover: none) and (pointer: coarse) {
    .ncbx-calendar-nav button {
        padding: 12px 18px;
        font-size: 14px;
        min-height: 48px;
    }
    
    .ncbx-calendar-nav button:active {
        background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
        transform: scale(0.98);
    }
}

/* Safari < 14.1 flex gap fallback */
@supports not (gap: 1px) {
    .ncbx-calendar-legend > * + * { margin-left: 30px; }
}
