/**
 * フロントエンドスタイル
 *
 * @package IntaTraceability
 */

/* ========================================
   検索コンテナ
   ======================================== */
.inta-traceability-search-container {
    max-width: 900px;
    margin: 0;
    padding: 0;
}

/* ========================================
   セクション共通スタイル
   ======================================== */
.inta-section {
    margin-bottom: 3rem;
    padding: 0;
}

.inta-section-title {
    display: flex;
    align-items: center;
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.6;
    color: #333;
}

.inta-section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: auto;
    margin-right: 0.5rem;
    color: #333;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ========================================
   セクション① 検索フォーム
   ======================================== */
.inta-section-1 .inta-section-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.inta-search-form-wrapper {
    flex: 1;
    min-width: 0;
}

.inta-search-label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.inta-search-field {
    display: flex;
    gap: 0.5rem;
}

.inta-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s ease;
}

.inta-search-input::placeholder {
    color: #999;
}

.inta-search-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.inta-search-button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #4a90e2;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.inta-search-button:hover {
    background-color: #357abd;
}

.inta-search-button:active {
    background-color: #2a5f9e;
}

/* 商品ラベル画像 */
.inta-product-label {
    flex: 0 0 auto;
    width: 220px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    background-color: #f9f9f9;
}

.inta-label-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* ========================================
   ローディング（セクション②内に表示）
   ======================================== */
.inta-loading {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.inta-loading.show {
    opacity: 1;
}

.inta-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a90e2;
    border-radius: 50%;
    animation: inta-spin 1s linear infinite;
}

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

.inta-loading-text {
    margin-top: 1rem;
    color: #666;
    font-size: 1rem;
}

/* ========================================
   メッセージ
   ======================================== */
.inta-message {
    padding: 1rem;
    margin-top: 1rem;
    border-radius: 4px;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.inta-message.show {
    opacity: 1;
}

.inta-message-error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c33;
}

/* ========================================
   セクション② 検索結果テーブル
   ======================================== */
.inta-results-table-wrapper {
    position: relative;
    min-height: 200px;
    overflow-x: auto;
}

.inta-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    border: 1px solid #ddd;
}

.inta-results-table thead {
    background-color: #f5f5f5;
}

.inta-results-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
}

.inta-results-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.inta-results-table tbody tr:hover {
    background-color: #f9f9f9;
}

.inta-results-table tbody tr:last-child td {
    border-bottom: none;
}

.inta-results-table a {
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.3s ease;
}

.inta-results-table a:hover {
    color: #357abd;
    text-decoration: underline;
}

/* テーブルが空の場合のスタイル */
.inta-results-table tbody:empty::before {
    content: '検索結果がここに表示されます';
    display: block;
    padding: 3rem;
    text-align: center;
    color: #999;
    font-size: 0.95rem;
}

/* ========================================
   セクション② 個体識別番号グリッド
   ======================================== */
.inta-results-wrapper {
    position: relative;
    min-height: 100px;
}

.inta-id-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem 1rem;
    padding: 1.5rem;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.inta-id-item {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    text-align: center;
    padding: 0.5rem 0.25rem;
    background-color: #fff;
    border-radius: 4px;
    user-select: all;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.inta-id-item:hover {
    background-color: #e8f4ff;
}

/* 空の状態 */
.inta-id-grid:empty::before {
    content: '検索結果がここに表示されます';
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    font-size: 0.95rem;
    padding: 2rem;
}

/* ========================================
   セクション③ 外部リンク
   ======================================== */
.inta-nlbc-description {
    margin: 0 0 1.5rem 0;
    color: #666;
    line-height: 1.8;
    font-size: 0.95rem;
}

.inta-nlbc-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #000000;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.inta-nlbc-button:hover {
    background-color: #333333;
}

.inta-nlbc-button:active {
    background-color: #1a1a1a;
}

/* ========================================
   レスポンシブ対応（タブレット）
   ======================================== */
@media screen and (max-width: 768px) {
    .inta-traceability-search-container {
        margin: 0;
    }

    .inta-section {
        margin-bottom: 2.5rem;
    }

    .inta-section-title {
        font-size: 1rem;
        line-height: 1.5;
    }

    .inta-section-number {
        font-size: 1rem;
        margin-right: 0.5rem;
    }

    /* セクション①のレイアウト調整 */
    .inta-section-1 .inta-section-content {
        flex-direction: column;
        gap: 1.5rem;
    }

    .inta-product-label {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .inta-search-field {
        flex-direction: row;
    }

    .inta-search-input {
        min-width: 0;
    }

    .inta-search-button {
        flex-shrink: 0;
    }

    /* テーブルのスクロール対応 */
    .inta-results-table-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    .inta-results-table {
        min-width: 600px;
    }

    /* 個体識別番号グリッド（タブレット） */
    .inta-id-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem 0.75rem;
        padding: 1rem;
    }

    .inta-id-item {
        font-size: 0.85rem;
        padding: 0.4rem 0.2rem;
    }

    /* NLBC説明文の調整 */
    .inta-nlbc-description {
        font-size: 0.9rem;
    }

    .inta-nlbc-button {
        width: 100%;
        text-align: center;
    }
}

/* ========================================
   レスポンシブ対応（スマホ）
   ======================================== */
@media screen and (max-width: 480px) {
    .inta-traceability-search-container {
        margin: 0;
    }

    .inta-section {
        margin-bottom: 2rem;
    }

    .inta-section-title {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .inta-section-number {
        font-size: 0.9rem;
        margin-right: 0.4rem;
    }

    /* セクション①：検索フォーム */
    .inta-search-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    .inta-search-field {
        flex-direction: column;
        gap: 0.75rem;
    }

    .inta-search-input {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px; /* iOSのズーム防止 */
    }

    .inta-search-button {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
    }

    .inta-product-label {
        max-width: 100%;
        padding: 0.75rem;
    }

    /* ローディング */
    .inta-loading {
        padding: 1rem 0;
    }

    .inta-loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }

    .inta-loading-text {
        font-size: 0.9rem;
    }

    /* エラーメッセージ */
    .inta-message {
        padding: 0.875rem;
        font-size: 0.9rem;
        margin-top: 0.75rem;
    }

    /* 個体識別番号グリッド（スマホ） */
    .inta-id-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .inta-id-item {
        font-size: 0.8rem;
        padding: 0.5rem 0.3rem;
    }

    /* セクション②：検索結果テーブル（カード形式） */
    .inta-results-table-wrapper {
        overflow-x: visible;
    }

    .inta-results-table {
        min-width: auto;
        border: none;
        font-size: 0.9rem;
    }

    .inta-results-table,
    .inta-results-table thead,
    .inta-results-table tbody,
    .inta-results-table th,
    .inta-results-table td,
    .inta-results-table tr {
        display: block;
    }

    .inta-results-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .inta-results-table tbody:empty::before {
        padding: 2rem 1rem;
        font-size: 0.9rem;
    }

    .inta-results-table tr {
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 0.75rem;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .inta-results-table td {
        position: relative;
        padding: 0.625rem 0.625rem 0.625rem 45%;
        text-align: right;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .inta-results-table td:last-child {
        border-bottom: none;
    }

    .inta-results-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        top: 0.625rem;
        width: 40%;
        padding-right: 0.5rem;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: #666;
        font-size: 0.85rem;
    }

    .inta-results-table td a {
        font-size: 0.9rem;
        word-break: break-all;
    }

    /* セクション③：外部リンク */
    .inta-nlbc-description {
        font-size: 0.85rem;
        line-height: 1.7;
    }

    .inta-nlbc-button {
        padding: 0.875rem 2rem;
        font-size: 0.95rem;
    }
}

/* ========================================
   非常に小さいスマホ（320px以下）
   ======================================== */
@media screen and (max-width: 360px) {
    .inta-section-title {
        font-size: 0.9rem;
    }

    .inta-section-number {
        font-size: 0.85rem;
        margin-right: 0.3rem;
    }

    .inta-results-table td {
        padding-left: 50%;
        font-size: 0.85rem;
    }

    .inta-results-table td::before {
        width: 45%;
        font-size: 0.8rem;
    }

    /* 個体識別番号グリッド（小さいスマホ） */
    .inta-id-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .inta-id-item {
        font-size: 0.75rem;
    }
}

/* ========================================
   2列レイアウト用の汎用クラス
   ======================================== */
.inta-two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.inta-case-left,
.inta-case-right {
    display: flex;
    flex-direction: column;
}

/* 2列レイアウト内の検索フォームの調整 */
.inta-case-left .inta-search-input,
.inta-case-right .inta-search-input {
    width: 362px;
    flex: none;
}

.inta-case-left .inta-search-field,
.inta-case-right .inta-search-field {
    flex-wrap: wrap;
}

.inta-case-left .inta-search-button,
.inta-case-right .inta-search-button {
    flex-shrink: 0;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .inta-two-columns {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* モバイルでは検索窓を広げる */
    .inta-case-left .inta-search-input,
    .inta-case-right .inta-search-input {
        width: auto;
        flex: 1;
    }
}

/* ========================================
   2列レイアウト用の汎用クラス
   ======================================== */
.inta-two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.inta-case-left,
.inta-case-right {
    display: flex;
    flex-direction: column;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .inta-two-columns {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}
