/* 薬価検索画面 - 完全に整理されたレイアウト */

/* リセットとベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    background: #f9fafb;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ヘッダー */
.drug-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    gap: 24px;
}

/* ロゴ */
.header-left .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #2563eb;
    font-weight: 700;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
}

/* 検索エリア */
.header-center {
    flex: 1;
    max-width: 500px;
    margin: 0 32px;
}

.main-search {
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.2s ease;
    height: 50px;
}

.search-input-wrapper:focus-within {
    border-color: #2563eb;
}

.search-icon {
    position: absolute;
    left: 16px;
    color: #9ca3af;
    font-size: 20px;
}

.main-search-input {
    flex: 1;
    padding: 15px 50px 15px 50px;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: #374151;
}

.main-search-input::placeholder {
    color: #9ca3af;
}

.clear-search-btn {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-search-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ヘッダー右側 */
.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.comparison-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.count-badge {
    background: #10b981;
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.compare-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.compare-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.clear-selection-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.clear-selection-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.header-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

/* メインコンテンツ */
.main-content {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
    width: 100%;
    align-items: flex-start;
}

/* フィルターサイドバー */
.filter-sidebar {
    width: 300px;
    min-width: 300px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin: 20px;
    overflow-y: auto;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    align-self: flex-start;
    max-height: calc(100vh - 120px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.filter-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.clear-filters-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f9fafb;
    color: #64748b;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-filters-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.filter-section {
    margin-bottom: 28px;
}

.filter-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 0;
    transition: all 0.2s;
}

.filter-option:hover {
    background: #f9fafb;
    border-radius: 6px;
    padding: 8px 8px;
    margin: 0 -8px;
}

.filter-radio {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

.filter-label {
    font-size: 14px;
    color: #374151;
    flex: 1;
}

.filter-count {
    font-size: 12px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 10px;
}

.filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
}

.filter-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.price-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    background: #fff;
}

.price-input:focus {
    outline: none;
    border-color: #2563eb;
}

.price-separator {
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
}

.price-unit {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

/* 検索結果エリア */
.results-area {
    flex: 1;
    min-width: 0;
    padding: 24px;
    background: #f9fafb;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.results-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.results-count {
    font-size: 14px;
    color: #64748b;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-label {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.sort-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    min-width: 120px;
}

.sort-direction-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sort-direction-btn:hover {
    background: #f9fafb;
    color: #374151;
}

/* 検索結果リスト */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 薬品カード */
.drug-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.drug-card:hover {
    border-color: #d1d5db;
}

.drug-card.selected {
    border-color: #10b981;
    border-width: 2px;
    padding: 23px;
}

/* ヘッダー行 */
.drug-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.selection-checkbox {
    flex-shrink: 0;
    cursor: pointer;
    padding-top: 2px;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
}

.drug-name-section {
    flex: 1;
    min-width: 0;
    margin-bottom: 8px;
}

.generic-name {
    font-size: 18px;
    color: #111827;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.drug-name {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.drug-badges {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.base-badge {
    background: #f59e0b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.set-base-btn {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.set-base-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}


.generic-badge {
    background: #10b981;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.brand-badge {
    background: #3b82f6;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.drug-price {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    flex-shrink: 0;
}

/* メタ情報 */
.drug-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f3f4f6;
}

/* 薬品情報 */
.drug-info {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
}

.info-icon {
    font-size: 18px;
    color: #9ca3af;
}

/* 詳細ボタン */
.detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.detail-btn .material-icons {
    font-size: 18px;
}
    gap: 6px;
    font-size: 13px;
    color: #666;
}

/* 検索結果なし */
.no-results {
    text-align: center;
    padding: 80px 20px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.no-results-icon {
    font-size: 64px;
    color: #ccc;
    margin-bottom: 24px;
}

.no-results-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.no-results-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 32px;
}

.retry-btn {
    padding: 10px 20px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 14px;
    cursor: pointer;
}

.retry-btn:hover {
    background: #1d4ed8;
}

/* ページネーション */
.pagination-wrapper {
    margin-top: 32px;
    display: flex;
    justify-content: center;
}

.pagination-wrapper nav > div:last-child > span.relative {
    gap: 8px;
}

.pagination-wrapper button,
.pagination-wrapper span[aria-current="page"] > span,
.pagination-wrapper span[aria-disabled="true"] > span {
    border-radius: 8px !important;
    min-width: 40px !important;
    height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: 0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.2s ease !important;
}

.pagination-wrapper button:hover {
    background: #f3f4f6 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
}

.pagination-wrapper span[aria-current="page"] > span {
    background: #3b82f6 !important;
    color: #fff !important;
    border-color: #3b82f6 !important;
    font-weight: 600 !important;
}

.pagination-wrapper span[aria-disabled="true"] > span {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f9fafb;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.modal-body {
    padding: 28px;
    max-height: 70vh;
    overflow-y: auto;
}

.drug-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 24px;
}

.detail-section {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
}

.detail-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.detail-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
}

.detail-label {
    font-weight: 500;
    color: #64748b;
    min-width: 120px;
    font-size: 14px;
}

.detail-value {
    text-align: right;
    color: #1f2937;
    font-weight: 500;
    flex: 1;
    margin-left: 16px;
    font-size: 14px;
}

.price-highlight {
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
}

.detail-notes {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    color: #374151;
    line-height: 1.6;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .filter-sidebar {
        width: 280px;
        min-width: 280px;
        padding: 20px;
    }
    
    .results-area {
        padding: 20px;
    }
    
    .header-container {
        padding: 0 20px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .filter-sidebar {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .drug-detail-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        height: auto;
        padding: 16px 20px;
        gap: 16px;
    }
    
    .header-center {
        margin: 0;
        max-width: none;
        width: 100%;
    }
    
    .search-input-wrapper {
        height: 46px;
    }
    
    .main-search-input {
        font-size: 15px;
        padding: 12px 45px 12px 45px;
    }
    
    .search-icon {
        font-size: 18px;
        left: 14px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
        padding: 20px;
    }
    
    .drug-card {
        padding: 20px;
    }
    
    .drug-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .drug-price-section {
        text-align: left;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .drug-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .modal {
        width: 95%;
        margin: 20px;
    }
    
    .main-content {
        min-height: calc(100vh - 120px);
    }
    
    .comparison-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .compare-btn,
    .clear-selection-btn {
        font-size: 13px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 12px 16px;
    }
    
    .results-area {
        padding: 16px;
    }
    
    .filter-sidebar {
        padding: 16px;
    }
    
    .drug-card {
        padding: 16px;
    }
    
    .drug-name {
        font-size: 16px;
    }
    
    .drug-price {
        font-size: 20px;
    }
}

/* 薬品メタ情報 (YJコード等) */
.drug-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.meta-item {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.yj-code {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.update-date {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #d1fae5;
}

/* モーダルヘッダー拡張 */
.modal-title-desc {
    flex: 1;
}

.modal-subtitle {
    font-size: 14px;
    color: #64748b;
    margin-top: 4px;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pdf-download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fee2e2;
    color: #b91c1c;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid #fecaca;
    height: 40px;
}

.pdf-download-btn:hover {
    background: #fecaca;
    transform: translateY(-1px);
}

/* モーダルタブ */
.modal-tabs {
    display: flex;
    padding: 0 28px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.tab-btn {
    padding: 14px 24px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #1f2937;
}

.tab-btn.active {
    color: #2563eb;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #2563eb;
}

/* 添付文書セクション */
.document-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.document-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
}

.document-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.document-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 警告・禁忌ボックス */
.warning-box {
    border: 2px solid #ef4444;
    background: #fef2f2;
}

.warning-title {
    color: #b91c1c;
}

.contra-box {
    border: 2px solid #f97316;
    background: #fff7ed;
}

.contra-title {
    color: #c2410c;
}

.no-document {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-style: italic;
}

/* レスポンシブ対応の追加 */
@media (max-width: 768px) {
    .modal-tabs {
        padding: 0 16px;
        overflow-x: auto;
    }
    
    .tab-btn {
        padding: 12px 16px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .modal-header-actions {
        flex-direction: column-reverse;
        align-items: flex-end;
        gap: 8px;
    }
}