@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Light Mode Palette */
    --bg-light: #f5f7fa;
    --bg-light-accent: #ffffff;
    --bg-light-subtle: #e8ecf1;
    --card-bg: rgba(255, 255, 255, 0.92);

    /* Dark Text for Contrast */
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-accent: #0066cc;

    /* Accent Colors */
    --accent-blue: #0077ff;
    --accent-teal: #00c9a7;
    --accent-gradient: linear-gradient(135deg, #0077ff 0%, #00c9a7 100%);

    /* Borders and Effects */
    --border-color: rgba(0, 0, 0, 0.1);
    --glow-color: rgba(0, 119, 255, 0.2);

    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html,
body {
    height: 100%;
}

body {
    background: linear-gradient(145deg, var(--bg-light) 0%, var(--bg-light-accent) 50%, var(--bg-light-subtle) 100%);
    color: var(--text-primary);
    font-family: var(--font-stack);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding: 20px 0;
}

/* Animated Background Particles/Glow */
.background-glob {
    position: fixed;
    width: 50vmax;
    height: 50vmax;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 119, 255, 0.06), transparent 60%);
    top: -15%;
    left: -15%;
    filter: blur(60px);
    z-index: 0;
    animation: pulse 8s ease-in-out infinite alternate;
    pointer-events: none;
}

.glob-2 {
    top: auto;
    bottom: -15%;
    left: auto;
    right: -15%;
    background: radial-gradient(circle, rgba(0, 201, 167, 0.06), transparent 60%);
    animation-delay: 4s;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    100% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* ======================== */
/* CENTERED MAIN CONTAINER  */
/* ======================== */
.container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1400px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: auto;
}

/* ======================== */
/* GLASSMORPHISM CARD       */
/* ======================== */
.step-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 50px 45px;
    width: 100%;
    text-align: center;
    box-shadow:
        0 4px 30px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Initial hidden state for animation */
    opacity: 0;
    transform: translateY(25px) scale(0.97);
    display: none;
}

.step-card.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ======================== */
/* TYPOGRAPHY               */
/* ======================== */
h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
}

p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ======================== */
/* MULTI-SELECT DROPDOWN    */
/* ======================== */
.input-group {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 2rem auto;
    position: relative;
}

.multi-select-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-toggle {
    width: 100%;
    padding: 16px 50px 16px 20px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.dropdown-toggle:hover {
    border-color: rgba(0, 119, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.95);
}

.dropdown-toggle.open {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--glow-color);
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    color: var(--accent-blue);
}

.dropdown-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 1rem;
    color: var(--text-primary);
    gap: 12px;
}

.dropdown-item:hover {
    background: rgba(0, 119, 255, 0.06);
}

.dropdown-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.selected-count {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--accent-blue);
    font-weight: 500;
}

/* ======================== */
/* GLOWING ACTION BUTTON    */
/* ======================== */
.action-btn {
    background: var(--accent-gradient);
    border: none;
    color: #ffffff;
    padding: 16px 42px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 5px 25px rgba(0, 119, 255, 0.3);
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.action-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 40px rgba(0, 119, 255, 0.4);
}

.action-btn:hover::before {
    left: 100%;
}

.action-btn:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-btn:disabled::before {
    display: none;
}

.secondary-btn {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    padding: 14px 28px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    background: rgba(0, 119, 255, 0.08);
}

/* ======================== */
/* UPLOAD GROUPS - HORIZONTAL */
/* ======================== */
#upload-groups-container {
    width: 100%;
    max-width: 1340px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.upload-group {
    background: rgba(255, 255, 255, 0.85);
    border: 3px solid rgba(0, 80, 180, 0.6);
    border-radius: 16px;
    padding: 20px;
    text-align: left;
    flex: 1 1 calc(33.33% - 10px);
    max-width: 430px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.15),
        0 3px 6px rgba(0, 80, 180, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.9),
        inset 0 -2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.upload-group:hover {
    border-color: rgba(0, 119, 255, 0.7);
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.18),
        0 6px 12px rgba(0, 119, 255, 0.25),
        inset 0 2px 4px rgba(255, 255, 255, 0.95),
        inset 0 -2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
}

.upload-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.upload-group-icon {
    font-size: 1.5rem;
}

.upload-group-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

/* Compact upload boxes - same size whether 1 or 2 */
.upload-box {
    background: rgba(255, 255, 255, 0.8);
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 15px 12px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.35s ease;
    text-align: center;
    flex: 1;
    min-height: 90px;
}

.upload-box:hover {
    border-color: var(--accent-blue);
    background: rgba(0, 119, 255, 0.04);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 119, 255, 0.1);
}

.upload-box input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-box .icon {
    font-size: 1.6rem;
    margin-bottom: 5px;
}

.upload-box h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.upload-box .file-name {
    margin-top: 5px;
    font-size: 0.75rem;
    color: var(--accent-blue);
    font-weight: 500;
    word-break: break-all;
}

/* Image Preview Thumbnail */
.upload-box .image-preview {
    width: 100%;
    max-height: 60px;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 5px;
}

.upload-box.has-image .upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.upload-box.has-image .icon {
    display: none;
}

.upload-box.has-image .file-name {
    display: none;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    width: 100%;
    margin-top: 2rem;
}

/* ======================== */
/* RESULTS DISPLAY          */
/* ======================== */
.results-container {
    margin-top: 40px;
    width: 100%;
}

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 25px;
}

#results-wrapper {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.result-block {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}

.result-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.result-block-icon {
    font-size: 1.4rem;
}

.result-block-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Result content with image on left */
.result-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* ID Images Preview Column */
.result-images {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-image-preview {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    object-fit: contain;
    background: #fff;
}

.result-image-preview:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.result-image-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: -5px;
}

/* Output cards container */
.result-outputs {
    flex: 1;
    display: flex;
    gap: 15px;
    min-width: 0;
}

.output-card {
    flex: 1 1 45%;
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid;
    display: flex;
    flex-direction: column;
    min-width: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    position: relative;
    max-height: 350px;
}

/* Card Headers */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid;
}

.card-label {
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- THEME: JSON Card --- */
.json-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

.json-card .card-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.json-card .card-label {
    color: var(--text-primary);
}

.json-output {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
    overflow-y: auto;
    flex-grow: 1;
    text-align: left;
}

/* JSON Syntax Highlighting - Light Mode */
.json-output .json-key {
    color: #0066cc;
}

.json-output .json-string {
    color: #059669;
}

.json-output .json-number {
    color: #d97706;
}

.json-output .json-boolean {
    color: #db2777;
}

.json-output .json-null {
    color: #64748b;
}

/* --- THEME: Markdown Card --- */
.markdown-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.markdown-card .card-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.markdown-card .card-label {
    color: var(--text-primary);
}

.markdown-output-content {
    font-family: var(--font-stack);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-y: auto;
    flex-grow: 1;
    text-align: left;
}

/* Rendered Markdown Content Styling */
.markdown-output-content h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--accent-gradient);
    border-image: var(--accent-gradient) 1;
    text-align: center;
}

.markdown-output-content h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.6rem;
    margin-bottom: 0.4rem;
}

.markdown-output-content p {
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.markdown-output-content strong {
    font-weight: 700;
    color: var(--text-primary);
}

.markdown-output-content ul {
    margin: 0.3rem 0 0.5rem 1.2rem;
    padding: 0;
    list-style-type: disc;
}

.markdown-output-content li {
    margin-bottom: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.83rem;
}

.markdown-output-content li ul {
    margin-top: 0.2rem;
    margin-left: 1rem;
}

/* --- COPY BUTTONS --- */
.copy-btn {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid;
    border-radius: 5px;
    cursor: pointer;
    background: transparent;
    transition: all 0.2s ease;
    font-weight: 500;
}

.neon-copy {
    color: #60a5fa;
    border-color: #60a5fa;
}

.neon-copy:hover {
    background: rgba(96, 165, 250, 0.15);
}

.bw-copy {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.bw-copy:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ======================== */
/* IMAGE MODAL              */
/* ======================== */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    z-index: 1001;
    max-width: 90%;
    max-height: 90%;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.modal-close:hover {
    transform: scale(1.1);
}

#modal-image {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* ======================== */
/* LOADING SPINNER          */
/* ======================== */
.loader {
    margin-top: 25px;
    text-align: center;
}

.loader p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.loader-progress {
    color: var(--accent-blue) !important;
    font-weight: 500;
}

.spinner {
    width: 45px;
    height: 45px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================== */
/* UTILITY CLASSES          */
/* ======================== */
.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .result-content {
        flex-direction: column;
    }

    .result-images {
        flex: none;
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }

    .result-image-preview {
        max-width: 120px;
    }

    .result-outputs {
        flex-wrap: wrap;
    }

    .output-card {
        flex: 1 1 100%;
    }
}

@media (max-width: 600px) {
    #upload-groups-container {
        flex-direction: column;
    }

    .upload-group {
        max-width: none;
    }

    .step-card {
        padding: 30px 20px;
    }

    h1 {
        font-size: 1.7rem;
    }

    .action-btn {
        padding: 14px 28px;
        font-size: 0.95rem;
    }
}