/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    line-height: 1.6;
    color: #333;
    background: #fff;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 4px;
}

.subtitle {
    text-align: center;
    color: #777;
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 15px;
}

h3 {
    margin-top: 0;
    color: #333;
}

h4 {
    margin: 0 0 8px 0;
    color: #555;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* How to Use Button */
.how-to-use-row {
    text-align: center;
    margin-bottom: 20px;
}

.btn-how-to-use {
    background: transparent;
    color: #888;
    border: none;
    font-size: 12px;
    padding: 2px 8px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.btn-how-to-use:hover {
    color: #555;
    background: transparent;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: #fff;
    border-radius: 8px;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.modal-header h3 {
    margin: 0;
}

.btn-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #777;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-modal-close:hover {
    color: #333;
    background: transparent;
}

.modal-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.7;
}

.modal-body h4 {
    margin-top: 16px;
    text-transform: none;
    font-size: 15px;
    color: #333;
}

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

.modal-body li {
    margin-bottom: 4px;
}

/* JSON Validator */
.validator-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.validator-section h4 {
    text-align: center;
    color: #999;
    font-weight: normal;
    text-transform: none;
    font-size: 13px;
    letter-spacing: 0;
    margin-bottom: 10px;
}

.json-paste {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
}

.json-paste:focus {
    outline: none;
    border-color: #999;
}

.validator-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.validator-actions button {
    flex: 1;
    font-size: 13px;
    padding: 8px 12px;
}

.validator-result {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
}

.validator-result.hidden {
    display: none;
}

.validator-result.valid {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
}

.validator-result.invalid {
    background: #fde8e8;
    border: 1px solid #ef9a9a;
    color: #c62828;
}

/* Container */
.container {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Steps */
.step {
    animation: fadeIn 0.25s ease;
}

.step.hidden {
    display: none;
}

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

/* Drop Area */
.drop-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
}

.drop-area:hover,
.drop-area.highlight {
    background: #e9e9e9;
    border-color: #999;
}

.drop-area p {
    margin: 0;
    font-size: 18px;
    color: #666;
}

.hidden {
    display: none;
}

/* Buttons */
button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #3e8e41;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #777;
}

.btn-secondary:hover {
    background: #555;
}

.btn-add {
    background: transparent;
    color: #4CAF50;
    border: 1px dashed #4CAF50;
    width: 100%;
    margin-bottom: 16px;
    font-size: 14px;
    padding: 8px;
}

.btn-add:hover {
    background: #f0f9f0;
}

.actions {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    gap: 12px;
}

/* JSON Summary */
#json-summary {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 8px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    color: #555;
    font-weight: bold;
}

.summary-value {
    color: #333;
}

.summary-path-list {
    margin-top: 12px;
}

.summary-path {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 6px;
    font-family: monospace;
    font-size: 13px;
}

.summary-path .count {
    background: #4CAF50;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-family: Arial, sans-serif;
}

/* Existing Fields Hint */
.existing-fields-hint {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
}

.existing-fields-hint .hint-label {
    font-weight: bold;
    color: #555;
}

.existing-fields-hint .field-chip {
    display: inline-block;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 2px 8px;
    margin: 2px 4px;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.existing-fields-hint .field-chip:hover {
    background: #4CAF50;
    color: #fff;
    border-color: #4CAF50;
}

/* Field Config */
.field-config-header {
    margin-bottom: 16px;
}

.field-config-header label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: #555;
}

.field-config-header select {
    flex: 1;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    background: #fff;
}

/* Config Sections */
.config-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.config-section-header {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: #333;
    text-transform: none;
    letter-spacing: 0;
}

.config-section-desc {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #777;
}

.btn-add-item-inline {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add-item-inline:hover {
    background: #3e8e41;
}

.new-items-count {
    margin-top: 10px;
    padding: 8px 12px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 4px;
    font-size: 13px;
    color: #1565c0;
}

.new-items-count.hidden {
    display: none;
}

.new-items-list {
    margin-top: 12px;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    background: #f1f8e9;
    max-height: 200px;
    overflow-y: auto;
}

.new-items-list.hidden {
    display: none;
}

.new-item-entry {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #c8e6c9;
    gap: 10px;
}

.new-item-entry:last-child {
    border-bottom: none;
}

.new-item-badge {
    background: #4caf50;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: bold;
}

.new-item-title {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.new-item-preview {
    font-size: 12px;
    color: #666;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-edit-new-item {
    background: transparent;
    border: 1px solid #888;
    color: #555;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit-new-item:hover {
    background: #333;
    border-color: #333;
    color: white;
}

.field-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    flex-wrap: wrap;
}

.field-row input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
}

.field-row select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.field-row .btn-remove {
    background: transparent;
    color: #d32f2f;
    border: none;
    font-size: 20px;
    padding: 4px 8px;
    line-height: 1;
    cursor: pointer;
}

.field-row .btn-remove:hover {
    background: #fde8e8;
    border-radius: 4px;
}

.field-row .edit-existing-tag {
    font-size: 11px;
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.field-options {
    width: 100%;
    margin-top: 6px;
}

.field-options input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    margin-top: 4px;
}

.field-options label {
    font-size: 12px;
    color: #777;
}

/* Classify Layout */
.classify-layout {
    display: flex;
    gap: 16px;
}

.classify-main {
    flex: 1;
    min-width: 0;
}

.classify-sidebar {
    width: 200px;
    flex-shrink: 0;
}

/* Classify Card */
#classify-progress {
    text-align: center;
    margin-bottom: 16px;
    font-size: 14px;
    color: #555;
}

.progress-bar-wrapper {
    background: #e0e0e0;
    border-radius: 10px;
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar-fill {
    background: #4CAF50;
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.classify-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    min-height: 120px;
}

.card-header {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.card-image {
    max-width: 120px;
    max-height: 160px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #e0e0e0;
}

.card-details {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #333;
}

.card-meta {
    font-size: 13px;
    color: #777;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-fields {
    margin-top: 12px;
}

.card-field-group {
    margin-bottom: 14px;
}

.card-field-group label {
    display: block;
    font-weight: bold;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
}

.card-field-group .existing-value-hint {
    font-weight: normal;
    font-size: 12px;
    color: #999;
    margin-left: 8px;
}

.card-field-group input[type="text"],
.card-field-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.card-field-group textarea {
    min-height: 80px;
    resize: vertical;
}

.card-field-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.choice-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.choice-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 16px;
    border: 2px solid #ddd;
    background: #fff;
    color: #333;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.choice-btn:hover {
    border-color: #4CAF50;
    background: #f0f9f0;
    color: #333;
}

.choice-btn.selected {
    border-color: #4CAF50;
    background: #4CAF50;
    color: #fff;
}

.classify-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    gap: 12px;
}

/* History Sidebar */
.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.history-item:hover {
    background: #f0f9f0;
    border-color: #4CAF50;
}

.history-item.active {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.history-item .history-title {
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .history-meta {
    color: #999;
    font-size: 11px;
    margin-top: 2px;
}

.history-item .history-status {
    font-size: 10px;
    margin-top: 2px;
}

.history-item .history-status.modified {
    color: #4CAF50;
}

.history-item .history-status.skipped {
    color: #999;
}

.history-empty {
    font-size: 12px;
    color: #aaa;
    text-align: center;
    padding: 16px 8px;
}

/* Diff */
.diff-wrapper {
    margin-bottom: 20px;
}

#diff-output {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    margin: 0;
}

.diff-line-add {
    color: #4ec84e;
    background: rgba(78, 200, 78, 0.1);
    display: block;
}

.diff-line-remove {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
    display: block;
}

.diff-line-context {
    color: #888;
    display: block;
}

.diff-line-header {
    color: #7cacf8;
    display: block;
    margin-top: 8px;
}

.diff-no-changes {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Results */
#results-summary {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.json-output-wrapper {
    position: relative;
}

#json-output {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    margin: 0 0 8px 0;
}

.output-actions {
    display: flex;
    gap: 8px;
}

.output-actions button {
    flex: 1;
    font-size: 14px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* Footer */
.license-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    font-size: 14px;
    color: #777;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.license-badge {
    display: inline-block;
    background: #555;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    position: relative;
}

.license-badge:hover {
    background: #444;
}

.license-tooltip {
    visibility: hidden;
    width: 300px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    line-height: 1.4;
}

.license-badge:hover .license-tooltip {
    visibility: visible;
    opacity: 1;
}

.attest-badge {
    display: inline-block;
    background: #555;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    transition: background 0.2s;
}

.attest-badge:hover {
    background: #444;
}

.author-info {
    display: inline-block;
}

.author-links {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.author-links a {
    color: #888;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.author-links a:hover {
    color: #555;
}

/* Add New Item */
.classify-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.classify-header #classify-progress {
    flex: 1;
}

.btn-add-item {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-add-item:hover {
    background: #3e8e41;
}

.modal-wide {
    max-width: 700px;
}

.add-item-fields {
    max-height: 60vh;
    overflow-y: auto;
}

.add-item-field-group {
    margin-bottom: 16px;
}

.add-item-field-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
    color: #333;
    font-size: 14px;
}

.add-item-field-group input,
.add-item-field-group textarea,
.add-item-field-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.add-item-field-group input:focus,
.add-item-field-group textarea:focus,
.add-item-field-group select:focus {
    outline: none;
    border-color: #2196F3;
}

.add-item-field-group textarea {
    min-height: 80px;
    resize: vertical;
}

.add-item-field-group .field-type-hint {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.add-item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

/* What's Next Modal */
.whats-next-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.whats-next-actions button {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
}

.btn-primary {
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #444;
}

.add-item-required {
    color: #c62828;
    margin-left: 2px;
}

/* Summary highlights for new items */
.summary-highlight {
    background: #e8f5e9;
    border-radius: 4px;
    padding: 8px 12px !important;
    margin-bottom: 8px;
}

.summary-value-highlight {
    color: #2e7d32;
    font-weight: bold;
}

.summary-sub {
    font-size: 13px;
    color: #666;
}

/* JSON output new item highlight */
.json-new-item {
    background: linear-gradient(90deg, #e8f5e9 0%, #c8e6c9 100%);
    border-left: 3px solid #4caf50;
    display: inline;
    padding: 2px 0;
}

/* Responsive */
@media (max-width: 700px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 16px;
    }

    .classify-layout {
        flex-direction: column-reverse;
    }

    .classify-sidebar {
        width: 100%;
    }

    .history-list {
        max-height: 150px;
    }

    .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .choice-group {
        flex-direction: column;
    }

    .choice-btn {
        min-width: auto;
    }
}
