/* =============================================
   UXshagan Labs - Chemistry Lab UI
   Clean, professional lab interface
   ============================================= */

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #ffffff;
    --bg-dark: #1a2332;
    --panel-bg: rgba(20, 30, 48, 0.92);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text: #f0f4ff;
    --text-dim: #8892a8;
    --cyan: #00bcd4;
    --pink: #e91e90;
    --red: #ef4444;
    --blue: #3b82f6;
    --green: #22c55e;
    --orange: #f97316;
    --purple: #a855f7;
    --font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: "JetBrains Mono", monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --transition: 0.25s ease;
}

html,
body {
    width: 100%;
    min-height: 100%;
    overflow: auto;
    font-family: var(--font);
    background: var(--bg);
    user-select: none;
    -webkit-user-select: none;
}

/* --- Canvas --- */
#labCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

/* --- Close Button --- */
.close-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #f0f4ff;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* --- Info Panel (Contents / Reactions) --- */
.info-panel {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 320px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.info-tabs {
    display: flex;
    border-bottom: 1px solid var(--panel-border);
}

.info-tab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.info-tab.active {
    color: var(--pink);
}

.info-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--pink);
    border-radius: 2px 2px 0 0;
}

.info-tab:hover:not(.active) {
    color: var(--text);
}

.info-body {
    padding: 12px;
    max-height: 240px;
    overflow-y: auto;
}

/* Scrollbar */
.info-body::-webkit-scrollbar {
    width: 4px;
}

.info-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Contents Table */
.contents-table {
    width: 100%;
    border-collapse: collapse;
}

.contents-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pink);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--panel-border);
}

.contents-table td {
    padding: 8px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.contents-table td:first-child {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 12px;
}

.contents-table td:nth-child(2) {
    color: var(--cyan);
    font-family: var(--mono);
    font-weight: 600;
    font-size: 12px;
}

.contents-table td:nth-child(3) {
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
}

.contents-table .subscript {
    font-size: 0.75em;
    vertical-align: sub;
}

.reactions-list {
    padding: 8px;
}

.reactions-list.hidden,
.contents-table.hidden {
    display: none;
}

.reaction-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    border-left: 3px solid var(--pink);
}

.empty-text {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 20px 0;
}

/* --- Side Controls --- */
.side-controls {
    position: fixed;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.left-controls {
    left: 16px;
    bottom: 120px;
}

.right-controls {
    right: 16px;
    bottom: 120px;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-pill);
    padding: 8px;
    border: 1px solid var(--panel-border);
}

.ctrl-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--red);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.ctrl-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.ctrl-btn:active {
    transform: scale(0.9);
}

.ctrl-value {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 28px;
    text-align: center;
}

/* Thermometer */
.thermometer {
    width: 14px;
    height: 60px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.thermo-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20%;
    background: linear-gradient(to top, var(--red), var(--orange));
    border-radius: 0 0 6px 6px;
    transition: height 0.4s ease;
}

/* pH Meter */
.ph-meter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 10px 8px;
    border: 1px solid var(--panel-border);
}

.ph-strip {
    width: 14px;
    height: 120px;
    border-radius: 7px;
    background: linear-gradient(
        to bottom,
        #ef4444 0%,
        #f97316 14%,
        #eab308 28%,
        #22c55e 42%,
        #06b6d4 57%,
        #3b82f6 71%,
        #8b5cf6 85%,
        #7c3aed 100%
    );
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ph-indicator {
    position: absolute;
    left: -4px;
    right: -4px;
    height: 4px;
    background: white;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
    transition: top 0.4s ease;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

.ph-value {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}

/* Stir Button */
.stir-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.stir-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.stir-btn:active {
    transform: scale(0.9);
}

.stir-btn.stirring {
    animation: stir-pulse 0.5s ease infinite;
    border-color: var(--cyan);
    color: var(--cyan);
}

@keyframes stir-pulse {
    0%,
    100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(5deg);
    }
    75% {
        transform: rotate(-5deg);
    }
}

/* --- Chemical Bar (Bottom) --- */
.chemical-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-dark);
    border-top: 1px solid var(--panel-border);
    max-height: 40vh;
    overflow-y: auto;
}

.category-tabs {
    display: flex;
    padding: 0 12px;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    border-bottom: 1px solid var(--panel-border);
    padding-top: 10px;
    padding-bottom: 8px;
}

.category-tabs::-webkit-scrollbar {
    height: 6px;
}

.category-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.category-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.category-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cat-tab {
    flex-shrink: 0;
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    color: var(--text-dim);
}

.cat-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.cat-tab[data-category="water"] {
    color: var(--cyan);
}
.cat-tab[data-category="acids"] {
    color: var(--pink);
}
.cat-tab[data-category="bases"] {
    color: var(--blue);
}
.cat-tab[data-category="salts"].active,
.cat-tab[data-category="metals"].active {
    color: var(--text);
}

.cat-tab[data-category="water"].active {
    color: var(--cyan);
    background: rgba(0, 188, 212, 0.12);
}
.cat-tab[data-category="acids"].active {
    color: var(--pink);
    background: rgba(233, 30, 144, 0.12);
}
.cat-tab[data-category="bases"].active {
    color: var(--blue);
    background: rgba(59, 130, 246, 0.12);
}

.chemical-list {
    display: flex;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chemical-list::-webkit-scrollbar {
    height: 6px;
}

.chemical-list::-webkit-scrollbar-track {
    background: transparent;
}

.chemical-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chemical-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chem-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    min-width: 100px;
}

.chem-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.chem-item:active {
    transform: translateY(0) scale(0.97);
}

.chem-item.selected {
    border-color: var(--cyan);
    background: rgba(0, 188, 212, 0.1);
}

.chem-formula {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.chem-name {
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
}

.chem-tag {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    border: 1px solid;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.chem-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

/* --- Notifications --- */
.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 200;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 16px 24px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
    text-align: center;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.notification.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* --- Pour Animation Overlay --- */
.pour-stream {
    position: fixed;
    top: 0;
    left: 50%;
    width: 4px;
    height: 0;
    transform: translateX(-50%);
    z-index: 50;
    border-radius: 0 0 4px 4px;
    pointer-events: none;
    transition:
        height 0.3s ease,
        opacity 0.3s ease;
    opacity: 0;
}

.pour-stream.active {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .info-panel {
        width: calc(100% - 80px);
        max-width: 300px;
        top: 12px;
        left: 12px;
    }

    .left-controls {
        left: 8px;
        bottom: 110px;
    }

    .right-controls {
        right: 8px;
        bottom: 110px;
    }

    .chemical-list {
        padding: 8px;
        gap: 6px;
    }

    .chem-item {
        min-width: 70px;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .info-panel {
        width: calc(100% - 32px);
        max-width: none;
        left: 16px;
        right: 16px;
    }
}
