/* リセットとベースフォント */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* カレンダーコントロール */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.week-display {
    flex: 1;
    text-align: center;
}

.week-display span {
    font-size: 1.2rem;
    font-weight: 600;
    color: #4c51bf;
}

/* ボタンスタイル */
.btn {
    background: #4c51bf;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: #434190;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 81, 191, 0.3);
}

.btn-nav {
    background: #6366f1;
    min-width: 120px;
}

.btn-secondary {
    background: #6b7280;
}

.btn-secondary:hover {
    background: #555e70;
}

.btn-primary {
    background: #059669;
}

.btn-primary:hover {
    background: #047857;
}

/* カレンダーラッパー */
.calendar-wrapper {
    display: flex;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden;
    height: auto;
}

/* 時間列 */
.time-column {
    background: #f8fafc;
    border-right: 2px solid #e2e8f0;
    min-width: 100px;
}

.time-header {
    padding: 15px;
    background: #4c51bf;
    color: white;
    text-align: center;
    font-weight: 600;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-slots {
    display: flex;
    flex-direction: column;
}

.time-slot {
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
}

/* 時間列ハイライト */
.time-slot.highlighted {
    background: #3b82f6;
    color: white;
    font-weight: 600;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    z-index: 10;
    position: relative;
}

.time-slot.selecting-highlight {
    background: #93c5fd;
    color: white;
    font-weight: 600;
}

.time-slot.current-time {
    background: #f59e0b;
    color: white;
    font-weight: 700;
    position: relative;
}

.time-slot.current-time::before {
    content: '●';
    position: absolute;
    left: 5px;
    font-size: 0.8rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* カレンダーグリッド */
.calendar-grid {
    flex: 1;
    display: flex;
}

.day-column {
    flex: 1;
    border-right: 1px solid #e2e8f0;
}

.day-column:last-child {
    border-right: none;
}

.day-header {
    padding: 15px;
    text-align: center;
    background: #f1f5f9;
    font-weight: 600;
    color: #334155;
    border-bottom: 2px solid #e2e8f0;
    height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.day-header .day-name {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 2px;
}

.day-header .day-date {
    font-size: 1rem;
    font-weight: 700;
}

.day-header.today {
    background: #ddd6fe;
    color: #5b21b6;
}

.day-header.weekend {
    background: #fef3c7;
    color: #92400e;
}

.day-slots {
    display: flex;
    flex-direction: column;
}

.time-cell {
    height: 35px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    user-select: none;
}

.time-cell:hover {
    background: #e0f2fe;
}

.time-cell.selected {
    background: #60a5fa;
    color: white;
}

.time-cell.selecting {
    background: #93c5fd;
}

.time-cell-end {
    background: #f9fafb;
    cursor: not-allowed;
    color: #9ca3af;
}

.time-cell-end:hover {
    background: #f3f4f6;
}

/* 選択パネル */
.selection-panel {
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    padding: 25px;
    margin-bottom: 20px;
}

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.selection-header h3 {
    color: #334155;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-actions {
    display: flex;
    gap: 10px;
}

.selected-schedules {
    min-height: 120px;
}

.empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
    opacity: 0.5;
}

.schedule-item {
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.schedule-item:hover {
    background: #e0f7fa;
    transform: translateX(5px);
}

.schedule-text {
    font-weight: 500;
    color: #0f766e;
}

.schedule-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-copy-single {
    background: #10b981;
}

.btn-copy-single:hover {
    background: #059669;
}



/* トースト通知 */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #059669;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* 確認ダイアログ */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dialog-overlay.show {
    opacity: 1;
    visibility: visible;
}

.dialog-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s ease;
}

.dialog-overlay.show .dialog-content {
    transform: scale(1) translateY(0);
}

.dialog-header {
    padding: 25px;
    background: #fef2f2;
    border-bottom: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dialog-header i {
    color: #dc2626;
    font-size: 1.3rem;
}

.dialog-header h3 {
    color: #991b1b;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.dialog-body {
    padding: 25px;
}

.dialog-body p {
    color: #374151;
    margin-bottom: 15px;
    font-size: 1rem;
}

.schedule-preview {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 15px;
    font-weight: 500;
    color: #1f2937;
    text-align: center;
}

.dialog-actions {
    padding: 20px 25px;
    background: #f9fafb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* 削除アニメーション */
.schedule-item.removing {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    0% {
        transform: translateX(0);
        opacity: 1;
        max-height: 100px;
        margin-bottom: 10px;
        padding: 12px 15px;
    }
    50% {
        transform: translateX(50px);
        opacity: 0;
    }
    100% {
        transform: translateX(100px);
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding: 0 15px;
        overflow: hidden;
    }
}

/* ホバー時の削除ボタン強調 */
.schedule-item .btn-small:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.schedule-item .btn-copy-single:hover {
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* モバイル対応（タブレット以下） */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    .header .subtitle {
        font-size: 0.95rem;
    }

    .calendar-controls {
        flex-direction: column;
        gap: 12px;
        padding: 15px;
        border-radius: 12px;
    }

    .week-display {
        order: -1;
    }

    .week-display span {
        font-size: 1.1rem;
    }

    /* カレンダー横スクロール対応 */
    .calendar-wrapper {
        overflow-x: hidden;
        border-radius: 12px;
    }

    .calendar-grid {
        display: flex;
        width: 100%;
    }

    .time-column {
        width: 50px;
        min-width: 50px;
        flex-shrink: 0;
    }

    .day-column {
        flex: 1;
        min-width: 0;
    }

    .time-header {
        height: 45px;
        padding: 6px 4px;
        font-size: 0.7rem;
    }

    .day-header {
        height: 45px;
        padding: 6px 2px;
        font-size: 0.7rem;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .time-cell {
        height: 28px;
        border-bottom: 1px solid #f1f5f9;
    }

    .time-slot {
        height: 28px;
        font-size: 0.65rem;
        padding: 0 2px;
    }

    /* タッチ操作最適化 */
    .time-cell {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
        tap-highlight-color: rgba(59, 130, 246, 0.3);
    }

    /* 選択パネル */
    .selection-panel {
        padding: 18px;
        border-radius: 12px;
    }

    .selection-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .selection-header h3 {
        font-size: 1.2rem;
        text-align: center;
    }

    .selection-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .schedule-item {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 12px;
        padding: 15px;
        border-radius: 10px;
    }

    .schedule-text {
        font-size: 1rem;
        font-weight: 600;
    }

    .schedule-actions {
        justify-content: center;
        gap: 15px;
    }

    /* ボタン最適化 */
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        border-radius: 10px;
        min-height: 44px; /* タッチ推奨サイズ */
    }

    .btn-small {
        padding: 10px 15px;
        font-size: 0.85rem;
        min-width: 44px;
        min-height: 44px;
    }

    /* ダイアログのモバイル対応 */
    .dialog-content {
        max-width: 95%;
        margin: 0 10px;
        border-radius: 12px;
    }

    .dialog-header,
    .dialog-body,
    .dialog-actions {
        padding: 20px;
    }

    .dialog-actions {
        flex-direction: column;
        gap: 12px;
    }

    .dialog-actions .btn {
        width: 100%;
        font-size: 1rem;
    }

    /* トースト */
    .toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        border-radius: 10px;
        text-align: center;
    }
}

/* スマートフォン対応（480px以下） */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .header h1 {
        font-size: 1.6rem;
        margin-bottom: 5px;
    }

    .header .subtitle {
        font-size: 0.9rem;
    }

    .calendar-controls {
        padding: 12px;
        gap: 10px;
    }

    .week-display span {
        font-size: 1rem;
    }

    .btn-nav {
        min-width: 100px;
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* カレンダー */
    .calendar-wrapper {
        border-radius: 10px;
        overflow-x: hidden;
    }

    .calendar-grid {
        display: flex;
        width: 100%;
    }

    .time-column {
        width: 40px;
        min-width: 40px;
        flex-shrink: 0;
    }

    .day-column {
        flex: 1;
        min-width: 0;
    }

    .time-header {
        height: 40px;
        padding: 4px 2px;
        font-size: 0.65rem;
    }

    .day-header {
        height: 40px;
        padding: 4px 1px;
        font-size: 0.65rem;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .day-header .day-name {
        font-size: 0.6rem;
        margin-bottom: 1px;
    }

    .day-header .day-date {
        font-size: 0.75rem;
    }

    .time-cell {
        height: 26px;
    }

    .time-slot {
        height: 26px;
        font-size: 0.6rem;
        padding: 0 1px;
    }

    /* 選択パネル */
    .selection-panel {
        padding: 15px;
        margin-bottom: 15px;
    }

    .selection-header h3 {
        font-size: 1.1rem;
    }

    .schedule-item {
        padding: 12px;
        margin-bottom: 8px;
    }

    .schedule-text {
        font-size: 0.9rem;
    }

    /* ボタン */
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .btn-small {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 40px;
        min-height: 40px;
    }

    /* ダイアログ */
    .dialog-content {
        max-width: 98%;
        margin: 0 5px;
    }

    .dialog-header,
    .dialog-body,
    .dialog-actions {
        padding: 15px;
    }

    .dialog-header h3 {
        font-size: 1.1rem;
    }

    .dialog-body p {
        font-size: 0.9rem;
    }

    /* トースト */
    .toast {
        bottom: 15px;
        right: 15px;
        left: 15px;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}