/* 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;
    /* PC・タブレット：2列固定、折り返しなし */
    flex-wrap: nowrap;
    align-items: flex-start;
}

.clinic-calendar-month {
    /* 等幅2列 */
    flex: 1 1 0;
    min-width: 0;
}

.clinic-calendar-month-title {
    font-size: 1.1em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: #1d2327;
    padding: 0;
    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;
    /* テーブルセルにaspect-ratioが効かないブラウザ対策:
       widthは table-layout:fixed で自動均等分割される。
       セルの高さは .cc-cell の padding-top:100% で正方形を実現する */
}

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

/* ======= セル基本 ======= */
.cc-cell {
    /* padding-top:100% で「幅＝高さ」の正方形を実現（table-cellでも確実に動作） */
    position: relative;
    width: 100%;
    padding-top: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* 日付・テキストを内包するインナー（absoluteで正方形の中に配置） */
.cc-cell-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* 単色セル */
.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 {
    font-size: 0.9em;
    font-weight: 700;
    line-height: 1;
    z-index: 1;
    /* 親のflexによって上下左右中央に配置される */
}

.cc-day-text {
    text-align: center;
    font-size: 0.65em;
    font-weight: 600;
    z-index: 1;
    padding: 0 2px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    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;
}

/* ======= レスポンシブ ======= */

/* タブレット（768px以下）：2列横並び維持・折り返しなし */
@media (max-width: 768px) {
    .clinic-calendar-months {
        flex-wrap: nowrap;
    }
    .clinic-calendar-month {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* スマホ（480px以下）：2列を横スクロールで表示 */
@media (max-width: 480px) {
    .clinic-calendar-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .clinic-calendar-months {
        flex-wrap: nowrap;
        /* 各カレンダーを最低260pxに固定して横スクロール */
        min-width: max-content;
    }
    .clinic-calendar-month {
        flex: 0 0 260px;
        min-width: 260px;
    }

}

/* ======= 任意テキスト アイコン（フロント） ======= */
.cc-cell-text-icon {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.6em;
    line-height: 1;
    z-index: 2;
    cursor: pointer;
    pointer-events: auto;
}

/* テキストがあるセルのカーソル */
.cc-cell.has-text {
    cursor: pointer;
}

/* テキスト表示モーダル */
.cc-text-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cc-text-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px 28px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    text-align: center;
    position: relative;
}
.cc-text-modal-date {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 8px;
}
.cc-text-modal-body {
    font-size: 1.1em;
    font-weight: 700;
    color: #1d2327;
    margin-bottom: 16px;
    word-break: break-all;
}
.cc-text-modal-close {
    background: #f0f0f1;
    border: none;
    border-radius: 4px;
    padding: 6px 20px;
    cursor: pointer;
    font-size: 0.9em;
    color: #50575e;
}
.cc-text-modal-close:hover { background: #ddd; }
