/* ============================================================
 * AstroInsight - styles.css（v5）
 * 要件§21: モバイルファースト、タップハイライト無効、Safe Area対応
 * 要件§21: 詳細画面は右からスライドイン、タブ切替はフェードイン
 * ============================================================ */

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: #f8fafc;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    color: #0f172a;
    overscroll-behavior: none;
}
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

#app-root {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
}

/* ---- タブ切替フェードイン（要件§21） ---- */
.tab-content {
    display: none;
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.tab-content.active {
    display: block;
    opacity: 1;
}
.tab-content:not(.active) {
    display: none !important;
}

/* ---- スライドイン画面（要件§21 §11 §12 §13 §15 詳細・設定・相性フォーム） ---- */
.slide-in-screen {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: #f8fafc;
    transform: translateX(100%);
    transition: transform 250ms ease-out;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
}
.slide-in-screen.slide-in-active { transform: translateX(0); }
.slide-in-screen.hidden { display: none !important; }

/* ---- オンボーディング全画面（要件§9） ---- */
#onboarding-screen {
    position: fixed; inset: 0; z-index: 60;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top);
}
#onboarding-screen.hidden { display: none !important; }

/* ---- チャットバブル（要件§14） ---- */
.chat-user {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}
.chat-ai {
    background: #fff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-radius: 18px 18px 18px 4px;
}

/* ---- 下部ナビ（要件§10 §21） ---- */
.glass-nav {
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    padding: 8px 4px;
    transition: color 150ms;
}
.nav-btn.active-nav { color: #4f46e5; }
.nav-btn i { font-size: 20px; }
.nav-btn span { font-size: 10px; margin-top: 2px; }

/* ---- 主コンテンツ領域（タブバーぶん下にパディング） ---- */
.main-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---- Markdown表示 ---- */
.markdown-body { line-height: 1.7; font-size: 14px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-weight: bold; margin-top: 1em; margin-bottom: 0.5em; color: #4f46e5;
}
.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.2em; }
.markdown-body h3 { font-size: 1.05em; }
.markdown-body p { margin: 0.5em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin: 0.5em 0; }
.markdown-body li { margin: 0.2em 0; }
.markdown-body strong { color: #4f46e5; }
.markdown-body code {
    background: #f1f5f9; padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em;
}

/* ---- Tailwind では出ない補助色 ---- */
.text-astro { color: #4f46e5; }
.bg-astro { background-color: #4f46e5; }
.bg-astro-dark { background-color: #4338ca; }
.bg-astro-light { background-color: #eef2ff; }
.border-astro { border-color: #4f46e5; }
.border-l-astro { border-left-color: #4f46e5; }
.hover\:bg-astro-dark:hover { background-color: #4338ca; }
.hover\:text-astro-dark:hover { color: #4338ca; }

/* ---- ローディングドット ---- */
.dot-flashing {
    position: relative;
    width: 8px; height: 8px;
    border-radius: 50%;
    background-color: #4f46e5;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: 0.5s;
    margin: 0 12px;
}
@keyframes dotFlashing {
    0% { background-color: #4f46e5; }
    50%, 100% { background-color: rgba(79,70,229,0.2); }
}

/* ---- フォーム入力共通 ---- */
input[type="text"], input[type="date"], input[type="time"],
input[type="number"], input[type="password"], textarea, select {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

/* ---- FAB（追加ボタン） ---- */
.fab {
    position: absolute;
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 6px 18px rgba(79,70,229,0.4);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    z-index: 20;
}

/* ---- 起動時スプラッシュ ---- */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 28%),
        linear-gradient(135deg, #312e81 0%, #7c3aed 56%, #ec4899 100%);
    color: #fff;
    transition: opacity 320ms ease, visibility 320ms ease;
}
#splash-screen.splash-hide {
    opacity: 0;
    visibility: hidden;
}
.splash-card {
    position: relative;
    width: min(86vw, 340px);
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 28px;
    background: rgba(255,255,255,0.12);
    box-shadow: 0 28px 90px rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
}
.splash-logo {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
    font-size: 34px;
    margin-bottom: 18px;
}
.splash-card h1 {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 0.02em;
    margin: 0 0 8px;
}
#splash-status {
    font-size: 12px;
    color: rgba(255,255,255,0.78);
}
.splash-orbit {
    position: absolute;
    width: 190px;
    height: 190px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 50%;
    animation: splashOrbit 5.5s linear infinite;
}
.splash-orbit span {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 16px rgba(255,255,255,0.9);
}
.splash-orbit span:nth-child(1) { top: -4px; left: 91px; }
.splash-orbit span:nth-child(2) { right: 16px; bottom: 30px; opacity: 0.72; }
.splash-orbit span:nth-child(3) { left: 18px; bottom: 28px; opacity: 0.55; }
@keyframes splashOrbit { to { transform: rotate(360deg); } }

/* 管理設定はオンボーディングより前面に出せるようにする */
#settings-screen.slide-in-screen { z-index: 80; }
#detail-screen.slide-in-screen { z-index: 70; }
#compat-form-screen.slide-in-screen { z-index: 70; }
