/* ========================================
   package.json Generator — Purple Haze Theme
   ======================================== */

:root {
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --secondary: #A78BFA;
    --accent: #EC4899;
    --bg: #0F0A2A;
    --bg-surface: #16103A;
    --bg-elevated: #1E1648;
    --bg-input: #130E30;
    --border: #2D2560;
    --border-focus: #8B5CF6;
    --text: #E8E0F5;
    --text-muted: #8B7EAA;
    --text-dim: #5E5280;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --success: #10B981;
    --error: #EF4444;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.05rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--primary);
}

.btn-primary-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-color: transparent;
}

.btn-primary-header:hover {
    filter: brightness(1.1);
    color: #fff;
}

/* Main */
.app-main {
    display: grid;
    grid-template-columns: 1fr 400px;
    flex: 1;
    min-height: 0;
}

/* Form Panel */
.form-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.form-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text);
}

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

.tab-panels {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.required {
    color: var(--accent);
}

.optional {
    font-weight: 400;
    font-style: italic;
    color: var(--text-dim);
}

.section-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--mono);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--border-focus);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-dim);
}

.form-group textarea {
    font-family: var(--font);
    resize: vertical;
    min-height: 60px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Script templates */
.quick-scripts {
    margin-bottom: 16px;
}

.script-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.script-tmpl-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--secondary);
    padding: 5px 12px;
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.script-tmpl-btn:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

/* KV Editor */
.kv-header {
    display: grid;
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.kv-header span {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.kv-row {
    display: grid;
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px;
    margin-bottom: 5px;
    animation: fadeIn 0.15s ease;
}

.kv-row.single {
    grid-template-columns: 1fr 36px;
}

.kv-row input {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 7px 10px;
    font-family: var(--mono);
    font-size: 0.82rem;
    outline: none;
    transition: border-color var(--transition);
}

.kv-row input:focus {
    border-color: var(--border-focus);
}

.kv-row input::placeholder {
    color: var(--text-dim);
}

.btn-remove-row {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    width: 36px;
    height: 34px;
}

.btn-remove-row:hover {
    color: var(--error);
    border-color: var(--error);
}

.btn-add-row {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 7px;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
    transition: all var(--transition);
}

.btn-add-row:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Dep Search */
.dep-search {
    margin-bottom: 20px;
}

.dep-search label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.search-row {
    display: flex;
    gap: 8px;
}

.search-row input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--mono);
    font-size: 0.85rem;
    outline: none;
}

.search-row input:focus {
    border-color: var(--border-focus);
}

.search-row select {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font);
    font-size: 0.82rem;
    appearance: none;
    cursor: pointer;
    outline: none;
    min-width: 140px;
}

.search-results {
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.search-result-item:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.search-result-name {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 500;
}

.search-result-ver {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.search-result-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dep List */
.dep-section {
    margin-bottom: 16px;
}

.dep-section h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dep-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--secondary);
    font-size: 0.7rem;
    padding: 1px 7px;
    border-radius: 10px;
}

.dep-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dep-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}

.dep-item-name {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--text);
}

.dep-item-version {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.dep-item-remove {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1rem;
    transition: color var(--transition);
}

.dep-item-remove:hover {
    color: var(--error);
}

/* Preview Panel */
.preview-panel {
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.preview-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: var(--radius-xs);
    font-size: 0.78rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.json-output {
    flex: 1;
    overflow: auto;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--secondary);
    white-space: pre;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.code-textarea {
    width: 100%;
    min-height: 260px;
    background: var(--bg-input);
    color: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

.code-textarea:focus {
    border-color: var(--border-focus);
}

.muted-text {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: center;
    padding: 16px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    max-width: 300px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 350px;
    }
}

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

    .search-row {
        flex-direction: column;
    }

    .search-row select {
        min-width: unset;
    }
}