/* ==========================================================================
   バーコード・QRラベルジェネレーター スタイルシート
   ========================================================================== */

/* 1. 基本変数とリセット */
:root {
    --bg-color: #121212;
    /* メイン背景（ダークグレー） */
    --panel-bg: #1e1e1e;
    /* パネル背景（少し明るいダークグレー） */
    --accent-color: #ffffff;
    /* アクセントカラー（白） */
    --accent-hover: #e0e0e0;
    /* アクセントホバー */
    --text-main: #ffffff;
    /* メインテキスト（白） */
    --text-muted: #a0a0a0;
    /* サブテキスト（グレー） */
    --border-color: #333333;
    /* 境界線 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --font-family: 'Outfit', 'Inter', 'Noto Sans JP', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 2. レイアウト構成 */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* 操作パネル（左側） */
.control-panel {
    width: 420px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #262626 0%, #171717 100%);
}

.panel-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h1 i {
    color: var(--accent-color);
}

.panel-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* フォームグループ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ラジオボタン・カードセレクト */
.radio-tile-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.radio-tile-group.two-cols {
    grid-template-columns: repeat(2, 1fr);
}

.radio-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background-color: #1f1f1f;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.radio-tile input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-tile i {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.radio-tile span {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.radio-tile:hover {
    border-color: var(--accent-color);
    background-color: #2a2a2a;
}

.radio-tile input:checked+.tile-content i,
.radio-tile input:checked+.tile-content span {
    color: var(--accent-color);
}

.radio-tile:has(input:checked) {
    border-color: var(--accent-color);
    background-color: #333333;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

/* 説明書ボタン（オレンジ） */
.guide-btn-orange {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background-color: #ff8800;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 700;
    width: auto;
    margin-top: 8px;
}

.guide-btn-orange:hover {
    background-color: #e67600;
    transform: translateY(-1px);
}

/* 説明書ガイドモーダルオーバーレイ【★初期状態を display: none; に修正】 */
.guide-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* activeクラス適用時のみ表示 */
.guide-modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* ガイドモーダルウィンドウ */
.guide-modal-content {
    width: 700px;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    color: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guide-modal-overlay.active .guide-modal-content {
    transform: translateY(0);
}

.guide-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    flex-shrink: 0;
}

.guide-modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.guide-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
}

.guide-modal-close:hover {
    color: #ef4444;
}

.guide-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 1.05rem;
    line-height: 1.6;
    overflow-y: auto;
    padding-right: 8px;
}

.guide-modal-body ol,
.guide-modal-body ul {
    padding-left: 20px;
}

.guide-modal-body h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 8px;
    color: #ff8800;
}

/* 動的入力フォームエリア */
.dynamic-input-area {
    background-color: #1f1f1f;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.input-container {
    display: none;
    animation: fadeIn 0.3s ease forwards;
}

.input-container.active {
    display: block;
}

/* ロケコード分割入力 */
.loc-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    background-color: #171717;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.loc-box {
    width: 28px;
    height: 34px;
    background-color: #262626;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-main);
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    outline: none;
    transition: all 0.15s ease;
}

.loc-box:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
    background-color: #171717;
}

/* ロケコード専用桁幅補正 */
.loc-box[data-max="1"] {
    width: 22px;
}

.loc-box[data-max="2"] {
    width: 30px;
}

.loc-separator {
    color: var(--text-muted);
    font-weight: 700;
    user-select: none;
}

/* 一般コード入力 */
.standard-input {
    width: 100%;
    padding: 12px;
    background-color: #171717;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    outline: none;
    transition: all 0.15s ease;
}

.standard-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.input-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 用紙設定グループ */
.paper-settings {
    background-color: #1f1f1f;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 10px 12px;
    background-color: #171717;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.select-wrapper::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.8rem;
}

/* アクションボタン・グループ */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background-color: #1f1f1f;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

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

.btn-secondary {
    background-color: #2a2a2a;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #3a3a3a;
}

#btn-clear-all {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

#btn-clear-all:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transform: translateY(-1px);
}

/* 最下部フィードバックテキストリンク */
.feedback-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    text-decoration: underline;
    margin-top: 4px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.feedback-link:hover {
    color: var(--accent-color);
}

/* プレビューコンテナ（右側） */
.preview-container {
    flex: 1;
    height: 100%;
    background-color: #0d0d0d;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px;
    position: relative;
}

/* 3. 用紙の再現設定 */
.paper-canvas {
    background-color: #ffffff;
    color: #000000;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    transform-origin: top center;
    transition: transform 0.2s ease;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 10px 10px;
}

/* 用紙サイズ対応 (CSS基準) */
.paper-canvas.a4-portrait {
    width: 204mm;
    height: 289mm;
}

.paper-canvas.a4-landscape {
    width: 289mm;
    height: 204mm;
}

.paper-canvas.clabel-portrait {
    width: 85mm;
    height: 115mm;
}

.paper-canvas.clabel-landscape {
    width: 115mm;
    height: 85mm;
}

.paper-canvas.manhattan-portrait {
    width: 55mm;
    height: 85mm;
}

.paper-canvas.manhattan-landscape {
    width: 85mm;
    height: 55mm;
}

/* 4. ラベルカード（ドラッグ＆リサイズ対象） */
.label-card {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid #94a3b8;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    overflow: hidden;
    width: 160px;
    height: 120px;
    min-width: 80px;
    min-height: 60px;
}

.label-card:hover {
    border-color: #00a29a;
    /* ニトリグリーンホバー */
}

.label-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    pointer-events: none;
}

.label-card:hover::after {
    border-color: #00a29a;
}

/* テキストラベル部分 */
.label-header-text,
.label-footer-text {
    font-weight: 700;
    color: #000000;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    font-family: monospace;
}

.label-header-text {
    font-size: 16px;
    margin-bottom: 2px;
}

.label-footer-text {
    font-size: 13px;
    margin-top: 2px;
}

/* カスタムサイズ入力 */
.hidden {
    display: none !important;
}

.custom-size-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
    animation: fadeIn 0.2s ease forwards;
}

.custom-size-inputs .input-sub-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.custom-size-inputs label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.custom-size-inputs input {
    width: 100%;
    padding: 8px;
    background-color: #171717;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    text-align: center;
}

.custom-size-inputs input:focus {
    border-color: var(--accent-color);
}

/* バーコードコンテナ */
.label-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: calc(100% - 20px);
    overflow: hidden;
}

.label-media-container canvas,
.label-media-container svg,
.label-media-container img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ラベル削除用ボタン */
.btn-delete-label {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    z-index: 5;
}

.btn-delete-label:hover {
    background-color: #b91c1c;
}

/* ラベル複製用ボタン */
.btn-duplicate-label {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    z-index: 5;
}

.btn-duplicate-label:hover {
    background-color: #1d4ed8;
}

/* 右下リサイズハンドル */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #00a29a;
    right: 0;
    bottom: 0;
    cursor: se-resize;
    display: none;
    border-top-left-radius: 3px;
}

.label-card:hover .resize-handle {
    display: block;
}

/* ズームコントローラー */
.zoom-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 5;
}

.zoom-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.zoom-btn:hover {
    background-color: #334155;
    color: var(--accent-color);
}

.zoom-value {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   6. フィードバック（ご要望送信）モーダルのスタイル【★初期状態を display: none; に修正】
   ========================================================================== */
.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* activeクラス適用時のみ表示 */
.feedback-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.feedback-modal {
    width: 420px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-main);
}

.feedback-modal-overlay.active .feedback-modal {
    transform: translateY(0);
}

.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
}

.feedback-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-close-btn:hover {
    color: #ef4444;
}

.feedback-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feedback-modal-body p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.feedback-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feedback-form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.feedback-select {
    width: 100%;
    padding: 10px;
    background-color: #171717;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.feedback-textarea {
    width: 100%;
    height: 120px;
    padding: 10px;
    background-color: #171717;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    resize: none;
}

.feedback-textarea:focus {
    border-color: var(--accent-color);
}

.feedback-submit-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: #000000;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.feedback-submit-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.feedback-submit-btn:disabled {
    background-color: #262626;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* スピナーとサクセス状態 */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.feedback-success-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    text-align: center;
    gap: 10px;
}

.feedback-success-state i {
    font-size: 2.5rem;
    color: #10b981;
    animation: scaleUp 0.3s ease;
}

@keyframes scaleUp {
    from {
        transform: scale(0.6);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   7. 印刷用設定 (@media print)
   ========================================================================== */
@media print {

    body,
    html {
        background-color: #ffffff;
        color: #000000;
        height: auto;
        overflow: visible;
        margin: 0 !important;
        padding: 0 !important;
    }

    .app-container {
        display: block;
        height: auto;
    }

    .control-panel,
    .settings-panel,
    .input-panel,
    .zoom-controls,
    .btn-delete-label,
    .btn-duplicate-label,
    .resize-handle,
    .feedback-modal-overlay,
    .guide-modal-overlay {
        display: none !important;
    }

    .label-card.editing {
        outline: none !important;
    }

    .preview-container {
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
    }

    .paper-canvas {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        transform: scale(1) !important;
        transform-origin: center center !important;
        background-image: none !important;
        page-break-after: always;
        page-break-inside: avoid;
    }

    .label-card {
        border: 1px solid #cccccc !important;
    }

    @page {
        margin: 0;
    }
}

/* ==========================================================================
   8. ローディングオーバーレイ
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.loading-overlay.active {
    opacity: 1;
}
.loading-container {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px;
    width: 320px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}
.loading-title {
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
}
.progress-bar-wrapper {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-bar {
    background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
    height: 100%;
    width: 0%;
    transition: width 0.1s ease-out;
}
.loading-percentage {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
}