/**
 * DNAレポートシステム - スタイルシート
 * A4サイズ最適化版 v3（左右余白20mm・帯削除）
 */

/* =====================================================
   基本設定
   ===================================================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --metabolism-color: #9333ea;
    --beauty-color: #ec4899;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* =====================================================
   レイアウト
   ===================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =====================================================
   ヘッダー
   ===================================================== */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    display: inline-block;
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.nav-link.active {
    background: var(--primary-color);
    color: #fff;
}

/* =====================================================
   カード
   ===================================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
}

/* カードヘッダー（タイトルとボタン横並び） */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
}

.card-header-flex .card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* 削除ボタン */
.btn-danger {
    background: var(--danger-color);
    color: #fff;
}

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

.btn-danger:disabled {
    background: #fca5a5;
    cursor: not-allowed;
}

/* チェックボックス列 */
.check-col {
    width: 40px;
    text-align: center;
}

/* =====================================================
   フォーム
   ===================================================== */
.form-group {
    margin-bottom: 20px;
    flex: 1;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
}

.required {
    color: var(--danger-color);
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-row .form-group {
    min-width: 250px;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* 日付範囲 */
.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-separator {
    color: var(--text-muted);
}

.date-range .form-input {
    width: auto;
    flex: 1;
}

/* =====================================================
   ボタン
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 8px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: #fff;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--bg-color);
}

/* =====================================================
   テーブル
   ===================================================== */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-color);
    font-weight: 600;
    white-space: nowrap;
}

.data-table tr:hover {
    background: #f1f5f9;
}

.risk-cell {
    font-size: 0.85rem;
    max-width: 200px;
}

.result-count {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--text-muted);
}

.no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

/* =====================================================
   エラーメッセージ
   ===================================================== */
.error-message {
    text-align: center;
    padding: 60px 20px;
}

.error-message h2 {
    color: var(--danger-color);
    margin-bottom: 16px;
}

.error-message p {
    margin-bottom: 24px;
    color: var(--text-muted);
}

/* =====================================================
   フッター
   ===================================================== */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =====================================================
   プレビュー画面専用
   ===================================================== */
.preview-page {
    background: #e5e5e5;
}

/* 操作パネル */
.control-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 12px 20px;
}

.control-panel-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.control-info {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.info-item {
    font-size: 0.9rem;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

/* レポートラッパー */
.report-wrapper {
    padding: 80px 20px 40px;
    display: flex;
    justify-content: center;
}

/* =====================================================
   レポート本体（A4サイズ・左右20mm余白）
   ===================================================== */
.report-container {
    width: 210mm;
    height: 297mm;
    background: #fff;
    box-shadow: var(--shadow-lg);
    padding: 8mm 20mm;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 顧客情報ヘッダー（下線削除） */
.customer-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 2mm;
    margin-bottom: 2mm;
}

.customer-info {
    display: flex;
    align-items: baseline;
    gap: 4mm;
}

.store-name {
    font-size: 10pt;
    font-weight: 600;
    color: #333;
}

.customer-name {
    font-size: 12pt;
    font-weight: 700;
    color: #000;
}

.output-date {
    font-size: 9pt;
    color: #666;
}

/* TOPセクション（ベーシックサプリメント） */
.report-header {
    flex-shrink: 0;
    margin-bottom: 2mm;
}

.header-image {
    width: 100%;
    height: auto;
    max-height: 50mm;
    object-fit: contain;
    display: block;
}

/* コンテンツ2カラム */
.report-content {
    display: flex;
    gap: 4mm;
    flex: 1;
    min-height: 0;
}

.report-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* リスク名（帯削除 → 色文字・太字） */
.column-title {
    flex-shrink: 0;
    padding: 0 0 1mm;
    margin-bottom: 1mm;
    text-align: center;
    font-size: 9pt;
    font-weight: 700;
    line-height: 1.3;
}

.column-title.metabolism {
    color: var(--metabolism-color);
}

.column-title.beauty {
    color: var(--beauty-color);
}

/* カラム画像 */
.column-image {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.column-image img {
    width: 100%;
    height: 100%;
    max-height: 225mm;
    object-fit: contain;
    object-position: top center;
    display: block;
}

/* フッター */
.report-footer {
    flex-shrink: 0;
    margin-top: 1mm;
    padding-top: 1mm;
    text-align: center;
}

.copyright {
    font-size: 6pt;
    color: var(--text-muted);
}

/* =====================================================
   レスポンシブ
   ===================================================== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        min-width: 100%;
    }
    
    .control-panel-inner {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .report-wrapper {
        padding: 120px 10px 20px;
    }
    
    .report-container {
        width: 100%;
        height: auto;
        min-height: auto;
        padding: 5mm 10mm;
    }
}

/* =====================================================
   メンテナンス画面（コンパクトレイアウト）
   ===================================================== */

/* アラート */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* 画像グリッド（横4列） */
.image-grid-compact {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* 画像アイテム（横並び：画像左、情報右） */
.image-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: box-shadow 0.2s;
}

.image-item:hover {
    box-shadow: var(--shadow);
}

/* 共通画像（単体表示） */
.image-item-single {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    max-width: 350px;
}

/* サムネイル */
.image-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 60px;
    background: #f8f8f8;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-thumb.clickable {
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.image-thumb.clickable:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.image-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 詳細情報 */
.image-detail {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.detail-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.image-detail .btn {
    margin-top: 4px;
    align-self: flex-start;
}

/* ページアクション */
.page-actions {
    text-align: center;
    margin: 30px 0;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

/* 大きなプレビューモーダル */
.modal-content.modal-large {
    max-width: 90vw;
    max-height: 95vh;
}

.preview-body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    min-height: 300px;
    padding: 20px;
}

.preview-body img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.preview-filename {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-right: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* アップロードエリア */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    transition: all 0.2s;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-area p {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.upload-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px !important;
    margin-bottom: 0 !important;
}

/* プレビューエリア（アップロード用） */
#uploadPreviewArea {
    text-align: center;
}

#uploadPreviewArea p {
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#uploadPreviewImage {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

#selectedFileName {
    font-weight: 600;
    color: var(--text-color);
}

/* レスポンシブ（メンテナンス画面） */
@media (max-width: 1100px) {
    .image-grid-compact {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 850px) {
    .image-grid-compact {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 550px) {
    .image-grid-compact {
        grid-template-columns: 1fr;
    }
}
