/* フロントエンドカレンダーUI CSS */

.onebuild-calendar-wrapper {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* PC表示時のカレンダー追従機能 */
@media (min-width: 769px) {
    .onebuild-calendar-wrapper {
        position: sticky;
        top: 20px;
        z-index: 100;
        transition: box-shadow 0.3s ease;
    }
    
    /* スクロール時の影効果 */
    .onebuild-calendar-wrapper.sticky-active {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
}

/* ヘッダー */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e1e1;
}

.calendar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.nav-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
    font-size: 16px;
    font-weight: bold;
}

.nav-btn:hover:not(.disabled) {
    background: #f0f0f0;
    border-color: #ccc;
    color: #333;
}

.nav-btn:disabled,
.nav-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* カレンダーグリッド */
.calendar-grid {
    padding: 0;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #e1e1e1;
}

.weekday {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e1e1e1;
}

/* 日付セル */
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: 2px solid transparent;
}

.calendar-day:hover:not(.disabled) {
    background: #f0f8ff;
    border-color: #e3f2fd;
}

.calendar-day:focus {
    outline: none;
    border-color: #2196f3;
    z-index: 1;
}

.calendar-day.selected {
    background: #2196f3;
    color: #fff;
    border-color: #1976d2;
}

.calendar-day.today {
    font-weight: bold;
    background: #fff3e0;
}

.calendar-day.today.selected {
    background: #ff9800;
    border-color: #f57c00;
}

/* 日付状態別スタイル */
.calendar-day.other-month {
    color: #ccc;
    background: #fafafa;
}

.calendar-day.past,
.calendar-day.disabled {
    color: #ccc;
    background: #f5f5f5;
    cursor: not-allowed;
}

.calendar-day.available {
    border-left: 4px solid #4caf50;
}

.calendar-day.limited {
    border-left: 4px solid #ff9800;
}

.calendar-day.full {
    border-left: 4px solid #f44336;
    color: #999;
    background: #fafafa;
    cursor: not-allowed;
}

.calendar-day.closed {
    border-left: 4px solid #9e9e9e;
    color: #999;
    background: #fafafa;
    cursor: not-allowed;
}

/* 日付表示 */
.day-number {
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 2px;
}

.day-status {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
}

/* 凡例 */
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 24px;
    background: #f8f9fa;
    border-top: 1px solid #e1e1e1;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-color.available {
    background-color: #4caf50;
}

.legend-color.limited {
    background-color: #ff9800;
}

.legend-color.full {
    background-color: #f44336;
}

.legend-color.closed {
    background-color: #9e9e9e;
}

.legend-text {
    color: #666;
    font-size: 13px;
}

/* ローディング */
.loading-indicator {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .onebuild-calendar-wrapper {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .calendar-header {
        padding: 16px 20px;
    }

    .calendar-header h3 {
        font-size: 16px;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .weekday {
        padding: 10px 4px;
        font-size: 13px;
    }

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

    .day-number {
        font-size: 14px;
    }

    .day-status {
        font-size: 11px;
    }

    .calendar-legend {
        padding: 12px 20px;
        gap: 12px;
    }

    .legend-text {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .calendar-header {
        padding: 12px 16px;
    }

    .calendar-header h3 {
        font-size: 15px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .weekday {
        padding: 8px 2px;
        font-size: 12px;
    }

    .calendar-day {
        min-height: 45px;
    }

    .day-number {
        font-size: 13px;
    }

    .calendar-legend {
        flex-direction: row;
        gap: 8px;
        padding: 12px 16px;
    }

    .legend-item {
        gap: 8px;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {

    .calendar-day,
    .nav-btn,
    .loading-spinner {
        transition: none;
        animation: none;
    }
}

/* ハイコントラストモード */
@media (prefers-contrast: high) {
    .calendar-day {
        border: 1px solid #000;
    }

    .calendar-day.selected {
        background: #000;
        color: #fff;
    }

    .legend-color {
        border: 1px solid #000;
    }
}