/**
 * よろずやツール - ツールページ共通CSS
 */

/* Tool Page */
.tool-page {
    max-width: 800px;
    margin: 0 auto;
}

.tool-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 0.5rem;
}

.tool-description {
    color: #6b7280;
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

/* Tool Body */
.tool-body {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Form Elements */
.tool-body label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.375rem;
}

.tool-body textarea,
.tool-body input[type="text"],
.tool-body input[type="number"],
.tool-body input[type="url"],
.tool-body input[type="date"],
.tool-body select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #1f2937;
    font-family: inherit;
    transition: border-color 0.2s;
}

.tool-body textarea:focus,
.tool-body input:focus,
.tool-body select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tool-body textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

/* Input/Output Areas */
.tool-input,
.tool-output {
    margin-bottom: 1rem;
}

.tool-output {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    min-height: 60px;
}

.tool-output pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
}

/* Action Buttons */
.tool-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}

.tool-btn:active {
    transform: scale(0.97);
}

.tool-btn-primary {
    background: #2563eb;
    color: #fff;
}

.tool-btn-primary:hover {
    background: #1d4ed8;
}

.tool-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.tool-btn-secondary:hover {
    background: #d1d5db;
}

.tool-btn-copy {
    background: #10b981;
    color: #fff;
}

.tool-btn-copy:hover {
    background: #059669;
}

.tool-btn-copy.copied {
    background: #6b7280;
}

/* Result Stats */
.tool-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.tool-stat {
    text-align: center;
}

.tool-stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: #2563eb;
    line-height: 1.2;
}

.tool-stat-label {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Options Row */
.tool-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    margin: 0.75rem 0;
}

.tool-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 400;
    font-size: 0.875rem;
    margin-bottom: 0;
    cursor: pointer;
}

.tool-options input[type="checkbox"],
.tool-options input[type="radio"] {
    width: auto;
}

/* Tabs */
.tool-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1rem;
}

.tool-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.tool-tab:hover {
    color: #2563eb;
}

.tool-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Color Preview */
.color-preview {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

/* Regex Match Highlight */
.match-highlight {
    background: #fef08a;
    border-radius: 2px;
    padding: 0 1px;
}

/* Usage Guide */
.usage-guide {
    margin: 2rem 0;
}

.usage-guide h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.usage-guide ol,
.usage-guide ul {
    margin: 0.75rem 0 0.75rem 1.5rem;
    line-height: 1.8;
}

.usage-guide p {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

/* Related Tools */
.related-tools {
    margin: 2rem 0;
}

.related-tools h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.related-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.related-tool-card {
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.related-tool-card:hover {
    text-decoration: none;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.related-tool-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.related-tool-card p {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.375rem;
}

.related-tool-link {
    font-size: 0.75rem;
    color: #2563eb;
    font-weight: 500;
}

/* FAQ */
.faq-section {
    margin: 2rem 0;
}

.faq-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.faq-list dt {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1f2937;
    margin-top: 0.75rem;
    padding: 0.625rem 1.75rem 0.625rem 1.25rem;
    position: relative;
    background: #f9fafb;
    border-radius: 6px;
    user-select: none;
}

.faq-list dt::before {
    content: 'Q.';
    position: absolute;
    left: 0.375rem;
    color: #2563eb;
    font-weight: 700;
}

.faq-list dt::after {
    content: '+';
    position: absolute;
    right: 0.625rem;
    color: #9ca3af;
    font-weight: 400;
    font-size: 1.125rem;
}

.faq-list dt.faq-open::after {
    content: '-';
}

.faq-list dd {
    font-size: 0.875rem;
    color: #4b5563;
    margin: 0 0 0 1.25rem;
    padding: 0.5rem 0 0.5rem 0;
    line-height: 1.7;
}

/* JSON Syntax Highlighting */
.json-highlighted {
    counter-reset: json-line;
}

.json-key {
    color: #2563eb;
}

.json-string {
    color: #16a34a;
}

.json-number {
    color: #ea580c;
}

.json-boolean {
    color: #dc2626;
}

.json-null {
    color: #9ca3af;
}

.json-line-num {
    display: inline-block;
    width: 3em;
    text-align: right;
    padding-right: 1em;
    margin-right: 0.5em;
    color: #9ca3af;
    border-right: 1px solid #e5e7eb;
    user-select: none;
    font-size: 0.8125rem;
}

/* JSON Tree View */
.json-tree {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.json-tree-node {
    margin-left: 1.25rem;
}

.json-tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 1em;
    color: #6b7280;
}

.json-tree-key {
    color: #2563eb;
}

.json-tree-bracket {
    color: #6b7280;
}

.json-tree-count {
    color: #9ca3af;
    font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 640px) {
    .tool-body {
        padding: 1rem;
    }

    .tool-title {
        font-size: 1.25rem;
    }

    .tool-stats {
        gap: 1rem;
    }

    .tool-stat-value {
        font-size: 1.5rem;
    }

    .related-tools-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Dark Mode Overrides ===== */
[data-theme="dark"] .tool-title {
    color: #e2e8f0;
}

[data-theme="dark"] .tool-description {
    color: var(--text-muted);
}

[data-theme="dark"] .tool-body {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .tool-body label {
    color: var(--text-secondary);
}

[data-theme="dark"] .tool-body textarea,
[data-theme="dark"] .tool-body input[type="text"],
[data-theme="dark"] .tool-body input[type="number"],
[data-theme="dark"] .tool-body input[type="url"],
[data-theme="dark"] .tool-body input[type="date"],
[data-theme="dark"] .tool-body select {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .tool-body textarea:focus,
[data-theme="dark"] .tool-body input:focus,
[data-theme="dark"] .tool-body select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .tool-output {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .tool-btn-primary {
    background: #3b82f6;
}

[data-theme="dark"] .tool-btn-primary:hover {
    background: #2563eb;
}

[data-theme="dark"] .tool-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

[data-theme="dark"] .tool-btn-secondary:hover {
    background: #475569;
}

[data-theme="dark"] .tool-btn-copy {
    background: #10b981;
}

[data-theme="dark"] .tool-btn-copy:hover {
    background: #059669;
}

[data-theme="dark"] .tool-btn-copy.copied {
    background: #4b5563;
}

[data-theme="dark"] .tool-stat-value {
    color: #60a5fa;
}

[data-theme="dark"] .tool-stat-label {
    color: var(--text-muted);
}

[data-theme="dark"] .tool-tabs {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .tool-tab {
    color: var(--text-muted);
}

[data-theme="dark"] .tool-tab:hover {
    color: #60a5fa;
}

[data-theme="dark"] .tool-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

[data-theme="dark"] .color-preview {
    border-color: var(--border-color);
}

[data-theme="dark"] .match-highlight {
    background: rgba(250, 204, 21, 0.25);
    color: #fde68a;
}

[data-theme="dark"] .usage-guide h2,
[data-theme="dark"] .related-tools h2,
[data-theme="dark"] .faq-section h2 {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .usage-guide p,
[data-theme="dark"] .usage-guide ol,
[data-theme="dark"] .usage-guide ul {
    color: var(--text-secondary);
}

[data-theme="dark"] .related-tool-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .related-tool-card:hover {
    border-color: #60a5fa;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .related-tool-card h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .related-tool-card p {
    color: var(--text-muted);
}

[data-theme="dark"] .related-tool-link {
    color: #60a5fa;
}

[data-theme="dark"] .faq-list dt {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .faq-list dt::before {
    color: #60a5fa;
}

[data-theme="dark"] .faq-list dt::after {
    color: var(--text-muted);
}

[data-theme="dark"] .faq-list dd {
    color: var(--text-secondary);
}

[data-theme="dark"] .json-key,
[data-theme="dark"] .json-tree-key {
    color: #60a5fa;
}

[data-theme="dark"] .json-string {
    color: #34d399;
}

[data-theme="dark"] .json-number {
    color: #fb923c;
}

[data-theme="dark"] .json-boolean {
    color: #f87171;
}

[data-theme="dark"] .json-null {
    color: #64748b;
}

[data-theme="dark"] .json-line-num {
    color: #475569;
    border-right-color: var(--border-color);
}

[data-theme="dark"] .json-tree-toggle {
    color: var(--text-muted);
}

[data-theme="dark"] .json-tree-bracket {
    color: var(--text-muted);
}

[data-theme="dark"] .json-tree-count {
    color: #64748b;
}

[data-theme="dark"] .tool-options label {
    color: var(--text-secondary);
}
