@charset "UTF-8";

/* ==========================================================================
   トーラムオンライン マイルーム家具図鑑 スタイルシート
   - 温かみのあるウッド調・マイルームパレット
   - 階層型カテゴリタブ（大分類・場所・小分類）
   - 320px極小モバイル端末完全対応（文字縦潰れ防止・自動スタック）
   - 高コントラスト（背景と文字・フォーム入力の視認性確保）
   ========================================================================== */

:root {
    --primary: #85532b;
    --primary-dark: #583315;
    --primary-light: #f6ede4;
    --accent: #d97706;
    --accent-hover: #b45309;
    --bg-main: #f8f6f0;
    --bg-card: #ffffff;
    --text-main: #2b2520;
    --text-muted: #6b635b;
    --border-color: #e5ded6;
    --border-focus: #85532b;
    
    /* 素材ptカラー */
    --color-wood: #15803d;
    --color-medicine: #7e22ce;
    --color-metal: #475569;
    --color-cloth: #1d4ed8;
    --color-beast: #c2410c;
    --color-mana: #be185d;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(88,51,21,0.1);
    --shadow-lg: 0 10px 24px rgba(88,51,21,0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-width: 320px;
}

/* ==========================================================================
   共通ナビゲーション
   ========================================================================== */
.global-nav {
    background: #3b2819;
    border-bottom: 2px solid #5a3d27;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.05rem;
}

.nav-brand .logo-icon {
    color: #fbbf24;
}

.nav-links {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: #e5ded6;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.nav-link.btn-highlight {
    background: #d97706;
    color: #fff;
    font-weight: bold;
}
.nav-link.btn-highlight:hover {
    background: #b45309;
}

/* ==========================================================================
   メインレイアウト
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* ヒーローヘッダー */
.page-header {
    background: linear-gradient(135deg, #4a2f19, #724621);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.8rem 1.2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.page-header::after {
    content: "\f015";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 20px;
    bottom: -20px;
    font-size: 7rem;
    color: rgba(255,255,255,0.06);
    pointer-events: none;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fef3c7;
}

.page-header p {
    font-size: 0.9rem;
    color: #fde68a;
    line-height: 1.4;
    margin-bottom: 0.8rem;
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
}

/* ボタン */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #d97706;
    color: #fff;
}
.btn-primary:hover {
    background: #b45309;
}

.btn-secondary {
    background: #fff;
    color: #4a2f19;
    border: 1px solid #dcd3c8;
}
.btn-secondary:hover {
    background: #f4ede4;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}
.btn-danger:hover {
    background: #b91c1c;
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   検索・階層カテゴリコントロールパネル（ゲーム内マイルーム感覚のUI）
   ========================================================================== */
.control-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* 第1階層：大分類タブ（すべて / 家の改装 / 家具） */
.main-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.main-tab {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    background: #ede6dc;
    color: #4a3e35;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.main-tab:hover {
    background: #dfd5c7;
}

.main-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(133,83,43,0.3);
}

/* 第2階層・第3階層：場所と詳細種別のサブタブエリア */
.sub-tabs-container {
    background: #fbf9f5;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.8rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sub-tabs-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sub-tabs-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--primary-dark);
    min-width: 65px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.sub-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.sub-chip {
    padding: 0.3rem 0.65rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #d8cfc4;
    color: #554a40;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.sub-chip:hover {
    background: #f4ede4;
    border-color: var(--primary);
}

.sub-chip.active {
    background: #d97706;
    color: #fff;
    border-color: #b45309;
    box-shadow: 0 1px 4px rgba(217,119,6,0.3);
}

/* 検索窓・並び替え（レスポンシブ） */
.search-bar-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-input-wrap i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.6rem 0.85rem 0.6rem 2.3rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: #fff;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--border-focus);
}

@media (max-width: 480px) {
    .search-bar-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==========================================================================
   家具一覧グリッド＆カード
   ========================================================================== */
.furniture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.furniture-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}

.furniture-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #ccb9a6;
}

.card-image-wrap {
    width: 100%;
    height: 180px;
    background: #f0eae1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.furniture-card:hover .card-image {
    transform: scale(1.03);
}

.card-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9c8c7c;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.card-image-placeholder i {
    font-size: 2.2rem;
}

/* カテゴリ・場所バッジ */
.card-badges-wrap {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.card-badge {
    background: rgba(30, 20, 10, 0.82);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    backdrop-filter: blur(4px);
}

.card-badge-sub {
    background: rgba(217, 119, 6, 0.88);
}

/* カード本文 */
.card-body {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

.card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.7rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.3rem;
}

/* 素材ptタグ一覧 */
.pts-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.7rem;
}

.pt-chip {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.pt-wood     { background-color: var(--color-wood); }
.pt-medicine { background-color: var(--color-medicine); }
.pt-metal    { background-color: var(--color-metal); }
.pt-cloth    { background-color: var(--color-cloth); }
.pt-beast    { background-color: var(--color-beast); }
.pt-mana     { background-color: var(--color-mana); }

.card-special-mat {
    font-size: 0.76rem;
    color: #78350f;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.7rem;
    line-height: 1.3;
}

.card-footer {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.card-contributor {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

/* ==========================================================================
   フォーム・入力画面（登録・編集画面用）
   ========================================================================== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: block;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: var(--text-main);
}

.form-label .badge-req {
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    margin-left: 0.35rem;
    font-weight: normal;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    background: #fff;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--border-focus);
}

select.form-control {
    background-color: #fff;
    color: #1c1917;
    font-weight: 500;
}

.pts-input-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .pts-input-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 380px) {
    .pts-input-grid {
        grid-template-columns: 1fr;
    }
}

.pt-input-item {
    background: #fbf9f6;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.pt-input-item label {
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.25rem;
}

.image-upload-box {
    border: 2px dashed #ccb9a6;
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    background: #faf6f0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

.image-upload-box:hover {
    background: #f4ede4;
    border-color: var(--primary);
}

.image-upload-box input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.preview-container {
    margin-top: 1rem;
    display: none;
    text-align: center;
}

.preview-image {
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   家具詳細画面
   ========================================================================== */
.detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

.detail-img-wrap {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #f0eae1;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

.detail-img {
    width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: contain;
    display: block;
}

.detail-info h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}

.detail-meta-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.detail-desc-box {
    background: #faf7f2;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1.2rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

.detail-section-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
}

/* ==========================================================================
   管理者テーブル・モーダル
   ========================================================================== */
.admin-table-wrap {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.admin-table th {
    background: #ede6dc;
    padding: 0.75rem 0.6rem;
    font-weight: bold;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.admin-table td {
    padding: 0.7rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.admin-table tr:hover {
    background: #fbf9f6;
}

.table-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* 320pxスマホ完全対応スタイル */
@media (max-width: 320px) {
    .container {
        padding: 0.5rem;
    }
    .page-header {
        padding: 1.2rem 0.8rem;
    }
    .page-header h1 {
        font-size: 1.25rem;
    }
    .main-tab {
        padding: 0.45rem 0.8rem;
        font-size: 0.85rem;
    }
    .card-body {
        padding: 0.65rem;
    }
    .card-title {
        font-size: 0.95rem;
    }
    .btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.82rem;
    }
}

/* ==========================================================================
   画像トリミング（Cropper.js）モーダル & プレビュースタイル
   ========================================================================== */
.crop-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 10, 5, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 10px;
}

.crop-modal-dialog {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.crop-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    background: #fbf9f6;
    border-bottom: 1px solid var(--border-color);
}

.crop-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.crop-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.crop-close-btn:hover {
    color: var(--text-main);
}

.crop-modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.crop-img-wrapper {
    width: 100%;
    height: 380px;
    max-height: 50vh;
    background: #2b2520;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* ツールバー */
.crop-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: #fbf9f6;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.8rem;
}

.crop-aspect-group,
.crop-action-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.crop-tool-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}

.crop-btn {
    background: #ede6dc;
    border: 1px solid #d8cfc4;
    color: #4a3e35;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.crop-btn:hover {
    background: #dfd5c7;
}

.crop-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
}

.crop-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    background: #fbf9f6;
    border-top: 1px solid var(--border-color);
}

/* トリミング済みプレビューボックス */
.crop-preview-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fbf9f6;
    border: 1.5px solid #d97706;
    border-radius: var(--radius-md);
    padding: 0.8rem;
    margin-top: 0.8rem;
}

.crop-preview-thumb {
    width: 90px;
    height: 90px;
    object-fit: cover;
    background: #2b2520;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.crop-preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.crop-preview-badge {
    display: inline-block;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    width: fit-content;
}

.crop-preview-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

/* 320pxスマホ対応 */
@media screen and (max-width: 480px) {
    .crop-modal-dialog {
        max-height: 98vh;
        border-radius: 12px;
    }
    .crop-modal-body {
        padding: 8px;
    }
    .crop-img-wrapper {
        height: 240px;
        max-height: 40vh;
    }
    .crop-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .crop-aspect-group,
    .crop-action-group {
        justify-content: flex-start;
        width: 100%;
    }
    .crop-modal-footer {
        flex-direction: column-reverse;
        padding: 8px;
    }
    .crop-modal-footer .btn {
        width: 100%;
    }
    .crop-preview-box {
        flex-direction: column;
        align-items: flex-start;
    }
    .crop-preview-thumb {
        width: 100%;
        max-width: 150px;
        height: auto;
        aspect-ratio: 1 / 1;
        align-self: center;
    }
}
