/* ローカルフォントの読み込み */
@font-face {
    font-family: 'ChilloutTYP';
    src: url('./font/ChilloutTYP-Regular.otf') format('opentype');
    font-display: swap;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF; /* 英数字・ひらがな・カタカナ */
}

@font-face {
    font-family: 'kakumarukko_ts';
    src: url('./font/kakumarukko_ts-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}


@font-face {
    font-family: 'x12y12pxMaruMinyaM';
    src: url('./font/x12y12pxMaruMinyaM.ttf') format('truetype');
    font-display: swap;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}

@font-face {
    font-family: 'x10y12pxDonguriDuel';
    src: url('./font/x10y12pxDonguriDuel.ttf') format('truetype');
    font-display: swap;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}

@font-face {
    font-family: 'YDWaosagi';
    src: url('./font/YDWaosagi.otf') format('opentype');
    font-display: block;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}

@font-face {
    font-family: 'Mamelon-5-Hi-Regular';
    src: url('./font/Mamelon-5-Hi-Regular.otf') format('opentype');
    font-display: block;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}

@font-face {
    font-family: 'Togalite-Bold';
    src: url('./font/Togalite-Bold.otf') format('opentype');
    font-display: block;
    unicode-range: U+0030-0039, U+0041-005A, U+0061-007A, U+3040-309F, U+30A0-30FF;
}


body {
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-container {
    display: flex;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
    gap: 30px;
    flex: 1;
}

/* 左側：ツールパレット */
.control-panel {
    flex: 0 0 360px;
    background: #2c2c2c;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ツールバー */
.toolbar {
    background: #1e1e1e;
    padding: 8px;
    border-bottom: 1px solid #444;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.tool-btn {
    width: 48px;
    height: 48px;
    background: #3a3a3a;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ccc;
    transition: all 0.2s;
    position: relative;
}

.tool-btn:hover {
    background: #4a4a4a;
    border-color: #666;
    transform: scale(1.05);
}

.tool-btn.active {
    background: #007bff;
    border-color: #0056b3;
    color: white;
}

.tool-btn .tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 2147483647;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

.tool-btn .tooltip::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0,0,0,0.95);
}

.tool-btn:hover .tooltip {
    opacity: 1;
}

/* プロパティパネル */
.properties-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.property-group {
    background: #3a3a3a;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 12px;
}

.property-group h4 {
    color: #ccc;
    font-size: 12px;
    text-transform: uppercase;
    margin: 0 0 10px 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* カラーパレット */
.color-palette {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: white;
}

.color-swatch.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.3);
}

/* スライダー */
.property-slider {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
}

.property-slider label {
    color: #aaa;
    font-size: 12px;
    min-width: 45px;
}

.property-slider input[type="range"] {
    flex: 1;
    background: transparent;
}

.property-slider .value {
    color: #ccc;
    font-size: 12px;
    min-width: 30px;
    text-align: right;
    margin-left: 2px;
}

/* カスタムスライダー */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, #777, #999);
    outline: none;
    border-radius: 3px;
    border: 1px solid #666;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: auto;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    cursor: grab;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    pointer-events: auto;
    -webkit-user-drag: none;
    user-drag: none;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: scale(1.1);
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    background: linear-gradient(135deg, #004085, #002752);
    transform: scale(1.05);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    cursor: grab;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    pointer-events: auto;
    -moz-user-drag: none;
    user-drag: none;
}

input[type="range"]::-moz-range-thumb:active {
    cursor: grabbing;
    background: linear-gradient(135deg, #004085, #002752);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: linear-gradient(to right, #777, #999);
    border-radius: 3px;
    border: 1px solid #666;
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    color: #495057;
    font-size: 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 右側：プレビューエリア */
.preview-area {
    flex: 1;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.canvas-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.canvas-section {
    text-align: center;
}

.canvas-wrapper {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    display: inline-block;
    position: relative;
}

.thumbnail-canvas {
    border: 2px solid #dee2e6;
    background: #fff;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: cursor 0.2s;
}

.thumbnail-canvas.text-tool-active {
    cursor: crosshair !important;
}

/* テキストハンドル */
.text-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #007bff;
    border: 2px solid white;
    border-radius: 50%;
    cursor: move;
    z-index: 1000;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.2s, width 0.2s, height 0.2s;
}

.canvas-wrapper:hover .text-handle {
    opacity: 1;
}

.text-handle:hover {
    background: #0056b3;
    width: 12px;
    height: 12px;
}

.text-handle.active {
    background: #dc3545;
    box-shadow: 0 0 0 2px rgba(220,53,69,0.3);
    opacity: 1;
}

/* インライン編集ボックス */
.inline-text-editor {
    position: absolute;
    z-index: 2000;
    background: white;
    border: 2px solid #007bff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 250px;
}

.inline-text-input {
    width: 100%;
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 14px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.inline-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.inline-font-select {
    flex: 1;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.inline-size-input {
    width: 60px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.inline-color-input {
    width: 40px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.inline-buttons {
    display: flex;
    gap: 8px;
}

.inline-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.inline-btn-primary {
    background: #007bff;
    color: white;
}

.inline-btn-secondary {
    background: #6c757d;
    color: white;
}

.inline-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}


.canvas-label {
    margin-top: 10px;
    font-size: 14px;
    color: #6c757d;
}

/* 連動チェックボックス */
.sync-control {
    background: #e7f3ff;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.sync-control label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
}

.sync-control input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* パターンプリセット */
.pattern-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.pattern-btn {
    padding: 12px 8px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 12px;
    text-align: center;
}

.pattern-btn:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pattern-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* コントロール */
.color-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.color-input {
    width: 60px;
    height: 35px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    cursor: pointer;
}

.slider-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.slider-control input[type="range"] {
    flex: 1;
}

.slider-value {
    min-width: 45px;
    text-align: right;
    font-size: 14px;
    color: #6c757d;
}

.text-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 10px;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-success {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #f9d423 0%, #ff4e50 100%);
}

.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* フッター */
footer {
    background: #2c3e50;
    color: white;
    padding: 15px 0;
    text-align: center;
    margin-top: 100px;
    min-height: 60px;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    color: #5dade2;
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .control-panel {
        flex: 1;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .pattern-presets {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .btn-group {
        grid-template-columns: 1fr;
    }
}

/* モーダルスタイル */
.modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: #2c2c2c;
    margin: 5% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    color: #fff;
}

.modal-header {
    padding: 20px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #fff;
    font-size: 24px;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 8px;
    border-radius: 4px;
    transition: all 0.3s;
}

.close:hover,
.close:focus {
    color: #fff;
    background-color: rgba(255,255,255,0.1);
}

.modal-body {
    padding: 0 24px 24px;
    line-height: 1.6;
}

.modal-body h3 {
    color: #4CAF50;
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 18px;
}

.modal-body p {
    margin-bottom: 12px;
    color: #ccc;
}

.modal-body a {
    color: #4CAF50;
    text-decoration: none;
    transition: color 0.3s;
}

.modal-body a:hover {
    color: #66BB6A;
}

/* テキストハンドルスタイル */
.text-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: move;
    z-index: 1000;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transform: translate(-50%, -50%);
}

.text-handle:hover {
    background: #45a049;
    transform: translate(-50%, -50%) scale(1.2);
}

/* フォント読み込み中オーバーレイ */
#fontLoadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.loading-subtext {
    font-size: 14px;
    opacity: 0.8;
}