/* =========================================
   Setae Module: Specific Views
   (Chat, Kanban, Timeline, Detail, Toasts)
   ========================================= */

/* --- Toast Notifications (通知) --- */
#setae-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.setae-toast {
    pointer-events: auto;
    min-width: 280px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideInToast 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1e;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.setae-toast.success {
    border-left: 6px solid #34c759;
}

.setae-toast.error {
    border-left: 6px solid #ff3b30;
}

.setae-toast.info {
    border-left: 6px solid #007aff;
}

@keyframes slideInToast {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Chat UI --- */
.setae-chat-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 10px;
    min-height: 400px;
}

.setae-chat-bubble {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.setae-chat-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #007AFF 0%, #0062cc 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.setae-chat-bubble.mine .setae-chat-meta {
    color: rgba(255, 255, 255, 0.8);
}

.setae-chat-bubble.others {
    align-self: flex-start;
    background-color: #e5e5ea;
    color: #000;
    border-bottom-left-radius: 4px;
}

.setae-chat-bubble.others .setae-chat-meta {
    color: #8e8e93;
}

.setae-chat-meta {
    font-size: 11px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

/* --- Topic List (BBS Style) --- */
.setae-bbs-list {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.setae-bbs-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

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

.setae-bbs-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.setae-bbs-num {
    width: 40px;
    color: #aeaeb2;
    font-size: 14px;
    font-weight: 600;
}

.setae-bbs-title {
    flex-grow: 1;
    font-weight: 600;
    color: #1c1c1e;
}

.setae-bbs-meta {
    color: #8e8e93;
    font-size: 12px;
}

/* --- Log History (Timeline) --- */
.log-history-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: #ffffff;
    border-radius: 16px;
    margin-bottom: 12px;
    align-items: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.log-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.log-content {
    flex-grow: 1;
    min-width: 0;
}

.log-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.log-title {
    font-size: 15px;
    font-weight: 700;
    color: #1c1c1e;
}

.log-date {
    font-size: 12px;
    color: #8e8e93;
}

.log-note-text {
    font-size: 14px;
    color: #3a3a3c;
    line-height: 1.5;
}

.log-image-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    margin-top: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* --- Detail View Hero (Big Card) & Timeline --- */

/* Hero Section */
.setae-spider-hero {
    position: relative;
    height: 280px;
    margin: 5px 5px 20px 5px;
    /* 親のpaddingを打ち消す */
    border-radius: 24px 24px 24px 24px;
    overflow: hidden;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* 3. 背景画像の補正：オーバーレイ（Scrim）を強化 */
/* .hero-backdrop 自体に疑似要素でグラデーションを掛ける */
.hero-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    /* filter: brightness(0.7);  <- Removed, let gradient handle it */
    z-index: 1;
}

.hero-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    /* top:0; left:0; right:0; bottom:0; と同じ */

    /* 上部はボタンのために少し暗く、下部は文字のためにしっかり暗くするグラデーション */
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.3) 0%,
            /* 上部30%の黒（ボタンが見やすくなる） */
            rgba(0, 0, 0, 0.1) 40%,
            /* 中間は写真を綺麗に見せる */
            rgba(0, 0, 0, 0.8) 100%
            /* 下部は80%の黒（文字がくっきり見える） */
        );
    z-index: 1;
    /* 写真より上、文字より下 */
    pointer-events: none;
    /* クリックを邪魔しない */
}

/* コンテンツをグラデーションより上に配置 */
.hero-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    /* 以前の background: linear-gradient... は削除してOK（::after側で制御するため） */
}

.hero-top-bar {
    display: flex;
    justify-content: space-between;
}

/* 1. ボタンのデザイン変更：白背景から「黒半透明＋白枠」へ */
.setae-btn-icon-glass {
    /* 背景を白(rgba(255...))から黒(rgba(0...))に変更し、視認性を確保 */
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    /* 枠線を少し太く、不透明度を上げてくっきりさせる */
    border: 1.5px solid rgba(255, 255, 255, 0.8) !important;
    color: #fff !important;

    /* ボタン自体にも影を落とす */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);

    /* サイズ等の既存スタイルは維持 */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
}

.setae-btn-icon-glass:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.5) !important;
}

/* 2. テキストの視認性強化：強制的に白文字＋濃い影 */
.hero-info h2,
.hero-info p,
.hero-info span {
    /* グローバルの色指定(primaryカラー等)に勝つために !important を使用 */
    color: #ffffff !important;

    /* 濃い影をつけて、白っぽい背景でも浮き上がらせる */
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.hero-info h2 {
    margin: 5px 0 0;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.spider-badge-id {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.species-name {
    margin: 0;
    font-style: italic;
    opacity: 0.9;
    font-size: 14px;
}

/* Container Adjustment */
.setae-detail-container {
    padding: 0 5px 40px 5px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.status-item {
    background: #fff;
    padding: 12px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid #f0f0f5;
}

.status-label {
    display: block;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.status-item strong {
    display: block;
    font-size: 14px;
    color: #333;
}

/* Charts */
.setae-grid-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.dashboard-card {
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    background: #fff;
}

.chart-container {
    height: 200px;
    width: 100%;
}

/* Calendar Section */
.section-calendar {
    position: relative;
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 30px;
    background: #fff;
}

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

.setae-btn-floating {
    width: 100%;
    margin-top: 15px;
    background: var(--setae-primary);
    color: #fff;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

/* Timeline Design (Transforming the Log List) */
.setae-timeline-section h4 {
    margin-left: 10px;
    margin-bottom: 15px;
    color: #555;
}

.timeline-container {
    position: relative;
    padding-left: 20px;
    /* Line space */
}

.timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 9px;
    width: 2px;
    background: #e0e0e0;
}

/* 既存のログカード(.setae-card)をタイムライン風に上書き */
#setae-log-list .setae-card {
    position: relative;
    margin-bottom: 20px !important;
    margin-left: 15px !important;
    border: none !important;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 15px !important;
}

/* Timeline Dot */
#setae-log-list .setae-card::before {
    content: '';
    position: absolute;
    top: 20px;
    left: -21px;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 3px solid var(--setae-primary, #2ecc71);
    /* 色はJSで制御されるボーダー色に合わせたいが一旦固定 */
    border-radius: 50%;
    z-index: 2;
}

/* --- Timeline Animation & Loading --- */
.log-card-animate {
    animation: slideUpFade 0.4s ease-out forwards;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spinner,
.end-of-log {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 13px;
    font-weight: 500;
}

/* --- Kanban Board --- */
.setae-kanban-board {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding: 10px 4px 30px 4px;
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
}

.kanban-col {
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: blur(10px);
    min-width: 280px;
    width: 280px;
    border-radius: 16px;
    padding: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.kanban-header {
    padding: 8px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    color: #1c1c1e;
    margin-bottom: 12px;
}

.kanban-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
    padding: 12px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* --- Context Menu --- */
.setae-context-menu {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 200px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.setae-menu-item {
    padding: 14px 20px;
    font-size: 15px;
    color: #1c1c1e;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.1s;
}

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

.setae-menu-item:hover {
    background: #007AFF;
    color: #fff;
}

/* --- Settings / View Switcher --- */
.setae-view-switch {
    display: inline-flex;
    background: rgba(118, 118, 128, 0.12);
    border-radius: 12px;
    padding: 2px;
    margin-bottom: 16px;
}

.view-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 10px;
    color: #8e8e93;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-btn.active {
    background: #fff;
    color: #007AFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}