/* Clinic Calendar Frontend Styles */

.clinic-calendar-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', sans-serif;
    max-width: 100%;
}

.clinic-calendar-title {
    font-size: 1.4em;
    font-weight: 700;
    color: #1d2327;
    margin-bottom: 12px;
}

.clinic-calendar-months {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.clinic-calendar-month {
    flex: 1;
    min-width: 280px;
    max-width: 480px;
}

.clinic-calendar-month-title {
    font-size: 1.1em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: #1d2327;
    padding: 8px;
    background: #f6f7f7;
    border-radius: 4px;
}

.clinic-cal-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.clinic-cal-table th {
    text-align: center;
    padding: 6px 2px;
    font-size: 0.8em;
    font-weight: 700;
    background: #f6f7f7;
    border: 1px solid #dde;
    color: #333;
}

.clinic-cal-table th.sun { color: #c62828; }
.clinic-cal-table th.sat { color: #1565c0; }

.clinic-cal-table td {
    border: 1px solid #dde;
    padding: 0;
    vertical-align: top;
    height: 60px;
}

.clinic-cal-table td.other-month {
    background: #f9f9f9;
    opacity: 0.4;
}

/* ======= セル基本 ======= */
.cc-cell {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    /* テーブルセル内で height:100% を効かせるために必要 */
    min-height: 60px;
}

/* 単色セル */
.cc-cell.status-open {
    background-color: var(--cc-color-open, #eaf6eb);
}

.cc-cell.status-closed {
    background-color: var(--cc-color-closed, #ffebee);
}

/* ======= 斜め分割セル =======
   clip-path+absolute方式はtd内で高さ0になるバグあり。
   linear-gradientをcc-cell自体に直接かける方式に変更。
   斜め線はグラデーションの色変化点で表現。
*/

/* am_closed：左上=午前休診色 / 右下=午後診療色 */
.cc-cell.status-am_closed {
    background-image: linear-gradient(
        to bottom right,
        var(--cc-color-am-top,    #ffebee) calc(50% - 1px),
        rgba(255,255,255,0.9)      calc(50% - 1px),
        rgba(255,255,255,0.9)      calc(50% + 1px),
        var(--cc-color-am-bottom, #eaf6eb) calc(50% + 1px)
    );
}

/* pm_closed：左上=午前診療色 / 右下=午後休診色 */
.cc-cell.status-pm_closed {
    background-image: linear-gradient(
        to bottom right,
        var(--cc-color-pm-top,    #eaf6eb) calc(50% - 1px),
        rgba(255,255,255,0.9)      calc(50% - 1px),
        rgba(255,255,255,0.9)      calc(50% + 1px),
        var(--cc-color-pm-bottom, #ffebee) calc(50% + 1px)
    );
}

/* ======= 日付数字・テキスト ======= */
.cc-day-num {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 0.85em;
    font-weight: 700;
    line-height: 1;
    z-index: 1;
}

.cc-day-text {
    position: absolute;
    bottom: 3px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65em;
    font-weight: 600;
    z-index: 1;
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

/* ======= 凡例 ======= */
.clinic-calendar-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 12px;
    background: #f6f7f7;
    border-radius: 4px;
}

.cc-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
}

/* 単色スウォッチ */
.cc-legend-swatch {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

/* 斜め分割スウォッチ（同じlinear-gradient方式） */
.cc-legend-swatch.diagonal {
    background-color: transparent;
}

/* ======= レスポンシブ ======= */
@media (max-width: 600px) {
    .clinic-calendar-months {
        flex-direction: column;
    }
    .clinic-calendar-month {
        max-width: 100%;
    }
    .clinic-cal-table td {
        height: 48px;
    }
    .cc-cell {
        min-height: 48px;
    }
}
