/* CSS変数 */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --success: #22c55e;
    --error: #ef4444;
    --info: #3b82f6;
}

/* リセットと基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* コンテナ */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* タブナビゲーション */
.tab-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--surface-light);
    padding-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* タブコンテンツ */
.tab-content {
    display: none;
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* セクションヘッダー */
.tab-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* フォーム要素 */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input[type="text"],
input[type="url"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 0.25rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* レンジスライダー */
.range-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.range-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn.primary {
    width: 100%;
    background: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn.secondary {
    width: 100%;
    background: var(--success);
    color: white;
    margin-top: 1rem;
}

.btn.secondary:hover {
    background: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn.tertiary {
    width: 100%;
    background: var(--info);
    color: white;
    margin-top: 1rem;
}

.btn.tertiary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.button-group .btn {
    margin-top: 0.5rem;
}

/* プレビューコンテナ */
.preview-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--surface-light);
    text-align: center;
}

.preview-container h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-container canvas {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* オーバーレイ用キャンバスラッパー（透明パターンを表示） */
.canvas-wrapper {
    display: inline-block;
    background-image: 
        linear-gradient(45deg, #808080 25%, transparent 25%),
        linear-gradient(-45deg, #808080 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #808080 75%),
        linear-gradient(-45deg, transparent 75%, #808080 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #666;
    border-radius: 8px;
    overflow: hidden;
}

.preview-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    font-style: italic;
}

/* 非表示クラス（詳細度で解決） */
.preview-container.hidden {
    display: none;
}

/* エラーメッセージ */
.error-message {
    display: block;
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.error-message:empty {
    display: none;
}

/* 入力エラー状態 */
input.input-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* フッター */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--surface-light);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* レスポンシブデザイン */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .tab-content {
        padding: 1.5rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* エラー状態 */
input:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

/* ローディング状態 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mode Toggle Styles */
.mode-toggle-container {
    margin-bottom: 1.5rem;
}

.mode-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.mode-toggle {
    display: flex;
    background: var(--surface-light);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Advanced Controls Section */
.advanced-controls {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--surface-light);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.advanced-controls.hidden {
    display: none;
}

.advanced-section-title {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* File Upload Styles */
.file-upload-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

input[type="file"] {
    flex: 1;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

input[type="file"]:hover {
    border-color: var(--primary-color);
}

input[type="file"]::file-selector-button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    margin-right: 0.75rem;
    transition: background 0.3s ease;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    background: var(--error);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

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

.file-name {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Gradient Colors Row */
#gradient-colors.hidden {
    display: none;
}
