/* ========================================
   リセット & ベーススタイル
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --background: #f5f7fa;
    --card-background: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   コンテナ（モバイルファースト）
   ======================================== */
.container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* タブレット以上 */
@media (min-width: 768px) {
    .container {
        padding: 24px;
    }
}

/* デスクトップ */
@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 32px;
    }
}

/* ========================================
   ヘッダー
   ======================================== */
.header {
    text-align: center;
    margin-bottom: 24px;
}

.title {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

@media (min-width: 768px) {
    .header {
        margin-bottom: 32px;
    }
    
    .title {
        font-size: 36px;
    }
    
    .subtitle {
        font-size: 16px;
    }
}

/* ========================================
   メインコンテンツ
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* デスクトップではグリッドレイアウト */
@media (min-width: 1024px) {
    .main-content {
        display: grid;
        grid-template-columns: 300px 1fr;
        grid-template-rows: auto 1fr;
        gap: 24px;
    }
    
    .settings-panel {
        grid-column: 1;
        grid-row: 1 / 3;
    }
    
    .upload-section {
        grid-column: 2;
        grid-row: 1;
    }
    
    .result-section {
        grid-column: 2;
        grid-row: 2;
    }
}

/* ========================================
   設定パネル
   ======================================== */
.settings-panel {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.settings-panel h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.mode-select {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.mode-select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.setting-info {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-top: 20px;
}

.setting-info h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.setting-info ol {
    margin-left: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.setting-info ol li {
    margin-bottom: 8px;
}

/* ========================================
   アップロードセクション
   ======================================== */
.upload-section {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.upload-section h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: #fafbfc;
    cursor: pointer;
    transition: var(--transition);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: var(--secondary-color);
    background: #f0f7ff;
}

.upload-area.dragover {
    border-color: var(--secondary-color);
    background: #e3f2fd;
}

.upload-placeholder {
    text-align: center;
    padding: 40px 20px;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-placeholder p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 12px !important;
    color: var(--text-secondary);
}

.image-preview {
    position: relative;
    width: 100%;
    padding: 16px;
}

.image-preview img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
}

.remove-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: var(--accent-color);
    transform: scale(1.1);
}

/* 生成ボタン */
.generate-btn {
    width: 100%;
    padding: 16px;
    margin-top: 16px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--secondary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.generate-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

/* タッチデバイス用のボタンサイズ調整 */
@media (max-width: 767px) {
    .generate-btn {
        padding: 18px;
        font-size: 17px;
        min-height: 52px;
    }
}

/* ========================================
   結果表示セクション
   ======================================== */
.result-section {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.5s ease;
}

.result-section h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.result-content {
    line-height: 1.8;
    color: var(--text-primary);
}

.result-content h3 {
    font-size: 18px;
    margin-top: 20px;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.result-content p {
    margin-bottom: 16px;
    white-space: pre-wrap;
}

.result-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* ========================================
   ローディング & エラー
   ======================================== */
.loading {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 40px 20px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

.error-message {
    background: #ffe5e5;
    border: 2px solid var(--accent-color);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: shake 0.5s ease;
}

.error-icon {
    font-size: 24px;
}

.error-message span:last-child {
    color: var(--accent-color);
    font-size: 14px;
    flex: 1;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ========================================
   フッター
   ======================================== */
.footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer p {
    color: var(--text-secondary);
    font-size: 13px;
}

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

/* ========================================
   スクロールバースタイル（Webkit）
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* ========================================
   印刷用スタイル
   ======================================== */
@media print {
    .settings-panel,
    .upload-section,
    .generate-btn,
    .footer {
        display: none;
    }
    
    .result-section {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
