/* styles.css */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    overscroll-behavior-x: none;
}

body {
    background-color: #E9EDF0; /* ultra-premium cool slate light background */
}

/* Custom Scrollbar for light theme */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* slate-300 */
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8; /* slate-400 */
}

/* Timer Ring Animation Helpers */
#timer-progress {
    transition: stroke-dashoffset 1s linear;
}

/* Custom Brand Colors Utility Classes */
.bg-brand-blue { background-color: #489CC1 !important; }
.hover\:bg-brand-blue-dark:hover { background-color: #3886a8 !important; }
.text-brand-blue { color: #489CC1 !important; }
.border-brand-blue { border-color: #489CC1 !important; }
.focus\:ring-brand-blue:focus { --tw-ring-color: #489CC1 !important; }

.bg-brand-red { background-color: #FF7272 !important; }
.hover\:bg-brand-red-dark:hover { background-color: #e55c5c !important; }
.text-brand-red { color: #FF7272 !important; }
.stroke-brand-red { stroke: #FF7272 !important; }
.focus\:ring-brand-red:focus { --tw-ring-color: #FF7272 !important; }

.bg-brand-green { background-color: #8ebb9d !important; }
.hover\:bg-brand-green-dark:hover { background-color: #72967e !important; }
.text-brand-green { color: #8ebb9d !important; }
.stroke-brand-green { stroke: #8ebb9d !important; }
.focus\:ring-brand-green:focus { --tw-ring-color: #8ebb9d !important; }

.stroke-brand-track { stroke: #E6E9EF !important; }

/* Custom Brand Shadow for primary sky-blue play button */
.shadow-brand-blue {
    box-shadow: 0 10px 15px -3px rgba(72, 156, 193, 0.3), 0 4px 6px -2px rgba(72, 156, 193, 0.05) !important;
}

/* Task Item Hover & Active states (Light Theme) */
.task-item {
    transition: all 0.2s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.task-item:hover {
    border-color: #489CC1; /* brand-blue */
    background-color: rgba(230, 233, 239, 0.4); /* soft E6E9EF tint */
}
.task-item.active {
    border-color: #489CC1; /* brand-blue */
    background-color: #E6E9EF; /* solid user color E6E9EF as card active background */
    box-shadow: 0 0 0 1px #489CC1 inset;
}
/* サブタスク選択時: border-l-2 (2px) を 1px に戻して上下右と揃える */
.task-item.active.border-l-2 {
    border-left-width: 1px;
}

/* Number input styling (remove arrows) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Dialog Fade animations */
.dialog-show {
    opacity: 1 !important;
}
.dialog-box-show {
    transform: scale(1) !important;
}

.-rotate-90 {
    transform: rotate(-90deg) !important;
}

/* Drag and Drop styling */
.task-item.dragging {
    opacity: 0.5;
    touch-action: none !important;
}
.task-item.drag-over {
    border-color: #489CC1 !important;
    background-color: rgba(72, 156, 193, 0.1) !important;
    transform: scale(1.02) translateZ(0);
    box-shadow: 0 4px 12px rgba(72, 156, 193, 0.15) !important;
    position: relative;
    z-index: 10;
}
/* タスク間の横線インジケーター（::before = 上に挿入、::after = 下に挿入） */
.task-item.drag-over-top {
    box-shadow: none !important;
    border-color: inherit !important;
    transition: none !important;
}
.task-item.drag-over-top::before {
    content: '';
    position: absolute;
    top: -7px; /* space-y-3 = 12px の中央付近 */
    left: 0;
    right: 0;
    height: 3px;
    background-color: #489CC1;
    border-radius: 2px;
    z-index: 20;
}
.task-item.drag-over-bottom {
    box-shadow: none !important;
    border-color: inherit !important;
    transition: none !important;
}
.task-item.drag-over-bottom::after {
    content: '';
    position: absolute;
    bottom: -7px; /* space-y-3 = 12px の中央付近 */
    left: 0;
    right: 0;
    height: 3px;
    background-color: #489CC1;
    border-radius: 2px;
    z-index: 20;
}
/* ドラッグ線インジケーターがスクロールコンテナにクリップされないよう補正 */
#task-list-container {
    overflow-x: hidden;
}

/* iOS Safariで入力フィールドフォーカス時の自動ズームを防止および画面の横揺れバウンス防止 */
@media (max-width: 767px) {
    /* 縦スクロールを復元しつつ、横スクロール・横バウンスのみを完全禁止 */
    html, body {
        position: relative; /* fixed を解除 */
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 100%;
        overflow-x: hidden; /* 横方向のスクロールを禁止 */
        overflow-y: auto;   /* 縦方向のスクロールを明示的に許可 */
        overscroll-behavior-x: none; /* 横方向の履歴ジェスチャーやバウンスのみ禁止 */
        touch-action: pan-y; /* 縦スクロール操作のみを許可し、横方向へのブレを防止 */
    }

    body {
        display: flex;
        flex-direction: column;
    }

    /* 内部のスクロール可能コンテナも、縦方向のスクロールのみを許可 */
    #cal-days-grid,
    #timeline-scroll-area,
    #day-timeline-grid,
    .overflow-y-auto {
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    /* タスクアイテム自体は通常時は縦スクロールを許可し、横ブレを防止 */
    .task-item {
        touch-action: pan-y;
    }

    input[type="text"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* カレンダー当日用 (青い丸枠で囲み、かつ青文字) */
.picker-today-circle {
    border: 2px solid #489CC1 !important;
    color: #489CC1 !important;
    font-weight: 700;
    border-radius: 9999px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* 選択された日付用 (青い丸で塗りつぶし、白抜き文字) */
.picker-selected-day {
    background-color: #489CC1 !important;
    color: white !important;
    font-weight: 700;
    border-radius: 9999px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* ピッカー用日付セルの基本ホバー効果 */
.picker-day-cell {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 9999px;
    transition: background-color 0.2s;
}
.picker-day-cell:hover:not(.picker-selected-day) {
    background-color: #e5e7eb;
}

/* Day View Filter Buttons */
.day-filter-completed-active {
    border-color: #8ebb9d !important;
    background-color: rgba(142, 187, 157, 0.15) !important;
    color: #4a6b56 !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

.day-filter-incomplete-active {
    border-color: #489CC1 !important;
    background-color: rgba(72, 156, 193, 0.1) !important;
    color: #2b6d8a !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

.day-filter-inactive {
    border-color: #e2e8f0 !important; /* border-slate-200 */
    background-color: rgba(248, 250, 252, 0.5) !important; /* bg-slate-50/50 */
    color: #cbd5e1 !important; /* text-slate-300 */
}

/* 画面フラッシュエフェクト */
.flash-active-focus {
    animation: flash-focus-animation 1.5s ease-out forwards;
}
.flash-active-break {
    animation: flash-break-animation 1.5s ease-out forwards;
}
@keyframes flash-focus-animation {
    0%, 100% { opacity: 0; background-color: transparent; }
    25%, 75% { opacity: 0.4; background-color: rgba(72, 156, 193, 0.4); } /* ブランドブルーでフラッシュ */
    50% { opacity: 0.1; background-color: transparent; }
}
@keyframes flash-break-animation {
    0%, 100% { opacity: 0; background-color: transparent; }
    25%, 75% { opacity: 0.4; background-color: rgba(142, 187, 157, 0.4); } /* ブランドグリーンでフラッシュ */
    50% { opacity: 0.1; background-color: transparent; }
}

/* Timeline Drag and Drop Preview */
#timeline-drag-preview {
    position: absolute;
    left: 56px;
    width: calc(100% - 64px);
    border: 2px dashed #489CC1;
    background-color: rgba(72, 156, 193, 0.2);
    border-radius: 6px;
    pointer-events: none;
    z-index: 50;
    transition: top 0.05s ease-out, height 0.1s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4px 8px;
    box-sizing: border-box;
}

.timeline-drag-preview-title {
    font-size: 12px;
    font-weight: 700;
    color: #2b6d8a;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.timeline-drag-preview-time {
    font-size: 10px;
    color: #3886a8;
    font-weight: 600;
    line-height: 1.2;
    margin-top: 1px;
}

/* Task Resize Handle */
.task-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background-color: transparent;
    z-index: 10;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    transition: background-color 0.2s;
    touch-action: none; /* タッチデバイスでの不要なブラウザスクロールを防止 */
}

.task-resize-handle:hover {
    background-color: rgba(72, 156, 193, 0.4);
}

/* Task Hover Tooltip */
.task-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background-color: #1e293b; /* slate-800 */
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.task-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

/* ホバー時に表示 */
.cursor-grab:hover .task-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ドラッグ中は非表示 */
.cursor-grab.opacity-50 .task-tooltip {
    display: none !important;
}

/* Mini Mode Settings for Chrome Extension Popup */
body.mini-mode {
    background: #FFFFFF !important;
    width: 220px !important;
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.mini-mode #flash-overlay {
    display: none !important;
}

/* Hide background decorations */
body.mini-mode div[class*="blur-[120px]"] {
    display: none !important;
}

/* Hide everything except timer view */
body.mini-mode #app-header,
body.mini-mode #sidebar-navigation,
body.mini-mode #task-side,
body.mini-mode .task-area,
body.mini-mode #calendar-content-view,
body.mini-mode #dashboard-content-view,
body.mini-mode #tasks-content-view,
body.mini-mode #timer-settings-panel,
body.mini-mode #timer-content-view > button:not(#btn-pip-minimize), /* Settings gear button */
body.mini-mode #timer-content-view > .absolute.top-8.w-full.px-12, /* Current Task Info */
body.mini-mode #timer-content-view > .flex.gap-4.mt-8, /* Control buttons */
body.mini-mode footer,
body.mini-mode #dashboard-section,
body.mini-mode #timer-side > div.absolute.top-6.left-6,
body.mini-mode #cal-view-selector,
body.mini-mode #mobile-tab-bar {
    display: none !important;
}

body.mini-mode #timer-side {
    position: fixed !important;
    inset: 0 !important;
    width: 220px !important;
    height: 100% !important;
    min-height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Expand timer content view to fill the whole screen */
body.mini-mode main {
    padding: 0 !important;
    margin: 0 !important;
    width: 220px !important;
    height: 100vh !important;
    min-height: 100vh !important;
}

body.mini-mode #view-login {
    display: none !important;
}

body.mini-mode main > #view-app {
    padding: 0 !important;
    margin: 0 !important;
    width: 220px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
}

body.mini-mode #timer-content-view {
    position: fixed !important;
    inset: 0 !important;
    width: 220px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    cursor: pointer !important; /* Click to restore normal size */
    transform: none !important;
}

body.mini-mode #timer-content-view .relative.w-64.h-64 {
    width: 190px !important;
    height: 190px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.mini-mode #timer-display {
    font-size: 3.5rem !important; /* Scale down slightly for 220px window */
}

body.mini-mode #timer-mode {
    font-size: 0.75rem !important;
    margin-top: 4px !important;
}

/* ミニタイマー連動トグルボタンのスタイル */
body.mini-mode #btn-toggle-mini-mode {
    display: none !important;
}

/* PiP Minimize Button */
#btn-pip-minimize {
    display: none;
}
body.mini-mode #btn-pip-minimize {
    display: flex !important;
    position: absolute !important;
    top: 16px !important;
    right: 16px !important;
    z-index: 50 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
}

/* ミニタイマー動作中プレースホルダーの初期状態とアクティブ状態 */
#mini-mode-placeholder {
    display: none;
}
body.mini-mode #mini-mode-placeholder {
    display: flex !important;
}



