/* ── PhET Scaling Base ───────────────────────────────────── */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* PhET Stage — scalable container */
#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    overflow: hidden; /* Stage itself should not scroll if children do */
    background: #020617;
    display: flex;
    flex-direction: column;
}

.converter-page {
    background-color: #020617;
    color: #f8fafc;
    overflow: hidden;
    height: 100%;
}

#bgCanvas {
    background: radial-gradient(circle at top right, #0f172a 0%, #020617 100%);
}

.converter-page nav {
    position: relative; /* Contained in stage flow */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 80px;
    flex-shrink: 0;
    padding: 0 5%;
}

.converter-page .nav-center {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

.converter-page .divider {
    color: rgba(255, 255, 255, 0.2);
}

.converter-page .exp-label {
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    flex: 1;
    min-height: 0; /* Important for flex child internal scrolling */
    margin-top: 0;
    gap: 0;
}

aside.controls-panel {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(6, 182, 212, 0.3) transparent;
}

aside.controls-panel::-webkit-scrollbar {
    width: 4px;
}
aside.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}
aside.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(6, 182, 212, 0.25);
    border-radius: 10px;
}

.results-panel {
    padding: 2rem 3rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(6, 182, 212, 0.3) transparent;
}

.results-panel::-webkit-scrollbar {
    width: 4px;
}
.results-panel::-webkit-scrollbar-track {
    background: transparent;
}
.results-panel::-webkit-scrollbar-thumb {
    background: rgba(6, 182, 212, 0.25);
    border-radius: 10px;
}

/* Panel Cards */
.panel-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s, border-color 0.3s;
}

.panel-card:hover {
    border-color: rgba(6, 182, 212, 0.3);
}

.card-header {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-header i {
    color: #06b6d4;
}

/* Input Styles */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

#number-input {
    width: 100%;
    background: #020617;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.25rem;
    color: white;
    font-size: 1.4rem;
    font-family: 'Space Grotesk', monospace;
    outline: none;
    transition: all 0.3s;
    text-align: center;
}

#number-input:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.15);
    background: rgba(6, 182, 212, 0.02);
}

.error-msg {
    color: #f43f5e;
    font-size: 0.8rem;
    margin-top: 0.75rem;
    text-align: center;
    font-weight: 600;
    display: none;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Selectors */
.base-selectors {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.selector-group {
    width: 100%;
}

.selector-group label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 0.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select {
    width: 100%;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    transition: all 0.2s;
}

select:hover {
    border-color: rgba(6, 182, 212, 0.5);
    background-color: #1e293b;
}

.swap-bases {
    align-self: center;
    background: rgba(6, 182, 212, 0.1);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #06b6d4;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(6, 182, 212, 0.2);
    margin: 0.25rem 0;
    z-index: 2;
}

.swap-bases:hover {
    background: #06b6d4;
    color: white;
    transform: rotate(180deg) scale(1.1);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.btn-convert {
    width: 100%;
    padding: 1.15rem;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

.btn-convert:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

.base-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.info-item {
    font-size: 0.8rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border-left: 2px solid #06b6d4;
    transition: 0.2s;
}

.info-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.info-item strong {
    color: #22d3ee;
    margin-right: 0.5rem;
}

/* Result Card */
.result-card {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15));
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 24px;
    padding: 2.5rem;
    text-align: center;
}

.result-label {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 2px;
}

.result-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

#result-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 3.5rem;
    font-weight: 800;
    word-break: break-all;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    min-height: 1.2em;
    display: block;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
}

.copy-btn:hover {
    background: #06b6d4;
    color: white;
    border-color: #06b6d4;
}

/* Process Card */
.process-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.process-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0 2rem;
    display: flex;
}

.tab {
    padding: 1.5rem 0;
    font-weight: 700;
    font-size: 0.9rem;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab.active {
    color: white;
    border-bottom-color: #06b6d4;
}

.process-content {
    padding: 2rem;
    overflow-y: auto;
}

.placeholder {
    text-align: center;
    padding: 4rem 0;
    color: #475569;
}

.placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* Transformation Steps Styling */
.step-item {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #06b6d4;
    animation: slideIn 0.4s ease-out;
}

.step-title {
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.math-row {
    font-family: 'Space Grotesk', monospace;
    font-size: 1.1rem;
    background: #020617;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    color: #22d3ee;
    overflow-x: auto;
}

.math-explanation {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.highlight-math {
    color: #f472b6;
    font-weight: 700;
}

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

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

/* Mobile responsiveness handled by PhET Scaling Engine */