/* 基本設定 */
.universal-price-tool * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.universal-price-tool {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    margin: 20px 0;
    border: none;
}

.universal-price-tool .container {
    background: transparent;
    box-shadow: none;
}

/* ヘッダー */
.universal-price-tool .header {
    background: white;
    color: #138496;
    padding: 5px 9px 9px 9px;
    text-align: center;
    border-radius: 20px;
    border: 4px solid #bee5eb;
}

.universal-price-tool .header-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.universal-price-tool .header-note {
    font-size: 0.75rem;
    color: #555;
    margin: 0;
    font-weight: 400;
}

.universal-price-tool.no-header {
    background: transparent;
    margin-top: 0;
}

.universal-price-tool.no-header .main-content {
    margin-top: 0;
    padding-top: 0;
}

.universal-price-tool .header:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    border: none !important;
}

/* メインコンテンツ */
.universal-price-tool .main-content {
    padding: 10px 0;
}

/* セクション */
.universal-price-tool .section {
    background: #e8f4f8;
    border-radius: 15px;
    padding: 10px;
    margin-bottom: 10px;
    border: 2px solid #bee5eb;
}

.universal-price-tool .section-title {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #138496;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.universal-price-tool .section-title svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* セクショングループ */
.universal-price-tool .select-section-group {
    background: #e8f4f8;
    border: 2px solid #bee5eb;
    border-radius: 15px;
    padding: 8px 10px 15px 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.universal-price-tool .select-section-group .section {
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 0;
    padding: 5px 0 10px 0;
}

.universal-price-tool .select-section-group .section:last-child {
    padding-bottom: 0;
}

/* 結果セクション */
.universal-price-tool #results-section {
    background: #e8f4f8;
    border: 2px solid #bee5eb;
    border-radius: 15px;
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ボタン */
.universal-price-tool button {
    background: linear-gradient(135deg, #3ca8b9 0%, #1a9fb3 100%);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.universal-price-tool button:hover {
    transform: translateY(-2px);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.button-grid button {
    width: 100%;
    min-height: 40px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    line-height: 1.2;
    gap: 8px;
}

.button-grid button:hover {
    background: #138496;
    transform: translateY(-1px);
}

.button-grid button.selected,
.button-grid button.active,
.selection-button.active {
    background: #138496;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

/* プルダウン */
.universal-price-tool .selection-dropdown {
    width: 100%;
    min-width: 580px;
    padding: 15px 45px 15px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    color: #138496;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    box-sizing: border-box;
    line-height: 1.4;
    min-height: 48px;
}

.universal-price-tool .selection-dropdown:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.universal-price-tool .selection-dropdown:hover {
    border-color: #17a2b8;
}

/* ドロップダウンラベル */
.universal-price-tool .dropdown-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #138496;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.universal-price-tool .dropdown-label .section-svg svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* プルダウン見出し制御 */
.universal-price-tool .section:has(.selection-dropdown) .section-title,
.universal-price-tool.all-dropdown .section-title:not(#results-section .section-title),
.universal-price-tool.has-dropdown .section.dropdown-mode .section-title {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

.universal-price-tool .section.button-mode .section-title,
.universal-price-tool #results-section .section-title {
    display: flex !important;
    visibility: visible !important;
    height: auto !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    margin-bottom: 8px !important;
    opacity: 1 !important;
    position: static !important;
    left: auto !important;
}

.universal-price-tool .dropdown-container .dropdown-label {
    display: flex !important;
    visibility: visible !important;
    height: auto !important;
    align-items: center !important;
    gap: 8px !important;
    color: #138496 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    margin-bottom: 8px !important;
    opacity: 1 !important;
    position: static !important;
    left: auto !important;
}

/* レイアウト調整 */
.universal-price-tool.has-dropdown .section.dropdown-mode,
.universal-price-tool.has-dropdown .section.button-mode:not(#results-section) {
    background: transparent;
    border: none;
    padding: 8px 0 5px 0;
    margin-bottom: 0;
}

.universal-price-tool.all-dropdown .section.dropdown-mode,
.universal-price-tool.all-dropdown .section.button-mode:not(#results-section) {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 0;
}

.universal-price-tool.all-dropdown .dropdown-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 0;
}

.universal-price-tool .dropdown-item {
    margin-bottom: 15px;
}

.universal-price-tool .dropdown-item:last-child {
    margin-bottom: 0;
}

.universal-price-tool.all-dropdown .selection-dropdown {
    min-width: 0;
    width: 100%;
}

/* 結果カード - コンパクトバージョン */
.universal-price-tool .comparison-card,
.universal-price-tool .result-card {
    background: white;
    border: 2px solid #bee5eb;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    position: relative;
    text-decoration: none;
    color: inherit;
    display: block;
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.07);
}

.universal-price-tool .comparison-card:hover,
.universal-price-tool .result-card:hover {
    border-color: #17a2b8;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.12);
}

.universal-price-tool .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.universal-price-tool .clinic-name-link,
.universal-price-tool .universal-name-link {
    color: #138496 !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    flex: 1;
    margin-right: 8px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.universal-price-tool .final-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #138496;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.universal-price-tool .card-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
    min-height: 60px;
}

.universal-price-tool .detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 18px;
    font-size: 0.85rem;
}

.universal-price-tool .plan-info {
    color: #555;
    font-size: 0.85rem;
    line-height: 1.2;
}

.universal-price-tool .original-price {
    color: #666;
    font-size: 0.85rem;
    text-align: right;
}

.universal-price-tool .campaign-info {
    color: #28a745;
    font-size: 0.85rem;
    font-weight: 600;
}

.universal-price-tool .discount-amount {
    color: #28a745;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.universal-price-tool .description-text {
    color: #666;
    font-size: 0.8rem;
    margin-top: 2px;
    margin-bottom: 6px;
    line-height: 1.3;
}

/* 予約ボタン */
.universal-price-tool .reserve-btn-wrapper {
    margin-top: 8px;
}

.universal-price-tool .reserve-btn {
    display: block;
    width: 70%;
    margin: 0 auto;
    text-align: center;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    border: none;
    background: #D26899;
    color: #fff; !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    text-decoration: none; !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* アラート */
.universal-price-tool .alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    grid-column: 1 / -1;
}

.universal-price-tool .alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
    font-size: 13px;
}

.universal-price-tool .alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.universal-price-tool .alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

/* 最安値バッジ（非表示） */
.universal-price-tool .lowest-price-badge {
    display: none;
}

/* 結果表示グリッド */
.universal-price-tool .results-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
}

/* 結果サブタイトル */
.universal-price-tool .result-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-top: 5px;
    margin-bottom: 15px;
    padding: 0 2px;
    line-height: 1.4;
    font-weight: 400;
}

.universal-price-tool #results-section .section-title {
    margin-bottom: 5px;
}

.universal-price-tool #results-section .results-area {
    margin-top: 15px;
}

.universal-price-tool #results-section .result-subtitle + .results-area {
    margin-top: 10px;
}

/* カスタムテーマ */
:root {
    --upt-base-color: #17a2b8;
    --upt-base-color-dark: #138496;
    --upt-base-color-light: #e8f4f8;
    --upt-base-color-border: #bee5eb;
    --upt-base-color-result-bg: #e8f4f8;
    --upt-base-color-result-title: #17a2b8;
    --upt-base-color-alert-bg: #d1ecf1;
    --upt-base-color-alert-text: #0c5460;
    --upt-button-hover-bg-color: #138496;
    --upt-button-active-bg-color: #117a8b;
    --upt-button-active-text-color: #fff;
}

.universal-price-tool.theme-custom {
    background: transparent;
}

.universal-price-tool.theme-custom .header {
    color: var(--upt-base-color);
    border-color: var(--upt-base-color-border);
}

.universal-price-tool.theme-custom .section,
.universal-price-tool.theme-custom .select-section-group {
    background-color: var(--upt-base-color-light);
    border-color: var(--upt-base-color-border);
}

.universal-price-tool.theme-custom .select-section-group .section {
    background: transparent;
    border: none;
}

.universal-price-tool.theme-custom .section-title,
.universal-price-tool.theme-custom .dropdown-label {
    color: var(--upt-base-color-result-title);
}

.universal-price-tool.theme-custom .button-grid button,
.universal-price-tool.theme-custom .selection-button {
    background-color: var(--upt-base-color);
}

.universal-price-tool.theme-custom .button-grid button:hover,
.universal-price-tool.theme-custom .selection-button:hover {
    background-color: var(--upt-button-hover-bg-color);
}

.universal-price-tool.theme-custom .button-grid button.selected,
.universal-price-tool.theme-custom .button-grid button.active,
.universal-price-tool.theme-custom .selection-button.active {
    background-color: var(--upt-button-active-bg-color);
    color: var(--upt-button-active-text-color);
}

.universal-price-tool.theme-custom .selection-dropdown {
    border-color: var(--upt-base-color-border);
    color: var(--upt-base-color-dark);
}

.universal-price-tool.theme-custom .selection-dropdown:focus,
.universal-price-tool.theme-custom .selection-dropdown:hover {
    border-color: var(--upt-base-color);
    box-shadow: 0 0 0 3px var(--upt-base-color-light);
}

.universal-price-tool.theme-custom #results-section {
    background: var(--upt-base-color-result-bg);
    border-color: var(--upt-base-color-border);
}

.universal-price-tool.theme-custom #results-section .section-title {
    color: var(--upt-base-color-result-title);
}

.universal-price-tool.theme-custom .comparison-card,
.universal-price-tool.theme-custom .result-card {
    border-color: var(--upt-base-color-border);
}

.universal-price-tool.theme-custom .comparison-card:hover,
.universal-price-tool.theme-custom .result-card:hover {
    border-color: var(--upt-base-color);
}

.universal-price-tool.theme-custom .clinic-name-link,
.universal-price-tool.theme-custom .universal-name-link,
.universal-price-tool.theme-custom .final-price {
    color: var(--upt-base-color) !important;
}

.universal-price-tool.theme-custom .alert-info {
    background-color: var(--upt-base-color-alert-bg);
    border-color: var(--upt-base-color-border);
    color: var(--upt-base-color-alert-text);
}

.universal-price-tool.theme-custom .result-subtitle {
    color: #666;
}

/* HTMLタグ用 */
.universal-price-tool .result-card-html-tag {
    position: relative;
    overflow: hidden;
}

.universal-price-tool .result-card-html-tag .jump {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

/* 管理画面用スタイル */
.tools-list-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.tools-list-table th,
.tools-list-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.tools-list-table th {
    background-color: #f9f9f9;
    font-weight: 600;
}

.tools-list-table tr:hover {
    background-color: #f5f5f5;
}

.setting-group {
    margin-top: 20px;
    border-radius: 5px;
}

.setting-box {
    margin-top: 15px;
    padding: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.save-actions {
    margin-top: 20px;
}

.save-actions .submit {
    padding: 0;
    margin: 15px 0;
}

.tracking-filters {
    background: #f9f9f9;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-block: 15px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #138496;
    margin-bottom: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

.stats-section {
    margin-bottom: 30px;
    background: white;
    padding: 0 20px 20px 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

/* ドラッグ&ドロップ */
.button-setting-header {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 60px 80px;
    gap: 5px;
    align-items: center;
    padding: 8px 1px 8px 20px;
    background: #f0f0f0;
    border-radius: 5px;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.draggable-row {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 60px 80px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 8px;
    cursor: move;
    transition: all 0.3s ease;
}

.draggable-row:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drag-handle {
    cursor: grab;
    color: #666;
    font-weight: bold;
    text-align: center;
    padding: 4px;
    border-radius: 3px;
    background: #f1f3f4;
    transition: all 0.2s ease;
    user-select: none;
    justify-self: center;
}

.drag-handle:hover {
    background: #e8eaed;
    color: #333;
}

.drag-handle:active {
    cursor: grabbing;
    background: #dadce0;
}

.draggable-row input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.order-display {
    color: #1976d2;
    font-weight: bold;
    text-align: center;
    padding: 6px;
    border-radius: 50%;
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    justify-self: center;
}

.draggable-row.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    position: relative;
}

.draggable-row.drag-over {
    border-top: 3px solid #007cba;
    background-color: #f0f8ff;
    transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media (max-width: 1024px) and (min-width: 769px) {
    .universal-price-tool.all-dropdown .dropdown-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .universal-price-tool .selection-dropdown {
        min-width: 400px;
    }
}

@media (max-width: 768px) {
    .universal-price-tool .header-title {
        font-size: 1.3rem;
    }
    
    .universal-price-tool .header-note {
        font-size: 0.8rem;
    }
    
    .button-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .button-grid button {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 0.9rem;
    }
    
    .universal-price-tool .selection-dropdown {
        font-size: 0.9rem;
        padding: 12px 40px 12px 15px;
        min-height: 44px;
        min-width: 300px;
    }
    
    .universal-price-tool.all-dropdown .dropdown-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .universal-price-tool .results-area {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .universal-price-tool .result-card {
        padding: 10px;
        margin-bottom: 6px;
        display: flex;
        flex-direction: column;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .universal-price-tool .card-header {
        margin-bottom: 6px;
    }
    
    .universal-price-tool .clinic-name-link,
    .universal-price-tool .universal-name-link {
        font-size: 0.9rem;
    }
    
    .universal-price-tool .final-price {
        font-size: 1.05rem;
    }
    
    .universal-price-tool .card-details {
        flex-grow: 1;
        min-height: auto;
    }
    
    .universal-price-tool .detail-row {
        font-size: 0.8rem;
        min-height: 16px;
    }
    
    .universal-price-tool .plan-info,
    .universal-price-tool .original-price,
    .universal-price-tool .campaign-info,
    .universal-price-tool .discount-amount {
        font-size: 0.8rem;
    }
    
    .universal-price-tool .description-text {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }
    
    .universal-price-tool .reserve-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .universal-price-tool .reserve-btn-wrapper {
        margin-top: auto;
    }
    
    .universal-price-tool .result-subtitle {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    
    .button-setting-header,
    .draggable-row {
        grid-template-columns: 25px 1fr 1fr 50px 70px;
        gap: 5px;
        padding: 8px;
    }
    
    .drag-handle {
        font-size: 0.8em;
        padding: 2px;
    }
    
    .order-display {
        min-width: 25px;
        height: 25px;
        font-size: 0.8em;
    }
    
    .draggable-row input[type="text"] {
        font-size: 0.9rem;
        padding: 6px 8px;
    }
    
    .draggable-row .button {
        padding: 4px 8px;
        font-size: 11px;
    }
}

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

.universal-price-tool.has-dropdown #results-section,
.universal-price-tool.all-dropdown #results-section {
    animation: resultsSlideIn 0.5s ease;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tracking-quick-check {
    animation: fadeInUp 0.5s ease;
}

.tracking-quick-check h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tracking-quick-check button {
    transition: all 0.3s ease;
}

.tracking-quick-check button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#quick-check-results {
    min-height: 20px;
}

#quick-check-results > div {
    animation: slideIn 0.3s ease;
}

/* アクセシビリティ */
.universal-price-tool button:focus,
.universal-price-tool .selection-dropdown:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.universal-price-tool .comparison-card:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.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-contrast: high) {
    .universal-price-tool .section {
        border-width: 3px;
    }
    
    .universal-price-tool button {
        border: 2px solid currentColor;
    }
    
    .universal-price-tool .selection-dropdown {
        border-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .universal-price-tool * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .universal-price-tool button:hover,
    .universal-price-tool .comparison-card:hover {
        transform: none;
    }
}