/* Y-Advisor Corporate Value Diagnosis Styles */

.yad-diagnosis-wrapper {
    /* Mapping to Blocksy Theme Palette where possible, fallback to mockup colors */
    --primary: var(--theme-palette-color-3, #1e3a5f);
    --accent: #d35400; /* Custom orange CTA */
    --bg: var(--theme-palette-color-7, #eef2f8);
    --text: var(--theme-palette-color-4, #2c3e50);
    --border: var(--theme-palette-color-5, #cbd5e1);
    
    font-family: inherit; /* inherit from Blocksy */
    color: var(--text);
    line-height: 1.8;
}

/* Base resets inside wrapper */
.yad-diagnosis-wrapper * { box-sizing: border-box; }
.yad-diagnosis-wrapper a { text-decoration: none; color: var(--primary); }
.yad-diagnosis-wrapper a:hover { color: var(--theme-palette-color-1, #0056b3); }

/* Common Structural Elements */
.yad-container { max-width: 900px; margin: 3rem auto; padding: 0 1rem; }
.yad-hero { text-align: center; padding: 4rem 2rem; background: var(--theme-palette-color-8, white); border-bottom: 1px solid var(--border); position: relative; }
.yad-hero h1 { font-size: 2.5rem; color: var(--primary); margin-bottom: 1rem; font-weight: 900; }
.yad-hero p { font-size: 1.2rem; margin-bottom: 2rem; color: #555; }

.yad-box { background: var(--theme-palette-color-8, white); border-radius: 8px; padding: 2.5rem; margin-bottom: 2rem; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid var(--border); }
.yad-box h2, .yad-box h3 { color: var(--primary); margin-top: 0; }
.yad-box h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; }

/* Buttons */
.yad-btn { display: inline-block; width: 100%; text-align: center; background: linear-gradient(135deg, #f39c12 0%, var(--accent) 100%); color: white !important; padding: 1.2rem; border-radius: 8px; font-size: 1.3rem; font-weight: bold; border: none; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 6px 15px rgba(211,84,0,0.3); }
.yad-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(211,84,0,0.4); color: white !important; }

/* Checklists */
.yad-checklist { list-style: none; padding: 0; }
.yad-checklist li { position: relative; padding-left: 2rem; margin-bottom: 1rem; text-align: left; }
.yad-checklist li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: bold; }

/* Forms */
.yad-form-group { margin-bottom: 1.5rem; }
.yad-form-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; font-size: 0.95rem; color: var(--text); }
.yad-diagnosis-wrapper input[type="text"], 
.yad-diagnosis-wrapper input[type="number"], 
.yad-diagnosis-wrapper input[type="email"], 
.yad-diagnosis-wrapper input[type="tel"], 
.yad-diagnosis-wrapper select { 
    width: 100%; padding: 0.9rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1.05rem; background: var(--theme-palette-color-7, #fafbfc); transition: 0.2s; 
}
.yad-diagnosis-wrapper input:focus, .yad-diagnosis-wrapper select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(58, 79, 102, 0.1); }
.yad-diagnosis-wrapper .yad-number-input { text-align: right; font-variant-numeric: tabular-nums; }

/* Industry selects: force readable text across browser/theme combinations */
.yad-diagnosis-wrapper .yad-industry-select {
    color: #2c3e50 !important;
    background-color: #fff !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif !important;
    font-size: 1rem !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    text-indent: 0 !important;
    text-transform: none !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    -webkit-text-fill-color: #2c3e50 !important;
    text-shadow: none !important;
    box-sizing: border-box !important;
    display: block;
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 2.5rem 0 0.9rem !important;
    background-position: right 12px center !important;
    vertical-align: middle;
    opacity: 1;
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
}

.yad-diagnosis-wrapper .yad-industry-select:required:invalid {
    color: #667085 !important;
    -webkit-text-fill-color: #667085 !important;
}

.yad-diagnosis-wrapper .yad-industry-select:disabled,
.yad-diagnosis-wrapper .yad-industry-select[disabled] {
    color: #475467 !important;
    -webkit-text-fill-color: #475467 !important;
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    opacity: 1 !important;
}

.yad-diagnosis-wrapper .yad-industry-select option:checked,
.yad-diagnosis-wrapper .yad-industry-select option[selected] {
    color: #1f2937 !important;
    background-color: #e8eef5 !important;
}

.yad-diagnosis-wrapper .yad-industry-select option {
    color: #1f2937 !important;
    background-color: #fff !important;
}

/* Grid Systems */
.yad-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
@media (max-width: 600px) {
    .yad-grid-2col { grid-template-columns: 1fr; gap: 1rem; }
    /* 9-1: Prevent iOS zoom on focus (requires font-size >= 16px) */
    .yad-diagnosis-wrapper input[type="text"],
    .yad-diagnosis-wrapper input[type="number"],
    .yad-diagnosis-wrapper input[type="email"],
    .yad-diagnosis-wrapper input[type="tel"],
    .yad-diagnosis-wrapper select { font-size: 16px; min-height: 44px; }
    /* Radar chart height on mobile */
    #yadRadarChart { height: 260px !important; }
    /* Larger tap targets for buttons */
    .yad-btn { min-height: 52px; }
}

/* Loading spinner animation */
@keyframes yadSpin {
    to { transform: rotate(360deg); }
}

/* Section Titles */
.yad-section-title { font-size: 1.25rem; margin: 2.5rem 0 1.5rem; color: var(--primary); border-bottom: 2px solid var(--border); padding-bottom: 0.8rem; display: flex; align-items: center; font-weight: bold; }
.yad-section-number { background: var(--primary); color: white; border-radius: 50%; width: 28px; height: 28px; display: inline-flex; justify-content: center; align-items: center; font-size: 1rem; margin-right: 0.8rem; font-weight: normal; }

/* Upload Area */
.yad-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1rem; }
.yad-ocr-upload { border: 2px dashed var(--border); padding: 2rem 1rem; text-align: center; border-radius: 8px; background: var(--theme-palette-color-7, #f8fafc); cursor: pointer; transition: 0.3s; }
.yad-ocr-upload:hover { border-color: var(--primary); background: var(--theme-palette-color-6, #f1f5f9); }
.yad-separator { display: flex; align-items: center; text-align: center; color: #94a3b8; margin: 2.5rem 0; font-weight: bold; }
.yad-separator::before, .yad-separator::after { content: ''; flex: 1; border-bottom: 1px dashed var(--border); }
.yad-separator:not(:empty)::before { margin-right: 1em; }
.yad-separator:not(:empty)::after { margin-left: 1em; }

/* Form Background Highlight */
.yad-bg-box { background: var(--theme-palette-color-7, #f8fafc); padding: 2rem; border-radius: 8px; border: 1px solid var(--border); }
.yad-table-header { font-size: 1.1rem; font-weight: bold; color: var(--primary); border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 1.5rem; text-align: center; }

/* Results specifics */
.yad-priority-box { background: white; border-left: 5px solid var(--accent); padding: 1.5rem 2rem; margin-bottom: 2rem; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.yad-priority-box h2 { color: var(--accent); margin-top:0; font-size: 1.5rem; }
.yad-priority-tag { display: inline-block; padding: 0.3rem 0.8rem; border-radius: 4px; color: white; font-weight: bold; font-size: 0.9rem; margin-bottom: 1rem; }
.yad-tag-red { background: #e74c3c; } .yad-tag-yellow { background: #f1c40f; color: #333; } .yad-tag-green { background: #2ecc71; }

.yad-note-bubble {
    position: relative;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    margin-top: 1rem;
    color: #55606e;
    font-size: 0.92rem;
    line-height: 1.7;
}

.yad-note-bubble::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 24px;
    border-width: 0 10px 10px 10px;
    border-style: solid;
    border-color: transparent transparent var(--border) transparent;
}

.yad-note-bubble::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 25px;
    border-width: 0 9px 9px 9px;
    border-style: solid;
    border-color: transparent transparent #f8fafc transparent;
}

.yad-subtle-link {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.95rem;
    font-weight: bold;
    text-decoration: underline;
}

.yad-mini-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem 1.3rem;
}

/* 通常画面ではロゴを完全に非表示（印刷時のみ表示） */
.yad-result-report .yad-print-logo {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 5mm;
    }

    body {
        background: #fff !important;
    }

    body * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body header,
    body footer,
    body aside,
    body .ct-header,
    body .ct-footer,
    body .ct-breadcrumbs,
    body .ct-share-box,
    body .ct-back-to-top {
        display: none !important;
    }

    .yad-result-report .yad-container,
    .yad-result-report .yad-container * {
        visibility: hidden !important;
    }

    .yad-result-report .yad-print-area,
    .yad-result-report .yad-print-area * {
        visibility: visible !important;
    }

    .yad-diagnosis-wrapper {
        color: #111827 !important;
    }

    .yad-container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .yad-box,
    .yad-priority-box,
    .yad-bg-box,
    .yad-mini-card {
        background: #fff !important;
        box-shadow: none !important;
        border: 1px solid #cbd5e1 !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* priority-box の直後にページ区切りを入れない */
    .yad-priority-box {
        break-after: avoid !important;
        page-break-after: avoid !important;
    }

    .yad-grid-2col {
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
        /* グリッド自体はページ先頭に追い出さない */
        break-before: avoid !important;
        page-break-before: avoid !important;
        break-inside: auto !important;
    }

    /* グリッド内ボックスの height:100% を解除（空白防止）、途中改ページを許可 */
    .yad-grid-2col > * {
        height: auto !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    /* チャートコンテナ: 固定高さを解除し img の自然な高さに従わせる */
    .yad-grid-2col [style*="height: 350px"],
    .yad-grid-2col [style*="height:350px"],
    .yad-grid-2col [style*="height: 280px"],
    .yad-grid-2col [style*="height:280px"] {
        height: auto !important;
        min-height: 0 !important;
    }

    /* canvas→img 変換後の画像: コンテナ幅に収め、高さは比率で決まる */
    .yad-result-report .yad-print-area img[src^="data:"] {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: 180px !important;
        object-fit: contain !important;
    }

    .yad-print-hide,
    .yad-result-report script,
    .yad-result-report .yad-print-area ~ * {
        display: none !important;
    }

    .yad-result-report .yad-print-area {
        display: block !important;
    }

    .yad-result-report .yad-print-logo {
        display: block !important;
        visibility: visible !important;
        height: auto !important;
        margin: 0 0 8mm 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        text-align: left !important;
    }

    .yad-result-report .yad-print-logo .custom-logo-link {
        display: inline-block !important;
        line-height: 0 !important;
    }

    .yad-result-report .yad-print-logo img {
        max-width: 190px !important;
        max-height: 28px !important;
        width: auto !important;
        height: auto !important;
        display: block !important;
    }

    .yad-result-report .yad-print-site-name {
        font-size: 14pt;
        font-weight: bold;
        color: #1e3a5f;
    }

    .yad-result-report h1 {
        font-size: 21pt !important;
        margin-bottom: 12pt !important;
    }

    .yad-result-report h2 {
        font-size: 15pt !important;
    }

    .yad-result-report h3 {
        font-size: 12pt !important;
    }

    .yad-result-report p,
    .yad-result-report li,
    .yad-result-report div,
    .yad-result-report span {
        font-size: 10.5pt !important;
        line-height: 1.6 !important;
    }

    .yad-result-report canvas {
        max-width: 100% !important;
        max-height: 260px !important;
    }

    .yad-note-bubble::before,
    .yad-note-bubble::after {
        display: none !important;
    }
}
