/* App JSON Generator — PSVitaAlive Store */

.tool-page {
    padding: 48px 0 80px;
}

.tool-hero {
    padding: 36px 0 30px;
    border-bottom: 1px solid var(--border);
}

.tool-hero h1 {
    margin: 10px 0 14px;
    color: #fff;
    font-size: clamp(2.3rem, 5vw, 4rem);
    line-height: 1;
}

.tool-hero p {
    max-width: 850px;
    color: var(--text-secondary);
    font-size: 1.02rem;
}

.tool-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 24px 0 16px;
    align-items: center;
}

.mode-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.35);
}

.mode-switch button {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.mode-switch button.active {
    background: var(--accent);
    color: #0a0a0a;
}

.generator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 28px;
    margin-top: 28px;
    align-items: start;
}

.form-stack {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.form-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(12, 12, 14, 0.92);
    padding: 22px 24px 24px;
    min-width: 0;
    overflow: hidden;
}

.form-card h2 {
    margin: 0 0 6px;
    color: #fff;
    font-size: 1.25rem;
}

.form-card > p,
.section-head p {
    margin: 0 0 16px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.section-head {
    margin-bottom: 8px;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 18px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    display: block;
    margin-bottom: 8px;
    color: #ddd;
    font-size: 0.92rem;
    font-weight: 600;
}

.field input:not([type="checkbox"]),
.field select,
.field textarea,
.repeat-item input:not([type="checkbox"]),
.repeat-item select {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 1.05rem;
    line-height: 1.35;
}

.field textarea {
    min-height: 110px;
    resize: vertical;
    font-size: 1.02rem;
}

.field select[multiple] {
    min-height: 140px;
    padding: 10px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.repeat-item input:not([type="checkbox"]):focus,
.repeat-item select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.repeat-list {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.repeat-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.28);
}

.repeat-item.link-item {
    /* Always stacked like the mobile card — stable on maximized desktop */
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-areas:
        "handle type   name"
        "url    url    url"
        "size   size   size"
        "path   path   path"
        "rec    rec    remove";
    gap: 12px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    padding: 16px;
}

.repeat-item.link-item > * {
    min-width: 0;
    max-width: 100%;
}

.repeat-item.link-item .drag-handle {
    grid-area: handle;
    width: 44px;
    height: 48px;
}

.repeat-item.link-item .link-type {
    grid-area: type;
}

.repeat-item.link-item .link-name {
    grid-area: name;
}

.repeat-item.link-item .url-field {
    grid-area: url;
}

/* Size value + unit (replaces old .link-size) */
.repeat-item.link-item .link-size-field,
.repeat-item.link-item .size-unit-field.link-size-field {
    grid-area: size;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.repeat-item.link-item .link-size-field .link-size-value {
    flex: 1 1 auto;
    min-width: 8rem;
    width: auto;
}
.repeat-item.link-item .link-size-field .link-size-unit {
    flex: 0 0 5.5rem;
    width: 5.5rem;
    min-width: 5.5rem;
}

.repeat-item.link-item .link-extract-wrap {
    grid-area: path;
    min-width: 0;
    width: 100%;
}
.repeat-item.link-item .link-extract-wrap[hidden],
.repeat-item.link-item .link-extract-wrap[style*="display: none"] {
    display: none !important;
}
.repeat-item.link-item .link-extract-path {
    min-width: 0;
    width: 100%;
}

.repeat-item.link-item > .checkbox-inline {
    grid-area: rec;
    justify-self: start;
    align-self: center;
    z-index: 1;
    position: relative;
}

.repeat-item .remove-button {
    border: 1px solid rgba(255, 92, 92, 0.55);
    background: rgba(255, 60, 60, 0.12);
    color: #ff9a9a;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    min-height: 44px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.repeat-item .remove-button:hover {
    background: rgba(255, 60, 60, 0.28);
    border-color: #ff5c5c;
    color: #fff;
}

.repeat-item .remove-button:focus {
    outline: 2px solid #ff5c5c;
    outline-offset: 2px;
}

.repeat-item.link-item .remove-button {
    grid-area: remove;
    justify-self: end;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    cursor: grab;
    user-select: none;
    font-size: 1.1rem;
    letter-spacing: -1px;
}

.drag-handle:active {
    cursor: grabbing;
}

.repeat-item.link-item.dragging {
    opacity: 0.55;
    border-color: var(--accent);
}

.repeat-item.link-item.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #d0d0d0;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    padding: 6px 4px;
    border: none;
    background: transparent;
    border-radius: 0;
}

.checkbox-inline:hover {
    color: #fff;
}

.checkbox-inline:has(input:checked) {
    color: #b8ff9a;
}

/* Clean custom checkbox — no glow / double outline */
.checkbox-inline input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: 2px solid #6a6a6a;
    border-radius: 4px;
    background: #1a1a1a;
    display: inline-block;
    vertical-align: middle;
    cursor: pointer;
    flex: 0 0 18px;
    position: relative;
    outline: none;
    box-shadow: none;
}

.checkbox-inline input[type="checkbox"]:hover {
    border-color: #9a9a9a;
}

.checkbox-inline input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 255, 0, 0.25);
}

.checkbox-inline input[type="checkbox"]:checked {
    border-color: #3bff00;
    background: #3bff00;
}

.checkbox-inline input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #111;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.small-button,
.button {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    padding: 11px 16px;
    font-size: 0.98rem;
    font-weight: 700;
    cursor: pointer;
}

.small-button:hover,
.button:hover {
    border-color: var(--accent);
}

.primary-button {
    background: var(--accent);
    color: #0a0a0a;
    border-color: var(--accent);
}

.primary-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.secondary-button {
    background: transparent;
}

.file-button {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
}

.file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.notice {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.notice.ok {
    border-color: var(--accent);
    color: var(--accent);
}

.notice.error {
    border-color: #ff5c5c;
    color: #ff8c8c;
}

.notice.info {
    border-color: #5c9dff;
    color: #9ec1ff;
}

.validation-summary {
    margin-top: 8px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.validation-summary.ok {
    border-color: var(--accent);
    color: var(--accent);
}

.validation-summary.error {
    border-color: #ff5c5c;
    color: #ff9a9a;
}

.validation-summary ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.download-row {
    margin-top: 8px;
}

.advanced-card summary {
    cursor: pointer;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.advanced-grid {
    margin-top: 16px;
}

.preview-panel {
    position: sticky;
    top: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(10, 10, 12, 0.95);
    overflow: hidden;
}

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

.preview-header h2 {
    margin: 4px 0 0;
    color: #fff;
    font-size: 1.15rem;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.preview-panel pre {
    margin: 0;
    padding: 18px;
    max-height: 760px;
    overflow: auto;
    color: #d8d8d8;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-help {
    border-top: 1px solid var(--border);
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.preview-help strong {
    color: #fff;
}

.preview-help p {
    margin: 6px 0 0;
}

.hero-label {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.14em;
}

.active {
    color: var(--accent) !important;
}

@media (min-width: 1100px) {
    .field input:not([type="checkbox"]),
    .field select,
    .field textarea,
    .repeat-item input:not([type="checkbox"]),
    .repeat-item select {
        font-size: 1.1rem;
        min-height: 52px;
        padding: 14px 16px;
    }
}



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

    .preview-panel {
        position: static;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .tool-page {
        padding-top: 25px;
    }

    .form-card {
        padding: 18px;
    }


    .preview-panel pre {
        max-height: 500px;
    }

    .main-nav {
        gap: 12px;
        flex-wrap: wrap;
    }

    .header-inner {
        gap: 14px;
    }

    .site-logo img {
        max-width: 170px;
        height: 36px;
    }
}

#requirements {
    min-height: 120px;
    font-family: inherit;
    white-space: pre-wrap;
}

@media (max-width: 520px) {
    .repeat-item.link-item {
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-areas:
            "handle type"
            "name   name"
            "url    url"
            "size   size"
            "path   path"
            "rec    remove";
    }
}


/* Category + subcategory picker */
.category-block .category-select {
    font-size: 1.08rem;
    font-weight: 600;
    min-height: 52px;
    border-radius: 12px;
    border-color: #333;
    background: rgba(0, 0, 0, 0.5);
}

.category-block .category-select:focus {
    border-color: rgba(59, 255, 0, 0.55);
}

.subcategory-block label {
    margin-bottom: 10px;
}

.subcategory-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 52px;
    padding: 12px;
    border: 1px solid #2e2e2e;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
}

.subcategory-chip {
    appearance: none;
    border: 1px solid #3a3a3a;
    background: rgba(255, 255, 255, 0.05);
    color: #d8d8d8;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.subcategory-chip:hover {
    border-color: rgba(59, 255, 0, 0.4);
    color: #fff;
    background: rgba(59, 255, 0, 0.08);
}

.subcategory-chip.is-selected {
    border-color: rgba(59, 255, 0, 0.65);
    background: rgba(59, 255, 0, 0.18);
    color: #c8ffb0;
    box-shadow: 0 0 0 1px rgba(59, 255, 0, 0.15);
}

.subcategory-chip:active {
    transform: scale(0.97);
}

.subcategory-empty {
    color: #888;
    font-size: 0.92rem;
    padding: 6px 4px;
}

.subcategory-help {
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
}


.repeat-item.screenshot-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}


/* Size value + unit selector (app form; link rows use grid-area rules above) */
.size-unit-field {
    display: flex;
    gap: 10px;
    align-items: stretch;
    min-width: 0;
    width: 100%;
}
.size-unit-field input {
    flex: 1 1 auto;
    min-width: 6rem;
}
.size-unit-field select {
    flex: 0 0 5.5rem;
    width: 5.5rem;
    min-width: 5.5rem;
}


/* Create mode: Internal ID locked (auto from name) */
#id.id-locked,
input.id-locked {
    opacity: 0.85;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary, #aaa);
}

.field-help-box {
    margin: 0 0 14px;
}
.field-help-box ul {
    margin: 8px 0 0 1.1rem;
    padding: 0;
}
.field-help-box li {
    margin: 4px 0;
}
