/* 資格試験カレンダー - UI改善版スタイルシート */

.study-calendar-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    padding: 10px;
}

/* カレンダーツールバー */
.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.calendar-nav button {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    min-width: 40px;
}

.calendar-nav button:hover {
    background: #005a87;
}

#current-date {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    min-width: 200px;
    text-align: center;
}

.calendar-views {
    display: flex;
    gap: 5px;
}

.view-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.view-btn:hover,
.view-btn.active {
    background: #007cba;
}

#add-event-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

#add-event-btn:hover {
    background: #218838;
}

.view-only {
    background: #6c757d;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
}

/* カレンダー本体 */
#study-calendar {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* 月表示 */
.calendar-month {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #007cba;
    color: white;
    font-weight: 600;
}

.calendar-header-cell {
    padding: 15px 10px;
    text-align: center;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.calendar-header-cell:last-child {
    border-right: none;
}

/* 土日の色分け（控えめに調整） */
.calendar-header-cell:nth-child(6) {
    background: #5a9fd4; /* 土曜日 - より薄い青 */
}

.calendar-header-cell:nth-child(7) {
    background: #e57373; /* 日曜日 - より薄い赤 */
}

.calendar-cell {
    min-height: 120px; /* 高さを増加 */
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    padding: 8px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calendar-cell:hover {
    background-color: #f8f9fa;
}

.calendar-cell:last-child {
    border-right: none;
}

.calendar-cell.other-month {
    background-color: #f8f9fa;
    color: #6c757d;
}

.calendar-cell.today {
    background-color: #e3f2fd;
    border: 2px solid #2196f3;
}

/* 土曜日の背景色（さらに薄く） */
.calendar-cell:nth-child(7n-1) {
    background-color: #f8fbff;
}

.calendar-cell:nth-child(7n-1):hover {
    background-color: #f0f8ff;
}

/* 日曜日の背景色（さらに薄く） */
.calendar-cell:nth-child(7n) {
    background-color: #fffafa;
}

.calendar-cell:nth-child(7n):hover {
    background-color: #fff5f5;
}

.cell-date {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px; /* 下マージンを増加 */
    color: #2c3e50;
    height: 20px; /* 固定高さ */
    display: flex;
    align-items: center;
}

.cell-events {
    display: flex;
    flex-direction: column;
    gap: 3px; /* ギャップを増加 */
    margin-top: 5px; /* 上マージンを追加 */
}

.event-item {
    background: #007cba;
    color: white;
    padding: 3px 6px; /* パディングを増加 */
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s;
    position: relative;
    line-height: 1.2;
}

.event-item:hover {
    opacity: 0.8;
}

/* 複数日イベントのスタイル */
.event-item.multi-day {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 30px; /* 日付の下に配置 */
    z-index: 2;
    border-radius: 0;
    margin: 1px 0;
}

.event-item.multi-day.start {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
}

.event-item.multi-day.end {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

.event-item.multi-day.single {
    border-radius: 3px;
}

.event-item.study { background: #3498db; }
.event-item.exam { background: #e74c3c; }
.event-item.practice { background: #f39c12; }
.event-item.review { background: #27ae60; }
.event-item.mock { background: #9b59b6; }

/* 週表示 */
.calendar-week {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    grid-template-rows: 50px repeat(24, 30px);
}

.week-time-slot {
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    padding: 5px;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    background: #f8f9fa;
}

.week-day-header {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    background: #007cba;
    color: white;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

/* 週表示の土日色分け（控えめに調整） */
.week-day-header:nth-child(7) {
    background: #5a9fd4; /* 土曜日 - より薄い青 */
}

.week-day-header:nth-child(8) {
    background: #e57373; /* 日曜日 - より薄い赤 */
}

.week-day-cell {
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    position: relative;
    cursor: pointer;
}

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

/* 日表示 */
.calendar-day {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-rows: repeat(24, 40px);
}

.day-time-slot {
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    padding: 10px 5px;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    background: #f8f9fa;
}

.day-content-cell {
    border-bottom: 1px solid #e9ecef;
    position: relative;
    cursor: pointer;
    padding: 5px;
}

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

/* モーダル - 小さめに調整 */
.study-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #6c757d;
    z-index: 1001;
}

.close:hover {
    color: #000;
}

#modal-title {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 20px;
    padding-right: 30px;
}

#event-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#event-form label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 3px;
    font-size: 14px;
}

#event-form input,
#event-form textarea,
#event-form select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#event-form input:focus,
#event-form textarea:focus,
#event-form select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

#event-form textarea {
    resize: vertical;
    min-height: 60px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
    flex-wrap: wrap;
}

.modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
    font-size: 14px;
}

.modal-buttons button[type="submit"] {
    background: #28a745;
    color: white;
}

.modal-buttons button[type="submit"]:hover {
    background: #218838;
}

#delete-event-btn {
    background: #dc3545;
    color: white;
}

#delete-event-btn:hover {
    background: #c82333;
}

.cancel-btn {
    background: #6c757d;
    color: white;
}

.cancel-btn:hover {
    background: #5a6268;
}

/* カウントダウン - シンプル版 */
.study-countdown {
    background: linear-gradient(135deg, #007cba, #005a87);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.study-countdown h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 600;
}

.countdown-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.countdown-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 8px;
    min-width: 80px;
    backdrop-filter: blur(10px);
}

.countdown-number {
    display: block;
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.countdown-label {
    display: block;
    font-size: 14px;
    margin-top: 5px;
    opacity: 0.9;
}

/* カウントダウン - 日数のみ版 */
.countdown-simple {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.countdown-simple .countdown-item {
    min-width: 100px;
}

.countdown-simple .countdown-number {
    font-size: 48px;
}

/* 予定一覧 */
.study-schedule-list {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.study-schedule-list h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 20px;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.schedule-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.schedule-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s;
}

.schedule-item:hover {
    background-color: #f8f9fa;
}

.schedule-item:last-child {
    border-bottom: none;
}

.event-color {
    width: 4px;
    height: 100%;
    min-height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.event-info h4 {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 16px;
}

.event-date {
    margin: 0 0 8px 0;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
}

.event-description {
    margin: 0 0 5px 0;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.4;
}

.event-duration {
    margin: 0;
    color: #007cba;
    font-size: 13px;
    font-weight: 600;
}

/* 通知メッセージ */
.study-calendar-notice,
.study-schedule-notice {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin: 20px 0;
}

.study-calendar-notice p,
.study-schedule-notice p {
    margin: 0 0 10px 0;
    color: #1565c0;
}

.study-calendar-notice a,
.study-schedule-notice a {
    color: #0d47a1;
    text-decoration: none;
    font-weight: 600;
}

.study-calendar-notice a:hover,
.study-schedule-notice a:hover {
    text-decoration: underline;
}

/* カウントダウン終了時 */
.countdown-expired {
    font-size: 24px;
    font-weight: bold;
    color: #e74c3c;
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .study-calendar-container {
        padding: 5px;
    }
    
    .calendar-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .calendar-nav {
        justify-content: center;
    }
    
    .calendar-views {
        justify-content: center;
    }
    
    #add-event-btn,
    .view-only {
        width: 100%;
        text-align: center;
    }
    
    .calendar-cell {
        min-height: 80px;
        padding: 4px;
    }
    
    .countdown-display {
        gap: 10px;
    }
    
    .countdown-item {
        min-width: 60px;
        padding: 10px;
    }
    
    .countdown-number {
        font-size: 24px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-height: 85vh;
    }
    
    .schedule-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .event-color {
        width: 100%;
        height: 4px;
        min-height: 4px;
    }
    
    .modal-buttons {
        justify-content: stretch;
    }
    
    .modal-buttons button {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .calendar-header-cell,
    .cell-date {
        font-size: 12px;
    }
    
    .event-item {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .calendar-cell {
        min-height: 60px;
        padding: 2px;
    }
    
    #current-date {
        font-size: 16px;
        min-width: 150px;
    }
    
    .countdown-item {
        min-width: 50px;
        padding: 8px;
    }
    
    .countdown-number {
        font-size: 20px;
    }
    
    .countdown-label {
        font-size: 12px;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.event-item {
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    animation: fadeIn 0.3s ease-out;
}

/* ローディング状態 */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

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