/* Defining modern fonts with a retro new wave touch */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Space+Mono:wght@400;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main"
        "nav nav";
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(236, 72, 153, 0.1), rgba(59, 130, 246, 0.1));
    pointer-events: none;
    z-index: -1;
}

body.light-theme {
    background-color: #f8fafc;
    color: #1e293b;
}

body.light-theme::before {
    background: linear-gradient(45deg, rgba(59, 130, 246, 0.1), rgba(236, 72, 153, 0.1));
}

#app-header {
    grid-area: header;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(236, 72, 153, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #0f172a, #1e293b);
}

.light-theme #app-header {
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    background: linear-gradient(to right, #f8fafc, #e2e8f0);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.app-title {
    margin: 0;
    font-family: 'Space Mono', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.05rem;
    background: linear-gradient(to right, #ec4899, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light-theme .app-title {
    background: linear-gradient(to right, #3b82f6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subheading {
    margin: 0.3rem 0 0;
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -0.02rem;
    background: linear-gradient(to right, #ec4899, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light-theme .app-subheading {
    background: linear-gradient(to right, #3b82f6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#theme-toggle-btn {
    background: transparent;
    border: none;
    color: #ec4899;
    font-size: 1.3rem;
    cursor: pointer;
    transition: color 0.3s;
}

.light-theme #theme-toggle-btn {
    color: #3b82f6;
}

#theme-toggle-btn:hover {
    color: #db2777;
}

.light-theme #theme-toggle-btn:hover {
    color: #2563eb;
}

#sidebar {
    grid-area: sidebar;
    padding: 1.5rem;
    border-right: 1px solid rgba(236, 72, 153, 0.2);
    background: #1e293b;
    height: 100%;
    overflow-y: auto;
}

.light-theme #sidebar {
    background: #e2e8f0;
    border-right: 1px solid rgba(59, 130, 246, 0.2);
}

.metric {
    margin-bottom: 1.5rem;
}

.metric label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: block;
}

.progress-container {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(to right, #ec4899, #3b82f6);
    height: 100%;
    width: 0;
    transition: width 0.3s ease-in-out;
}

.light-theme .progress-container {
    background: rgba(0, 0, 0, 0.1);
}

.light-theme .progress-bar {
    background: linear-gradient(to right, #3b82f6, #ec4899);
}

#congruence-matrix div {
    padding: 0.5rem;
    margin: 0.3rem 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.light-theme #congruence-matrix div {
    background: rgba(0, 0, 0, 0.05);
}

#congruence-matrix div.complete {
    background: linear-gradient(to right, #ec4899, #3b82f6);
}

.light-theme #congruence-matrix div.complete {
    background: linear-gradient(to right, #3b82f6, #ec4899);
}

main {
    grid-area: main;
    padding: 2rem;
    overflow-y: auto;
}

.wizard-screen, .blueprint-screen {
    display: none;
}

.wizard-screen.active, .blueprint-screen.active {
    display: block;
}

h2 {
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #ec4899, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light-theme h2 {
    background: linear-gradient(to right, #3b82f6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card, .toggle-button {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s, transform 0.3s, border-color 0.3s;
}

.light-theme .card, .light-theme .toggle-button {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.card:hover, .toggle-button:hover {
    transform: translateY(-3px);
    border-color: #ec4899;
}

.light-theme .card:hover, .light-theme .toggle-button:hover {
    border-color: #3b82f6;
}

.card.selected, .toggle-button.selected {
    background: linear-gradient(to right, #ec4899, #3b82f6);
    border-color: #ec4899;
}

.light-theme .card.selected, .light-theme .toggle-button.selected {
    background: linear-gradient(to right, #3b82f6, #ec4899);
    border-color: #3b82f6;
}

.tag {
    display: inline-block;
    background: linear-gradient(to right, #ec4899, #3b82f6);
    color: #ffffff;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    margin: 0.3rem;
    font-size: 0.85rem;
}

.light-theme .tag {
    background: linear-gradient(to right, #3b82f6, #ec4899);
}

.image-placeholder, .video-placeholder {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    margin-top: 1rem;
}

.light-theme .image-placeholder, .light-theme .video-placeholder {
    background: rgba(0, 0, 0, 0.1);
}

#wizard-nav {
    grid-area: nav;
    padding: 1rem;
    border-top: 1px solid rgba(236, 72, 153, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
}

.light-theme #wizard-nav {
    background: #e2e8f0;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

#step-indicator {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-link {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: #ec4899;
    text-decoration: none;
    transition: color 0.3s;
}

.light-theme .footer-link {
    color: #3b82f6;
}

.footer-link:hover {
    color: #db2777;
}

.light-theme .footer-link:hover {
    color: #2563eb;
}

.hidden {
    display: none;
}

input, textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s, box-shadow 0.3s;
}

textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
}

input:focus, textarea:focus {
    border-color: #ec4899;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.5);
    outline: none;
}

.light-theme input, .light-theme textarea {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.light-theme input:focus, .light-theme textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

button {
    background: linear-gradient(to right, #ec4899, #3b82f6);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.3s, box-shadow 0.3s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.5);
}

.light-theme button {
    background: linear-gradient(to right, #3b82f6, #ec4899);
}

.light-theme button:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

#simulation-results div, #adaptation-engine-output div, #competitor-analysis-output, #voice-query-output p, #passage-recommender-output p, #image-alignment-output, #video-alignment-output, #urgency-output {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 0 5px rgba(236, 72, 153, 0.2);
}

.light-theme #simulation-results div, .light-theme #adaptation-engine-output div, .light-theme #competitor-analysis-output, .light-theme #voice-query-output p, .light-theme #passage-recommender-output p, .light-theme #image-alignment-output, .light-theme #video-alignment-output, .light-theme #urgency-output {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.2);
}

.blueprint-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

#query-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.query-input {
    margin-bottom: 0.5rem;
}

/* Responsive Design */

/* Tablets */
@media (max-width: 1024px) {
    body {
        grid-template-columns: 220px 1fr; /* narrower sidebar */
    }
    #sidebar {
        padding: 1rem;
    }
    main {
        padding: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    body {
        grid-template-areas:
            "header"
            "main"
            "sidebar"
            "nav";
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto;
    }

    #sidebar {
        border-right: none;
        border-top: 1px solid rgba(236, 72, 153, 0.2);
        background: #1e293b;
        padding: 1rem;
        order: 3;
    }
    .light-theme #sidebar {
        border-top: 1px solid rgba(59, 130, 246, 0.2);
    }

    #wizard-nav {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    /* --- BUG FIX --- */
    /* Reorder navigation buttons for a more logical mobile layout */
    #wizard-nav #next-btn {
        order: -2; /* Display first */
    }

    #wizard-nav #step-indicator {
        order: -1; /* Display second */
    }
    
    /* The #back-btn and other elements will have the default order of 0, */
    /* so they will appear after the reordered items. */


    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .card-container {
        grid-template-columns: 1fr; /* stack cards */
    }

    input, textarea, button {
        font-size: 1rem;
    }
}
