/* 推しウマ記録アプリ - スマホ推奨デザイン */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    overflow-x: hidden;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-title {
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.add-btn, .back-btn, .edit-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px; /* タッチ操作に適したサイズ */
}

.add-btn:hover, .back-btn:hover, .edit-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.add-btn:active, .back-btn:active, .edit-btn:active {
    transform: translateY(0);
}

/* メインコンテンツ */
.main-content {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* 検索バー */
.search-bar {
    margin-bottom: 1rem;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 1rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-height: 44px;
}

.search-bar input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* 推しウマ一覧 */
.horse-list {
    display: grid;
    gap: 1rem;
}

.horse-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 120px;
}

.horse-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.horse-card:active {
    transform: translateY(0);
}

.horse-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.horse-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    font-size: 2rem;
    color: #999;
}

.horse-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.horse-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.horse-info p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.horse-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.horse-meta span {
    background: #e3f2fd;
    color: #1976D2;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* 空状態 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.empty-state button {
    background: #2196F3;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    min-height: 44px;
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 1.1rem;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e9ecef;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

/* フォーム */
.horse-form, .record-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
    min-height: 44px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 画像プレビュー */
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    aspect-ratio: 1;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item button {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255,0,0,0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* フォームアクション */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    margin-top: 1rem;
}

.form-actions button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 80px;
}

.form-actions button[type="submit"],
.form-actions button:last-child {
    background: #2196F3;
    color: white;
}

.form-actions button[type="submit"]:hover,
.form-actions button:last-child:hover {
    background: #1976D2;
}

.form-actions button[type="button"]:first-child {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.form-actions button[type="button"]:first-child:hover {
    background: #e9ecef;
}

/* 詳細画面 */
.detail-content {
    padding-bottom: 2rem;
}

.horse-info-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.horse-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.horse-images img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.horse-images img:hover {
    transform: scale(1.02);
}

.horse-images .no-image {
    aspect-ratio: 1;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #999;
}

.horse-basic-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.horse-comment {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.jra-link-section {
    margin-top: 1rem;
}

.jra-link-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
}

.jra-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* 記録セクション */
.records-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.add-record-btn {
    background: #FF9800;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
}

.add-record-btn:hover {
    background: #F57C00;
    transform: translateY(-1px);
}

/* 記録リスト */
.records-list {
    display: grid;
    gap: 1rem;
}

.record-card {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1rem;
    background: #fafafa;
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.record-type {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.record-type-race {
    background: #e3f2fd;
    color: #1976D2;
}

.record-type-training {
    background: #f3e5f5;
    color: #7b1fa2;
}

.record-type-other {
    background: #e8f5e8;
    color: #388e3c;
}

.record-date {
    color: #666;
    font-size: 0.9rem;
}

.record-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.record-card p {
    color: #666;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.record-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.record-actions button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    min-height: 36px;
}

.record-actions button:first-child {
    background: #e3f2fd;
    color: #1976D2;
}

.record-actions button:first-child:hover {
    background: #bbdefb;
}

.delete-btn {
    background: #ffebee !important;
    color: #d32f2f !important;
}

.delete-btn:hover {
    background: #ffcdd2 !important;
}

/* 画像拡大モーダル */
.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
}

.image-modal-content .modal-body {
    text-align: center;
    padding: 1rem;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

.image-modal-content p {
    margin-top: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }
    
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header-title {
        font-size: 1.1rem;
    }
    
    .add-btn, .back-btn, .edit-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .horse-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .horse-image {
        width: 60px;
        height: 60px;
    }
    
    .horse-info h3 {
        font-size: 1rem;
    }
    
    .horse-info p {
        font-size: 0.85rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .horse-images {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .add-record-btn {
        width: 100%;
    }
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    .horse-card:hover {
        transform: none;
    }
    
    .horse-images img:hover {
        transform: none;
    }
    
    .add-btn:hover, .back-btn:hover, .edit-btn:hover {
        transform: none;
        background: rgba(255,255,255,0.2);
    }
    
    .jra-link-btn:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

/* スクロールバーのスタイリング（Webkit系ブラウザ） */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* フォーカス時のアクセシビリティ */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

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

.horse-card,
.record-card {
    animation: fadeIn 0.3s ease-out;
}

/* プリント用スタイル */
@media print {
    .header {
        position: static;
    }
    
    .add-btn, .back-btn, .edit-btn,
    .add-record-btn, .record-actions {
        display: none;
    }
    
    .modal {
        display: none !important;
    }
}