/* ===================================================
   テプラシール作成ツール スタイルシート
   =================================================== */

:root {
    --primary-color: #38bdf8;
    --primary-hover: #0ea5e9;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.12);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #10b981;
}

.tepra-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.tepra-header {
    margin-bottom: 1.5rem;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.title-badge {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.05em;
}

.tepra-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.tepra-header .subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0;
}

/* 2カラムグリッド */
.tepra-grid {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 1.5rem;
    align-items: start;
}

.control-panel {
    order: 1;
}

.preview-panel {
    order: 2;
    position: sticky;
    top: 1rem;
}

@media (max-width: 900px) {
    .tepra-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* スマホでは実寸プレビューを最上部に配置！ */
    .preview-panel {
        order: -1;
        position: static;
    }

    .control-panel {
        order: 1;
    }
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* フォーム共通 */
.form-group {
    margin-bottom: 1.4rem;
}

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 0.6rem;
}

.label-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* 1. テープ幅セレクター */
.tape-width-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.tape-btn {
    padding: 0.65rem 0.2rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tape-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
}

.tape-btn.active {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

/* 2. 管理番号入力ボックス */
.code-input-container {
    display: flex;
    align-items: stretch;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid rgba(56, 189, 248, 0.4);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s ease;
}

.code-input-container:focus-within {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.code-prefix-box {
    background: rgba(56, 189, 248, 0.15);
    border-right: 2px solid rgba(56, 189, 248, 0.3);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.prefix-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.35rem;
    font-weight: 900;
    color: #38bdf8;
    letter-spacing: 0.05em;
}

.code-number-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem 0.85rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.1em;
    outline: none;
    min-width: 0;
}

.step-buttons {
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-step {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 800;
    padding: 0 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-step:hover {
    background: rgba(56, 189, 248, 0.25);
    color: #38bdf8;
}

.btn-step:active {
    background: rgba(56, 189, 248, 0.4);
}

.input-quick-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.quick-pad-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.quick-pad-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.quick-pad-btn.reset {
    margin-left: auto;
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.quick-pad-btn.reset:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* 3. テープ色セレクター */
.tape-color-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.45rem;
}

.color-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-preview {
    width: 28px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 900;
}

.color-name {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.color-btn.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: #38bdf8;
}

.color-btn.active .color-name {
    color: #38bdf8;
    font-weight: 800;
}

/* 詳細設定アコーディオン */
.adv-settings,
.batch-settings {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-top: 1rem;
    overflow: hidden;
}

.adv-settings summary,
.batch-settings summary {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.adv-settings summary:hover,
.batch-settings summary:hover {
    color: #e2e8f0;
}

.adv-content,
.batch-content {
    padding: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.sub-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.sub-form-group input[type="range"] {
    width: 100%;
    accent-color: #38bdf8;
}

.form-select,
.form-input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0.45rem 0.65rem;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
}

.form-select:focus,
.form-input:focus {
    border-color: #38bdf8;
}

.batch-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.batch-col {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-switch input {
    accent-color: #38bdf8;
    width: 16px;
    height: 16px;
}

/* ===================================================
   プレビューパネル
   =================================================== */
.preview-panel {
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.preview-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.dim-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.stage-scale-controls {
    display: flex;
    gap: 0.35rem;
}

.btn-scale {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-scale.active {
    background: #38bdf8;
    color: #0f172a;
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.preview-stage-wrap {
    background: #0b1120;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.85rem;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.preview-stage {
    width: 100%;
    overflow-x: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    min-height: 120px;
}

.label-svg-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.7));
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center center;
    max-width: 100%;
}

.label-svg-container svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.label-svg-container svg {
    display: block;
    max-width: 100%;
}

.dimension-guide {
    display: flex;
    gap: 1.25rem;
    margin-top: 1rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.75rem;
    width: 100%;
}

.dimension-guide strong {
    color: #e2e8f0;
}

/* エクスポートアクションボタン群 */
.export-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .action-grid {
        grid-template-columns: 1fr;
    }
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.export-btn .btn-icon {
    font-size: 1.5rem;
}

.export-btn .btn-text {
    display: flex;
    flex-direction: column;
}

.export-btn .btn-text strong {
    font-size: 0.95rem;
    font-weight: 800;
}

.export-btn .btn-text small {
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 0.15rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-success:hover {
    background: linear-gradient(135deg, #047857, #065f46);
    transform: translateY(-1px);
}

.action-row {
    display: flex;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: none;
}

.btn-secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
}

.btn-outline:hover {
    background: rgba(56, 189, 248, 0.15);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* 連番プレビューエリア */
.batch-preview-section {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.25rem;
}

.batch-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.batch-preview-header h3 {
    font-size: 0.95rem;
    color: #e2e8f0;
    margin: 0;
}

.batch-labels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.85rem;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.3rem;
}

.batch-item-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.batch-item-card svg {
    max-width: 100%;
    height: auto;
}

.batch-item-label {
    font-size: 0.75rem;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    color: #38bdf8;
}

/* フッターナビ */
.footer-nav {
    margin-top: 2rem;
    text-align: center;
}

.btn-back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.btn-back-link:hover {
    color: #38bdf8;
}

/* ===================================================
   スマホ・モバイル最適化スタイル (ファーストビュー完全対応)
   =================================================== */
@media (max-width: 768px) {
    header {
        padding: 0.5rem 0.8rem !important;
        position: static !important;
    }

    header h1 {
        font-size: 1.15rem !important;
        margin: 0 !important;
    }

    header p {
        display: none !important;
    }

    main.app-main {
        padding: 0.4rem 0.5rem !important;
    }

    .tepra-container {
        padding: 0.2rem 0 !important;
    }

    .tepra-header {
        margin-bottom: 0.5rem !important;
        text-align: center;
    }

    .title-row {
        justify-content: center;
        margin-bottom: 0;
    }

    .tepra-header h1 {
        font-size: 1.05rem;
    }

    .tepra-header .subtitle {
        display: none;
    }

    .card {
        padding: 0.75rem 0.85rem !important;
        border-radius: 0.75rem !important;
    }

    .section-title {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* プレビューパネル */
    .preview-header {
        margin-bottom: 0.4rem !important;
    }

    .dim-badge {
        font-size: 0.72rem !important;
        padding: 0.15rem 0.5rem !important;
    }

    .btn-scale {
        padding: 0.2rem 0.45rem !important;
        font-size: 0.7rem !important;
    }

    .preview-stage-wrap {
        min-height: 90px !important;
        padding: 0.5rem 0.35rem !important;
        border-radius: 0.65rem !important;
    }

    .preview-stage {
        min-height: 70px !important;
        padding: 0.25rem 0 !important;
    }

    .dimension-guide {
        gap: 0.6rem !important;
        margin-top: 0.4rem !important;
        padding-top: 0.4rem !important;
        font-size: 0.72rem !important;
    }

    /* コントロールパネル */
    .form-group {
        margin-bottom: 0.6rem !important;
    }

    .form-label {
        font-size: 0.8rem !important;
        margin-bottom: 0.25rem !important;
    }

    .tape-width-selector {
        gap: 0.35rem !important;
    }

    .tape-btn {
        padding: 0.45rem 0.15rem !important;
        font-size: 0.85rem !important;
        border-radius: 6px !important;
    }

    .code-input-container {
        height: 42px !important;
        border-radius: 8px !important;
    }

    .code-prefix-box {
        padding: 0 0.65rem !important;
    }

    .prefix-text {
        font-size: 1.1rem !important;
    }

    .code-number-input {
        font-size: 1.25rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    .btn-step {
        font-size: 0.85rem !important;
        padding: 0 0.65rem !important;
    }

    /* エクスポートボタン群 */
    .export-actions {
        margin-top: 0.6rem !important;
        gap: 0.45rem !important;
    }

    .action-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.45rem !important;
    }

    .export-btn {
        padding: 0.55rem 0.65rem !important;
        border-radius: 8px !important;
        gap: 0.5rem !important;
    }

    .export-btn .btn-icon {
        font-size: 1.2rem !important;
    }

    .export-btn .btn-text strong {
        font-size: 0.85rem !important;
    }

    .export-btn .btn-text small {
        font-size: 0.65rem !important;
    }

    .action-row {
        gap: 0.45rem !important;
    }

    .action-row .btn {
        padding: 0.45rem 0.5rem !important;
        font-size: 0.78rem !important;
    }

    /* 詳細設定・連番設定 */
    .adv-settings,
    .batch-settings {
        margin-top: 0.45rem !important;
    }

    .adv-settings summary,
    .batch-settings summary {
        padding: 0.45rem 0.65rem !important;
        font-size: 0.78rem !important;
    }

    .adv-content,
    .batch-content {
        padding: 0.65rem !important;
        gap: 0.5rem !important;
    }

    .footer-nav {
        margin-top: 1rem !important;
    }
}

/* 印刷用スタイル */
@media print {
    body * {
        visibility: hidden;
    }

    #print-sheet-container,
    #print-sheet-container * {
        visibility: visible;
    }

    #print-sheet-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8mm;
        padding: 10mm;
    }
}
