/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Edit Section */
.edit-section {
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    padding: 2rem;
    transition: all 0.3s ease;
}

.edit-section.hidden {
    display: none;
}

.edit-container {
    max-width: 1200px;
    margin: 0 auto;
}

.edit-container .title-with-docs {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.edit-container h1 {
    font-size: 1.75rem;
    margin-bottom: 0;
    color: #2c3e50;
}

.edit-container .docs-link {
    font-size: 0.85rem;
    color: #4a90e2;
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.edit-container .docs-link:hover {
    background-color: #e8f4ff;
    text-decoration: underline;
}

/* JSON Editor */
.json-editor {
    margin-bottom: 1.5rem;
}

.json-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.json-editor-label-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.json-editor label {
    font-weight: 600;
    color: #555;
    margin: 0;
}

/* URL Loader Styles */
.url-loader-trigger {
    font-size: 0.85rem;
    color: #4a90e2;
    cursor: pointer;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.url-loader-trigger:hover {
    background-color: #e8f4ff;
    text-decoration: underline;
}

.url-loader-trigger.hidden {
    display: none;
}

.url-loader-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.2s ease;
}

.url-loader-input-group.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

.url-input {
    padding: 0.35rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 250px;
    transition: border-color 0.2s ease;
}

.url-input:focus {
    outline: none;
    border-color: #4a90e2;
}

.url-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.url-confirm-btn {
    background-color: #5cb85c;
    color: white;
}

.url-confirm-btn:hover {
    background-color: #4cae4c;
    transform: scale(1.05);
}

.url-cancel-btn {
    background-color: #dc3545;
    color: white;
}

.url-cancel-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

.url-action-btn:active {
    transform: scale(0.95);
}

.example-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.examples-label {
    font-size: 0.9rem;
    color: #777;
}

.example-link {
    font-size: 0.9rem;
    color: #4a90e2;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.example-link:hover {
    background-color: #e8f4ff;
    text-decoration: underline;
}

.json-textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    background-color: #fafafa;
    transition: border-color 0.3s ease;
}

.json-textarea:focus {
    outline: none;
    border-color: #4a90e2;
    background-color: #fff;
}

/* URL Info Box */
.url-info-box {
    background-color: #e8f4ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

.url-info-box.hidden {
    display: none;
}

.url-info-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.url-info-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.url-info-text {
    color: #2c5282;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-all;
}

.url-info-text strong {
    color: #1a365d;
    font-weight: 600;
}

.url-unload-btn {
    background-color: #4a90e2;
    color: white;
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    margin-left: 1rem;
}

.url-unload-btn:hover {
    background-color: #357abd;
    text-decoration: none;
}


/* Error Box */
.error-box {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    animation: slideDown 0.3s ease;
}

.error-box.hidden {
    display: none;
}

.error-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}

.error-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.error-message {
    color: #c33;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}

.close-error {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #c33;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.close-error:hover {
    color: #a11;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Buttons */
.button-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #4a90e2;
    color: white;
}

.btn-primary:hover {
    background-color: #357abd;
}

.btn-secondary {
    background-color: #5cb85c;
    color: white;
}

.btn-secondary:hover {
    background-color: #4cae4c;
}

.btn:active {
    transform: translateY(1px);
}

/* Toggle Button (Cog Wheel) */
.toggle-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background-color: #4a90e2;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background-color: #357abd;
    transform: scale(1.05);
}

.toggle-btn.hidden {
    display: none;
}

/* Checklist Section */
.checklist-section {
    padding: 2rem;
    min-height: 50vh;
}

.checklist-container {
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.checklist-container:empty {
    display: none;
}

/* Multi-column layout */
.checklist-elements {
    column-gap: 2rem;
    column-rule: 1px solid #ddd;
}


/* Page break handling */
.checklist-page.page-break-before {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 2px dashed #999;
}

/* Prevent elements from breaking across columns */
.checklist-element {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Checklist Elements */
.checklist-title {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 700;
}

.checklist-element {
    padding: 1rem;
    background-color: #fafafa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.checklist-element pre {
    margin: 0;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Sequence with title gets top margin for visual separation */
.checklist-element-sequence:has(.sequence-title) {
    margin-top: 1.5rem;
}

.checklist-element-sequence:has(.sequence-title):first-child {
    margin-top: 0;
}

/* Sequence Elements */
.sequence-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.sequence-step {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    margin-bottom: 0.25rem;
    font-family: monospace;
    font-size: 0.95rem;
}

.step-item {
    flex-shrink: 0;
    padding-right: 0.5rem;
}

.step-dots {
    flex-grow: 1;
    border-bottom: 2px dotted #999;
    margin: 0 0.25rem;
    min-width: 2rem;
    height: 0.8em;
}

.step-state {
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 0.5rem;
    font-weight: 600;
}

.sequence-step-text {
    margin-bottom: 0.25rem;
    font-family: monospace;
    font-size: 0.95rem;
}

/* Text Elements */
.checklist-element-text {
    background: none;
    border: none;
    padding: 0.5rem 0;
}

.text-content {
    font-style: italic;
    color: #555;
    line-height: 1.5;
    white-space: pre-wrap;
}

.checklist-placeholder {
    padding: 2rem;
    text-align: center;
    color: #666;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 2px dashed #ddd;
}

.checklist-placeholder p {
    margin: 0.5rem 0;
}

/* Checklist Footer */
.checklist-footer {
    margin-top: 0.75rem;
    padding-top: 0;
    text-align: center;
    font-size: 0.75rem;
    font-style: italic;
    color: #999;
}

.checklist-footer a {
    color: #999;
    text-decoration: none;
}

.checklist-footer a:hover {
    color: #666;
    text-decoration: underline;
}

/* Print Styles */
@media print {

    /* Force browsers to print background colors and images */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    .toggle-btn,
    .interactive-nav {
        display: none !important;
    }

    .checklist-section {
        padding: 0;
    }

    .checklist-container {
        box-shadow: none;
        padding: 0;
    }

    body {
        background-color: white;
    }

    /* Force page break before pages with page-break-before class */
    .checklist-page.page-break-before {
        page-break-before: always;
        break-before: page;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .edit-section {
        padding: 1rem;
    }

    .checklist-section {
        padding: 1rem;
    }

    .button-container {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .edit-container .title-with-docs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .edit-container h1 {
        font-size: 1.5rem;
    }

    .json-editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .url-input {
        min-width: 200px;
        max-width: 100%;
        flex: 1;
    }

    .url-loader-input-group {
        width: 100%;
    }

    .url-info-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .url-unload-btn {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}

/* Interactive Mode Styles */
.sequence-step {
    transition: opacity 0.3s ease, background-color 0.2s ease;
}

.sequence-step:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.sequence-step-text {
    transition: opacity 0.3s ease, background-color 0.2s ease;
}

.sequence-step-text:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.text-content {
    transition: opacity 0.3s ease, background-color 0.2s ease;
}

.text-content:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Interactive Navigation Controls */
.interactive-nav {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 999;
}

.interactive-nav.hidden {
    display: none;
}

.nav-btn {
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-btn-icon {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    background-color: #6c757d;
    color: white;
    overflow: hidden;
    opacity: 0.6;
}

.nav-btn-icon:hover {
    background-color: #5a6268;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.nav-btn-icon:active {
    transform: scale(0.95);
}

.nav-btn-primary {
    width: 64px;
    height: 64px;
    background-color: #4a90e2;
    color: white;
}

.nav-btn-primary:hover {
    background-color: #357abd;
}

.nav-btn-reset {
    background-color: #dc3545;
    color: white;
}

.nav-btn-reset:hover {
    background-color: #c82333;
}

.nav-btn svg {
    display: block;
}




/* Checklist Mode Toggle - Modern Segmented Control */
.layout-mode-toggle {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.layout-mode-toggle .mode-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
}

.segmented-control {
    display: inline-flex;
    background-color: #e9ecef;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control .segment-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    background-color: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.segmented-control .segment-label svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.segmented-control .segment-label:hover {
    color: #333;
}

.segmented-control .segment-label:hover svg {
    opacity: 1;
}

.segmented-control input[type="radio"]:checked+.segment-label {
    background-color: white;
    color: #4a90e2;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.segmented-control input[type="radio"]:checked+.segment-label svg {
    opacity: 1;
    stroke: #4a90e2;
}

/* Gamepad Helper Styles */
.gamepad-helper-toggle {
    margin-top: 1.5rem;
}

.btn-gamepad-helper {
    padding: 0.5rem 1rem;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-gamepad-helper:hover {
    background-color: #5a6268;
}

.gamepad-helper {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.gamepad-helper.hidden {
    display: none;
}

.gamepad-helper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #dee2e6;
}

.gamepad-helper-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2c3e50;
}

.close-gamepad-helper {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.close-gamepad-helper:hover {
    color: #495057;
}

.gamepad-device {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.gamepad-device h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    color: #495057;
}

/* Compact button display */
.gamepad-buttons-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.button-compact {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #495057;
    transition: background-color 0.1s ease;
}

.button-compact.pressed {
    background-color: #28a745;
    color: white;
}

/* JSON config display */
.gamepad-config {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 3px;
    border: 1px solid #dee2e6;
    font-size: 0.85rem;
}

.gamepad-config strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #495057;
}

.gamepad-config code {
    display: block;
    padding: 0.25rem 0.5rem;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #d63384;
    user-select: all;
    flex: 1;
}

.copy-config-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.copy-config-btn:hover {
    background-color: #5a6268;
    transform: scale(1.05);
}

.copy-config-btn:active {
    transform: scale(0.95);
}

.gamepad-helper-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background-color: #e8f4ff;
    border-left: 3px solid #4a90e2;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
}

.gamepad-helper-info .info-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    color: #4a90e2;
}

.gamepad-helper-info a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: 600;
}

.gamepad-helper-info a:hover {
    text-decoration: underline;
}

.button-group-left {
    display: flex;
    gap: 1rem;
}

/* Current Item Highlight - 3D Raised Effect */
.current-item {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 -1px 0 rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

/* Add subtle animation to draw attention */
@keyframes pulse-subtle {

    0%,
    100% {
        transform: translateY(-2px);
    }

    50% {
        transform: translateY(-3px);
    }
}

.current-item {
    animation: pulse-subtle 2s ease-in-out infinite;
}