/* ===== リセット ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== グローバルスタイル ===== */
html,
body {
    height: 100%;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #87ceeb 0%, #e0f6ff 50%, #b3e5fc 100%);
    background-attachment: fixed;
    color: #2c3e50;
    line-height: 1.6;
}

button {
    font-family: inherit;
}

input,
select {
    font-family: inherit;
}

/* ===== ヘッダー ===== */
.header {
    background: linear-gradient(
        135deg,
        rgba(0, 102, 204, 0.9) 0%,
        rgba(52, 152, 219, 0.9) 100%
    );
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    font-weight: bold;
    margin: 0;
}

/* ===== メインコンテンツ ===== */
.calendar-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
}

/* ===== コントロールエリア ===== */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.nav-btn {
    background-color: #e8f4f8;
    border: 1px solid #7fbbcc;
    color: #2c3e50;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #b8e5f0;
}

.nav-btn:active {
    background-color: #7fbbcc;
}

.month-display {
    font-size: 18px;
    font-weight: bold;
    min-width: 120px;
    text-align: center;
}

.date-picker-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.date-picker-btn:hover {
    background-color: #2980b9;
}

.date-picker-btn:active {
    background-color: #1f618d;
}

/* ===== 曜日ヘッダー ===== */
.weekday-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: #bdc3c7;
    margin-bottom: 1px;
}

.weekday {
    background-color: #ecf0f1;
    color: #2c3e50;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

.weekday:first-child {
    color: #e74c3c;
}

.weekday:last-child {
    color: #3498db;
}

/* ===== カレンダーグリッド ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: #bdc3c7;
    margin-bottom: 20px;
}

.day-cell {
    background-color: white;
    min-height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 5px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.day-cell:hover {
    background-color: #f5f5f5;
}

.day-cell.other-month {
    color: #bdc3c7;
    opacity: 0.5;
    cursor: default;
}

.day-cell.other-month:hover {
    background-color: white;
}

.day-cell.sunday {
    color: #e74c3c;
}

.day-cell.saturday {
    color: #3498db;
}

.day-cell.holiday {
    color: #e74c3c;
    font-weight: bold;
}

.day-cell.today {
    background-color: #fff9c4;
    border: 2px solid #3498db;
    font-weight: bold;
}

.day-cell.today.holiday {
    color: #e74c3c;
}

.day-cell.today.other-month {
    border: 2px solid #3498db;
    opacity: 1;
}

/* ===== フッター ===== */
.footer-legend {
    max-width: 1200px;
    margin: 0 auto 40px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    font-size: 12px;
    color: #2c3e50;
}

/* ===== ダイアログ ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

.dialog-overlay.active {
    display: block;
}

.dialog-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 400px;
    max-width: 90%;
    z-index: 1000;
    display: none;
}

.dialog-container.active {
    display: block;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.dialog-header {
    background: linear-gradient(
        135deg,
        rgba(0, 102, 204, 0.9) 0%,
        rgba(52, 152, 219, 0.9) 100%
    );
    color: white;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.dialog-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: #34495e;
    border-radius: 4px;
}

.dialog-content {
    padding: 20px;
}

.year-picker-section,
.month-picker-section {
    margin-bottom: 20px;
}

.year-picker-section label,
.month-picker-section label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: #2c3e50;
}

.year-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

#input-year {
    font-size: 16px;
    text-align: center;
    width: 80px;
    padding: 8px;
    border: 1px solid #7fbbcc;
    background-color: white;
}

#input-year:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 4px rgba(52, 152, 219, 0.3);
}

.year-btn {
    width: 36px;
    background-color: #e8f4f8;
    border: 1px solid #7fbbcc;
    color: #2c3e50;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0;
    line-height: 1;
    height: 24px;
}

.year-btn.up-btn {
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.year-btn.down-btn {
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.year-btn:hover {
    background-color: #b8e5f0;
}

.year-btn:active {
    background-color: #7fbbcc;
}

#select-month {
    width: 100%;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid #7fbbcc;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

#select-month:hover {
    background-color: #f5f5f5;
}

#select-month:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 4px rgba(52, 152, 219, 0.3);
}

.dialog-button-area {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #ecf0f1;
}

.btn-cancel {
    background-color: #ecf0f1;
    color: #2c3e50;
    border: 1px solid #bdc3c7;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-cancel:hover {
    background-color: #d5d8dc;
}

.btn-cancel:active {
    background-color: #bdc3c7;
}

.btn-confirm {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-confirm:hover {
    background-color: #2980b9;
}

.btn-confirm:active {
    background-color: #1f618d;
}

/* ===== ポップアップ ===== */
.popup-container {
    position: fixed;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    z-index: 500;
    display: none;
    overflow: hidden;
}

.popup-container.active {
    display: block;
    animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid rgba(255, 255, 255, 0.95);
}

.popup-header {
    background: linear-gradient(
        135deg,
        rgba(0, 102, 204, 0.9) 0%,
        rgba(52, 152, 219, 0.9) 100%
    );
    color: white;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.popup-date-info {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.popup-holiday-name {
    display: block;
    font-size: 16px;
    margin-top: 4px;
    font-weight: bold;
}

.popup-content {
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
}

.popup-description {
    font-size: 13px;
    line-height: 1.6;
    color: #34495e;
    padding: 12px 15px;
    margin: 0;
}

.popup-background-section {
    background-color: #ecf0f1;
    border-top: 1px solid #bdc3c7;
    padding: 12px 15px;
    display: none;
}

.popup-background-section.active {
    display: block;
}

.background-title {
    font-size: 12px;
    font-weight: bold;
    color: #2c3e50;
    margin: 0 0 8px 0;
}

.background-text {
    font-size: 12px;
    line-height: 1.5;
    color: #7f8c8d;
    margin: 0;
}

/* ===== スクロールバー ===== */
.popup-content::-webkit-scrollbar {
    width: 6px;
}

.popup-content::-webkit-scrollbar-track {
    background: #ecf0f1;
}

.popup-content::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 3px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* ===== レスポンシブ対応 ===== */
@media (max-width: 768px) {
    .calendar-container {
        padding: 15px;
    }

    .controls {
        gap: 10px;
    }

    .month-display {
        min-width: 100px;
        font-size: 16px;
    }

    .date-picker-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

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

    .header h1 {
        font-size: 20px;
    }

    .dialog-container {
        width: 95%;
    }

    .dialog-button-area {
        flex-direction: column;
    }

    .btn-cancel,
    .btn-confirm {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }

    .calendar-container {
        padding: 10px;
        border-radius: 0;
    }

    .controls {
        gap: 8px;
        margin-bottom: 15px;
    }

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

    .month-display {
        font-size: 14px;
        min-width: 90px;
    }

    .date-picker-btn {
        font-size: 11px;
        padding: 5px 10px;
    }

    .day-cell {
        min-height: 45px;
        font-size: 11px;
        padding: 3px;
    }

    .popup-container {
        max-width: 85%;
    }

    .footer-legend {
        font-size: 11px;
        padding: 8px;
    }
}
