/* リセットと基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* コンテナ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* メインコンテンツ */
main {
    padding: 2rem 0;
}

/* フォームセクション */
.form-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.form-section h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* フォームグループ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2ecc71;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.875rem;
}

/* フォーム行 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ボタン */
.btn-primary {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    width: 100%;
    margin-top: 2rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(46, 204, 113, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* 結果セクション */
.results-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.results-section h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* 結果カード */
.result-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.result-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}

.result-card:hover {
    transform: translateY(-5px);
}

.result-card h3 {
    color: #495057;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.result-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2ecc71;
    margin-bottom: 0.5rem;
}

.result-unit {
    color: #6c757d;
    font-size: 1rem;
}

/* バッジ */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    color: white;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
    margin-top: 8px;
    background-color: #6c757d;
}

.badge-demo {
    background-color: #fd7e14;
}

.badge-real {
    background-color: #20c997;
}

.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.badge-info {
    background-color: #17a2b8;
}

.badge-success {
    background-color: #28a745;
}

.badge-greenhouse {
    background-color: #059669;
    color: white;
}

/* グラフコンテナ */
.chart-container {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    height: 400px;
    position: relative;
}

/* データテーブル */
.data-table-container {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
}

.data-table-container h3 {
    color: #495057;
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#dataTable th,
#dataTable td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

#dataTable th {
    background: #2ecc71;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

#dataTable tbody tr:hover {
    background: #f8f9fa;
}

#dataTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

/* ヘルプセクション */
.help-section {
    text-align: center;
    margin: 3rem 0;
}

.help-link {
    display: inline-block;
    color: #2ecc71;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 10px 20px;
    border: 2px solid #2ecc71;
    border-radius: 5px;
    transition: all 0.3s;
}

.help-link:hover {
    background: #2ecc71;
    color: white;
}

/* フッター */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

/* ローディングメッセージ */
.loading-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.2);
    z-index: 9999;
    text-align: center;
}

.loading-message h3 {
    color: #2ecc71;
    margin-bottom: 1rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

/* 温室設定セクション */
.greenhouse-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f0f9ff;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
}

.greenhouse-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #1e40af;
    font-size: 1.1rem;
}

.greenhouse-settings {
    margin-top: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e7ff;
}

.info-box {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #eff6ff;
    border-radius: 5px;
    font-size: 0.9rem;
    color: #1e40af;
}

input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .result-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .chart-container {
        height: 300px;
    }
    
    #dataTable {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .form-section,
    .results-section {
        padding: 1.5rem;
    }
    
    .result-cards {
        grid-template-columns: 1fr;
    }
    
    .result-value {
        font-size: 2rem;
    }
    
    .btn-primary {
        font-size: 1rem;
        padding: 10px 20px;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-section {
    animation: fadeIn 0.5s ease-out;
}

/* 都市検索候補 */
.location-suggestions {
    position: absolute;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    width: 100%;
    margin-top: 5px;
}

.location-suggestions.show {
    display: block;
}

.location-suggestion {
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.location-suggestion:hover {
    background-color: #f8f9fa;
}

.location-suggestion.selected {
    background-color: #e3f2fd;
}

.location-suggestion-name {
    font-weight: 600;
    color: #2c3e50;
}

.location-suggestion-details {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}

/* 座標情報表示 */
.coordinates-text {
    color: #2ecc71;
    font-weight: 500;
}

#coordinatesInfo {
    margin-top: -10px;
    margin-bottom: 15px;
}

/* API情報 */
.api-info {
    text-align: center;
    margin-top: 1rem;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 5px;
}

.api-info small {
    color: #2e7d32;
    font-weight: 500;
}

/* ローディングスピナー */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* エラーメッセージ */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
}

/* 成功メッセージ */
.success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 1rem;
    border: 1px solid #c3e6cb;
}

/* 地域候補表示 */
.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

.suggestion-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

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

.suggestion-item:hover {
    background-color: #f8f9fa;
}

/* 地域入力欄の相対位置設定 */
.form-group:has(#location) {
    position: relative;
}

/* 座標情報表示 */
.coordinates-text {
    color: #666;
    font-size: 0.875rem;
    display: block;
    margin-top: 0.5rem;
}

#coordinatesInfo {
    background: #e8f5e9;
    padding: 10px;
    border-radius: 5px;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
}

/* API情報 */
.api-info {
    text-align: center;
    margin-top: 1.5rem;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 5px;
}

.api-info small {
    color: #1976d2;
    font-weight: 500;
}

/* 達成行の強調表示 */
.achieved-row {
    background-color: #fffde7 !important;
    font-weight: bold;
}

.achieved {
    color: #2ecc71;
    font-weight: bold;
    position: relative;
}

.achieved::before {
    content: "✓ ";
    color: #2ecc71;
}

/* グラフコンテナの改善 */
.chart-container {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    min-height: 400px;
    position: relative;
}

/* データテーブルの改善 */
#dataTable tbody tr {
    transition: background-color 0.2s;
}

#dataTable tbody tr:hover {
    background-color: #e8f5e9 !important;
}

/* カスタムスクロールバー */
.location-suggestions::-webkit-scrollbar {
    width: 8px;
}

.location-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.location-suggestions::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.location-suggestions::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 結果ヘッダー */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* セカンダリボタン */
.btn-secondary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(52, 152, 219, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* ボタングループ */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.button-group .btn-primary,
.button-group .btn-secondary,
.button-group .btn-outline {
    flex: 1;
    min-width: 200px;
}

/* アウトラインボタン */
.btn-outline {
    background: white;
    color: #2ecc71;
    border: 2px solid #2ecc71;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-outline:hover {
    background: #2ecc71;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(46, 204, 113, 0.3);
}

.btn-outline:active {
    transform: translateY(0);
}

/* テーブルヘッダー */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.data-summary {
    font-size: 0.9rem;
    color: #666;
}

/* アニメーションの改善 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner-large {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #2ecc71;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* 予測結果表示エリア */
.prediction-results {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    margin: 2rem 0;
    border-left: 5px solid #3498db;
}

.prediction-achieved {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.prediction-forecast {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196f3;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.prediction-completed {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.prediction-unpredictable {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 2px solid #dc3545;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.prediction-info {
    background: linear-gradient(135deg, #e2e3e5 0%, #d1ecf1 100%);
    border: 2px solid #6c757d;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* 予測日付表示 */
.prediction-date {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.prediction-details {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.prediction-basis {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* 信頼度バッジ */
.confidence-badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 15px;
    text-align: center;
    white-space: nowrap;
}

.confidence-very-high {
    background-color: #28a745;
    color: white;
}

.confidence-high {
    background-color: #17a2b8;
    color: white;
}

.confidence-medium {
    background-color: #ffc107;
    color: #212529;
}

.confidence-low {
    background-color: #dc3545;
    color: white;
}

/* 予測タイプバッジ */
.badge-prediction {
    background-color: #007bff;
}

.badge-historical {
    background-color: #28a745;
}

.badge-forecast {
    background-color: #17a2b8;
}

.days-remaining {
    background-color: #6f42c1;
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* 予報情報エリア */
.forecast-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.forecast-info h4 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.forecast-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.forecast-stats .stat {
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #495057;
    border: 1px solid #dee2e6;
    font-weight: 500;
}

/* データタイプ表示 */
.data-historical {
    background-color: rgba(40, 167, 69, 0.05);
}

.data-forecast {
    background-color: rgba(0, 123, 255, 0.05);
    font-style: italic;
}

.data-forecast td {
    position: relative;
}

.data-forecast td::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 4px;
    height: 20px;
    background: #007bff;
    transform: translateY(-50%);
    border-radius: 2px;
}

/* グラフタイトルの改善 */
.chart-container canvas {
    max-height: 100%;
}

/* テーブルでの予測データ表示 */
#dataTable .data-forecast {
    border-left: 3px solid #007bff;
}

#dataTable .data-historical {
    border-left: 3px solid #28a745;
}

/* アニメーション効果 */
.prediction-results {
    animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ツールチップ風の説明 */
.prediction-tooltip {
    position: relative;
    cursor: help;
}

.prediction-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* レスポンシブデザインの追加調整 */
@media (max-width: 768px) {
    .location-suggestions {
        max-height: 200px;
    }
    
    .suggestion-item {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    #coordinatesInfo {
        font-size: 0.75rem;
    }
    
    .api-info small {
        font-size: 0.75rem;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* 予測結果のモバイル対応 */
    .prediction-results {
        padding: 1.5rem;
        margin: 1rem 0;
    }
    
    .prediction-date {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .prediction-details {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .forecast-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .forecast-stats .stat {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .prediction-results {
        padding: 1rem;
    }
    
    .prediction-date {
        font-size: 1.1rem;
    }
    
    .confidence-badge,
    .days-remaining {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}