/* ===================================
   1. 基本スタイル
=================================== */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

/* ===================================
   2. バリデーション
=================================== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

/* ===================================
   3. Blazor エラー UI
=================================== */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* ===================================
   4. ローディング
=================================== */
.loading-progress {
    position: absolute;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

/* ===================================
   5. Drawer / ナビゲーション
=================================== */
.drawer-style {
    background: #fff7fb;
}

.mud-nav-link {
    border-radius: 12px;
    margin: 4px 8px;
    padding: 10px 14px !important;
    font-weight: 500;
}

    .mud-nav-link:hover {
        background-color: #ffe3f0 !important;
    }

    .mud-nav-link.active {
        background-color: #ffb6d9 !important;
        color: #fff !important;
    }

/* ===================================
   6. 並び替え UI
=================================== */
.drag-handle {
    cursor: grab;
    font-size: 20px;
    color: #666;
}

.sortable-ghost {
    opacity: 0.4;
}

/* ===================================
   7. 画像セル（PC → 縦 / スマホ → 横）
=================================== */
.variant-image-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 120px;
}

@media (max-width: 600px) {
    .variant-image-cell {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
    }

        .variant-image-cell img {
            width: 80px !important;
            height: 80px !important;
        }
}

/* ===================================
   8. 所持・希望（PC → 縦 / スマホ → 横）
=================================== */
.count-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (max-width: 600px) {
    .count-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

        .count-wrapper .mud-input-root {
            width: 100%;
        }
}

/* ===================================
   9. URL + アイコン
=================================== */
.url-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===================================
   10. 画像編集（Cropper）
=================================== */
.cropper-top-bar,
.cropper-bottom-bar {
    width: 100%;
    background: white;
    padding: 8px 16px;
    z-index: 1;
}

.edit-root {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 56px); /* ← スマホ最適化 + AppBar 分を引く */
}

.cropper-main {
    flex: 1;
    overflow: hidden;
    background: transparent;
}

#crop-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: hidden;
}

#edit-image {
    position: absolute;
    user-select: none;
    touch-action: none;
}

#crop-container,
#edit-image,
#crop-frame,
.handle {
    touch-action: none;
}

/* トリミング枠の外側を暗くするオーバーレイ */
.crop-overlay {
    position: absolute;
    background: rgba(0,0,0,0.5);
    pointer-events: none;
}

    /* 上・下・左・右の4枚を作る */
    .crop-overlay.top,
    .crop-overlay.bottom,
    .crop-overlay.left,
    .crop-overlay.right {
        position: absolute;
        background: rgba(0,0,0,0.5);
    }

/* トリミング枠 */
#crop-frame {
    position: absolute;
    border: 3px dashed var(--mud-palette-primary);
    border-radius: 12px;
    box-shadow: 0 0 0 2px rgba(255, 182, 217, 0.4);
    box-sizing: border-box;
    pointer-events: none;
}

    #crop-frame.circle {
        border-radius: 50%;
        border: 3px dashed var(--mud-palette-primary);
    }

.handle {
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--mud-palette-primary);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    pointer-events: auto;
}

/* ハンドル位置 */
.handle-nw {
    top: -10px;
    left: -10px;
    cursor: nwse-resize;
}

.handle-ne {
    top: -10px;
    right: -10px;
    cursor: nesw-resize;
}

.handle-sw {
    bottom: -10px;
    left: -10px;
    cursor: nesw-resize;
}

.handle-se {
    bottom: -10px;
    right: -10px;
    cursor: nwse-resize;
}

/* ===================================
   11. 一括編集パネル
=================================== */
.editing-panel {
    background: #fff7e6 !important;
    border-left: 4px solid #ffa726 !important;
}

/* ===================================
   12. 商品一覧サムネイル
=================================== */
.variant-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: transparent;
    border-radius: 4px;
    margin-right: 8px;
}

.variant-thumb-large {
    width: 100px;
    height: 100px;
    object-fit: contain;
    background: transparent;
    border-radius: 4px;
}

/* ===================================
   13. ヘッダー（AppBar）
=================================== */
.full-width {
    width: 100%;
    display: flex;
}

.header-title {
    max-width: 60vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(14px, 4vw, 20px) !important; 
    line-height: 1.2;
}

/* ===================================
   14. 画像生成
=================================== */
.trade-card {
    width: 128px;
    height: 128px;
    position: relative;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    border: 2px solid transparent;
}

    .trade-card img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .trade-card .count-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        background: #ff4081;
        color: white;
        border-radius: 50%;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
    }

    .trade-card.gray {
        filter: grayscale(100%);
        opacity: 0.5;
    }

    /* 条件枠 */
    .trade-card.red {
        border-color: #ff5252;
    }

    .trade-card.yellow {
        border-color: #ffeb3b;
    }

    .trade-card.blue {
        border-color: #42a5f5;
    }

/* ================================
   グリッド全体
================================ */
.grid-container {
    display: grid;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
}

/* ================================
   グリッドのマス
================================ */
.grid-item {
    position: relative;
    background: white;
    border-radius: 6px;
    padding: 4px;
    min-height: 110px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* 並べ替え時のアニメーション */
    transition: transform 0.15s ease;
}

/* SortableJS のゴースト */
.sortable-ghost {
    opacity: 0.4;
}

/* ================================
   画像
================================ */
.grid-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ================================
   テキスト（画像なし）
================================ */
.grid-text {
    font-size: 0.9rem;
    text-align: center;
    padding: 4px;
    color: #555;
    word-break: break-word;
}

/* ================================
   丸数字（個数バッジ）
================================ */
.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #1976d2;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
}

    .badge.zero {
        background: #bdbdbd;
    }

/* ================================
   枠線（色付き）
================================ */
.border-red {
    border: 3px solid #ef5350;
}

.border-yellow {
    border: 3px solid #ffeb3b;
}

.border-blue {
    border: 3px solid #42a5f5;
}

/* ================================
   選択中のマス（クリックで選択）
================================ */
.grid-item.selected {
    outline: 3px solid #42a5f5;
    outline-offset: -3px;
}
