/**
 * MAL Enhanced Styles
 * UI/UX最終化 - レスポンシブデザイン・アクセシビリティ・ユーザビリティ向上
 */

/* ===============================================
   レスポンシブデザイン基盤
   =============================================== */

/* モバイルファースト設計 */
@media (max-width: 767px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-full {
        width: 100% !important;
    }
    
    .mobile-stack {
        flex-direction: column !important;
    }
    
    /* モバイル専用検索バー */
    .mobile-search-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 1rem;
        z-index: 30;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    }
    
    /* モバイル検索結果 */
    .search-results-mobile {
        padding-bottom: 120px; /* 下部固定バーのスペース確保 */
    }
    
    /* モバイルナビゲーション */
    .mobile-nav {
        position: fixed;
        bottom: 80px;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 0.5rem;
        z-index: 29;
    }
    
    .mobile-nav-item {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

/* タブレット対応 */
@media (min-width: 768px) and (max-width: 1023px) {
    .tablet-hidden {
        display: none !important;
    }
    
    .tablet-grid-2 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* タブレット用サイドバー */
    .tablet-sidebar {
        width: 300px;
        position: sticky;
        top: 1rem;
        height: fit-content;
    }
}

/* デスクトップ対応 */
@media (min-width: 1024px) {
    .desktop-hidden {
        display: none !important;
    }
    
    .desktop-grid-3 {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .desktop-grid-4 {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    /* デスクトップ用レイアウト */
    .desktop-layout {
        display: grid;
        grid-template-columns: 320px 1fr;
        gap: 2rem;
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 1rem;
    }
}

/* ===============================================
   ローディングアニメーション
   =============================================== */

/* スケルトンローディング */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin: 0.5rem 0;
    border-radius: 4px;
}

.skeleton-text-sm {
    height: 0.75rem;
}

.skeleton-text-lg {
    height: 1.25rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-card {
    height: 12rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* プログレスバー */
.progress-bar {
    width: 100%;
    height: 0.5rem;
    background-color: #f3f4f6;
    border-radius: 0.25rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    transition: width 0.3s ease-in-out;
    border-radius: 0.25rem;
}

.progress-bar-animated {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8, #3b82f6);
    background-size: 200% 100%;
    animation: progress-animation 2s infinite;
}

@keyframes progress-animation {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* スピナー */
.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
}

.spinner-md {
    width: 2rem;
    height: 2rem;
}

.spinner-lg {
    width: 3rem;
    height: 3rem;
}

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

/* ===============================================
   エラー表示・通知システム
   =============================================== */

/* 通知ベース */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    max-width: 24rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background-color: #10b981;
    color: white;
}

.notification-error {
    background-color: #ef4444;
    color: white;
}

.notification-warning {
    background-color: #f59e0b;
    color: white;
}

.notification-info {
    background-color: #3b82f6;
    color: white;
}

/* エラー状態 */
.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.error-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.error-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
}

.error-state-description {
    margin-bottom: 2rem;
    line-height: 1.6;
}

.error-retry-button {
    background-color: #3b82f6;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.error-retry-button:hover {
    background-color: #2563eb;
}

/* 空の状態 */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    border: 2px dashed #d1d5db;
}

.empty-state-illustration {
    width: 8rem;
    height: 8rem;
    margin: 0 auto 2rem;
    opacity: 0.3;
}

/* ===============================================
   物件カード改善
   =============================================== */

.property-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.property-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.property-card-image {
    position: relative;
    height: 12rem;
    background: #f3f4f6;
    overflow: hidden;
}

.property-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.property-card:hover .property-card-image img {
    transform: scale(1.05);
}

/* 物件バッジ */
.property-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-new {
    background-color: #ef4444;
    color: white;
}

.badge-featured {
    background-color: #f59e0b;
    color: white;
}

.badge-investment {
    background-color: #8b5cf6;
    color: white;
}

.badge-quality {
    background-color: #10b981;
    color: white;
}

/* 価格表示 */
.property-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.property-price-detail {
    font-size: 0.875rem;
    color: #6b7280;
}

/* AI推薦スコア */
.ai-recommendation {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.recommendation-score {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.recommendation-stars {
    color: #fbbf24;
}

/* ===============================================
   フィルターパネル改善
   =============================================== */

.filters-panel {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

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

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* カスタムレンジスライダー */
.range-slider {
    width: 100%;
    height: 0.5rem;
    border-radius: 0.25rem;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.range-slider::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* チェックボックス・ラジオボタンカスタマイズ */
.custom-checkbox,
.custom-radio {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input,
.custom-radio input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 1.25rem;
    width: 1.25rem;
    background-color: #f3f4f6;
    border: 2px solid #d1d5db;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.custom-radio .checkmark {
    border-radius: 50%;
}

.custom-checkbox:hover .checkmark,
.custom-radio:hover .checkmark {
    border-color: #3b82f6;
}

.custom-checkbox input:checked ~ .checkmark,
.custom-radio input:checked ~ .checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
    left: 0.25rem;
    top: 0.125rem;
    width: 0.25rem;
    height: 0.5rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-radio input:checked ~ .checkmark:after {
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: white;
}

/* ===============================================
   アニメーション・トランジション
   =============================================== */

/* フェードイン */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* スライドイン */
.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* スケールアニメーション */
.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* パルスアニメーション */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===============================================
   アクセシビリティ
   =============================================== */

/* フォーカス状態 */
.focus\:ring-2:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    .property-card {
        border: 2px solid #000;
    }
    
    .badge {
        border: 1px solid #000;
    }
    
    .button {
        border: 2px solid #000;
    }
}

/* リデュースモーション対応 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* スクリーンリーダー専用テキスト */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===============================================
   ダークモード対応（将来拡張用）
   =============================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1f2937;
        --bg-secondary: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border-color: #4b5563;
    }
    
    .dark-mode .property-card {
        background-color: var(--bg-secondary);
        border-color: var(--border-color);
    }
    
    .dark-mode .property-price {
        color: var(--text-primary);
    }
}

/* ===============================================
   プリント対応
   =============================================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .property-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .property-card-image {
        height: 8rem;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}