/* 基本リセットとフォント設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* ヘッダースタイル */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    font-weight: 300;
}

.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.month-selector button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background-color 0.3s ease;
}

.month-selector button:hover {
    background: rgba(255,255,255,0.3);
}

#current-month {
    font-size: 1.5rem;
    font-weight: 500;
    min-width: 150px;
}

/* 作業時間サマリー */
.work-summary {
    background: white;
    margin: 20px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.work-time {
    font-size: 1.2rem;
    font-weight: 600;
}

#total-work-time {
    color: #e74c3c;
    font-size: 1.4rem;
}

.schedule-legend {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* スケジュールコンテナ */
.schedule-container {
    margin: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: auto;
}

/* 時間軸ヘッダー */
.time-header {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.day-column {
    width: 120px;
    padding: 15px 10px;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid #dee2e6;
    background: #f8f9fa;
}

.time-labels {
    display: flex;
    flex: 1;
}

.time-label {
    flex: 1;
    padding: 15px 5px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    border-right: 1px solid #dee2e6;
    min-width: 40px;
}

/* スケジュールグリッド */
.schedule-grid {
    /* JavaScriptで動的に生成されるため、基本スタイルのみ */
}

.day-row {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    min-height: 60px;
    position: relative;
}

.day-row:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.day-label {
    width: 120px;
    padding: 20px 10px;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid #dee2e6;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.day-number {
    font-size: 1.5rem;
    color: #667eea;
}

.day-name {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 2px;
}

.schedule-bar {
    flex: 1;
    display: flex;
    position: relative;
    height: 60px;
}

.hour-cell {
    flex: 1;
    border-right: 1px solid #f0f0f0;
    position: relative;
    min-width: 40px;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.hour-cell:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

/* 予定ブロック */
.schedule-block {
    position: absolute;
    top: 5px;
    bottom: 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}

.schedule-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 5;
}

/* 予定種類の色定義 */
.work { background-color: #3b82f6; }
.commute { background-color: #60a5fa; }
.sleep { background-color: #9ca3af; }
.meal { background-color: #fbbf24; }
.drawing { background-color: #ef4444; }
.outing { background-color: #10b981; }

/* 色インジケーター */
.color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 5px;
}

/* ポップアップスタイル */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.popup.hidden {
    display: none;
}

.popup-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.popup-header {
    padding: 25px 30px 15px;
    border-bottom: 1px solid #e9ecef;
}

.popup-header h3 {
    font-size: 1.4rem;
    color: #333;
    margin: 0;
}

.popup-body {
    padding: 25px 30px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.input-group select,
.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#selected-time {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
    background: #f8f9ff;
    padding: 10px 15px;
    border-radius: 6px;
    display: inline-block;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid #e9ecef;
}

.popup-footer {
    padding: 20px 30px 30px;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* ボタンスタイル */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-cancel:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-register {
    background: #667eea;
    color: white;
}

.btn-register:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

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

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-1px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

/* コントロールパネル */
.control-panel {
    margin: 20px;
    text-align: center;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* モーダルスタイル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 25px 30px 15px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #333;
}

.modal-body {
    padding: 25px 30px;
}

.manual-section {
    margin-bottom: 30px;
}

.manual-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid #f0f0f0;
}

.manual-section ul {
    list-style: none;
    padding-left: 0;
}

.manual-section li {
    padding: 8px 0;
    border-left: 3px solid #667eea;
    padding-left: 15px;
    margin-bottom: 8px;
    background: #f8f9ff;
    border-radius: 0 6px 6px 0;
}

/* 選択状態のスタイル */
.selecting {
    background: rgba(102, 126, 234, 0.3) !important;
    border: 2px solid #667eea !important;
}

.selecting-start {
    background: rgba(255, 193, 7, 0.6) !important;
    border: 2px solid #ffc107 !important;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.5);
}

@keyframes pulse {
    0% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(1.02);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}

/* ドラッグ中の状態 */
.dragging .hour-cell {
    cursor: crosshair !important;
}

.schedule-grid.dragging {
    cursor: crosshair !important;
}

.selection-preview {
    position: absolute;
    top: 10px;
    bottom: 10px;
    background: rgba(102, 126, 234, 0.2);
    border: 2px solid #667eea;
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .month-selector {
        flex-direction: column;
        gap: 10px;
    }
    
    .work-summary {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .schedule-legend {
        width: 100%;
    }
    
    .day-label {
        width: 80px;
        padding: 15px 5px;
    }
    
    .day-number {
        font-size: 1.2rem;
    }
    
    .day-name {
        font-size: 0.7rem;
    }
    
    .time-labels {
        min-width: calc(24 * 30px);
    }
    
    .hour-cell {
        min-width: 30px;
    }
    
    .time-label {
        min-width: 30px;
        font-size: 0.7rem;
        padding: 15px 2px;
    }
    
    .schedule-block {
        font-size: 0.7rem;
        padding: 0 4px;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: center;
    }
    
    .popup-content,
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* スクロールバーのカスタマイズ */
.schedule-container::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.schedule-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.schedule-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.schedule-container::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

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

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

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

/* ツールチップスタイル */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}