:root {
    --bg-color: #f8f9fa;
    --panel-bg: #ffffff;
    --border-color: #e0e0e0;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --accent-color: #0d2c54;
    /* Navy Blue */
    --accent-hover: #0a2342;
    --button-bg: #0d2c54;
    --button-text: #ffffff;
    --success-color: #188038;
    --error-color: #d93025;
    --font-family: 'Calibri', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
    --glass-bg: rgba(0, 0, 0, 0.05);
    --glass-border: rgba(0, 0, 0, 0.1);
    color-scheme: light;
}

.hidden {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}


/* Top Navigation Bar */
.top-nav {
    height: 70px;
    background-color: var(--panel-bg);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-logo {
    display: flex;
    align-items: center;
    margin-right: 48px;
}

.logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.nav-menu-horizontal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.nav-item {
    padding: 12px 24px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.nav-item:hover {
    background-color: rgba(13, 44, 84, 0.06);
    color: var(--accent-color);
}

.nav-item.active {
    background-color: rgba(13, 44, 84, 0.12);
    color: var(--accent-color);
    font-weight: 600;
}

/* User Info Display */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-right: 12px;
}

/* Logout Button */
.btn-logout {
    padding: 10px 20px;
    border-radius: 6px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: var(--font-family);
}

.btn-logout:hover {
    background-color: rgba(217, 48, 37, 0.08);
    border-color: var(--error-color);
    color: var(--error-color);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Workspace Views */
.view-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: var(--bg-color);
}

.view-section.active {
    display: block;
    /* For calculator, maybe flex? handled in specific rule */
}

/* Allow Generic Tester to use flex */
#generic-tester.active {
    display: flex;
}

/* Calculator & History Styles */
#calculator-view,
#history-view {
    overflow-y: auto;
    padding: 0;
}

.calc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    background: var(--panel-bg);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
}

.checkbox-item:hover {
    color: var(--text-primary);
}

/* Dashboard Results */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: slideUp 0.5s ease-out;
}



.dashboard-top-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    align-items: stretch;
}

.price-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 400;
}



.dashboard-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}

.pano-container {
    height: 100%;
    min-height: 250px;
    overflow: hidden;
    position: relative;
    padding: 0;
}

#pano-view {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* Price Display */
.price-display {
    text-align: center;
    padding: 20px 0;
}

.price-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.price-value {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #8ab4f8, #c58af9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    font-family: var(--font-family);
    /* Ensure readable font */
}

.price-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 0;
}

.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table a {
    color: var(--accent-color);
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

/* Charts */
/* Charts: Vertical Histogram */
.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    height: 200px;
    margin-top: 32px;
    margin-left: 60px;
    /* Space for Y-axis */
    margin-right: 20px;
    /* Right margin */
    padding-bottom: 24px;
    /* Space for labels */
    border-bottom: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    position: relative;
}

.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    height: 100%;
    position: relative;
}

.chart-bar-vertical {
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease-out;
    position: relative;
}

/* Tooltip for value */
.chart-bar-vertical:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    z-index: 10;
}

/* Chart Axes */
.axis-title-y {
    position: absolute;
    left: -55px;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: center;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.axis-title-x {
    position: absolute;
    bottom: -36px;
    left: 50%;
    /* Center horizontally */
    transform: translateX(-50%);
    /* Adjust to exact center */
    font-size: 12px;
    color: var(--text-secondary);
}

/* Average Line */
.avg-line {
    position: absolute;
    bottom: 0;
    width: 2px;
    background: #FFD700;
    /* Gold */
    z-index: 5;
    pointer-events: none;
}

.avg-line::before {
    content: 'Promedio';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #FFD700;
    white-space: nowrap;
}

/* Y-axis Ticks */
.y-axis-ticks {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.y-tick {
    position: absolute;
    left: -8px;
    width: 100%;
    display: flex;
    align-items: center;
}

.y-tick-label {
    position: absolute;
    left: -45px;
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.y-tick-line {
    position: absolute;
    left: 0;
    width: 8px;
    height: 1px;
    background: var(--border-color);
}

/* Bar Value Labels */
.bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-color);
    white-space: nowrap;
}

/* Star Ratings */
.star-rating {
    display: inline-flex;
    gap: 2px;
}

.star {
    font-size: 16px;
    color: var(--border-color);
    /* Gray by default */
}

.star.filled {
    color: #FFD700;
    /* Gold */
}


/* Map for Similares */
#similares-map {
    width: 100%;
    height: 400px;
    border-radius: 12px;
    margin-top: 0;
    border: 1px solid var(--border-color);
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    min-width: 0;
    /* Prevent flex overflow */
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    height: 40px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--panel-bg);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-control {
    background-color: #f1f3f4;
    /* Darker input bg */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 14px;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color 0.2s;
}

.input-control:focus {
    border-color: var(--accent-color);
}

.input-control:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.code-input {
    min-height: 200px;
    resize: vertical;
    line-height: 1.5;
}

.flex-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.flex-grow textarea {
    flex: 1;
}

/* Headers List */
.headers-list {
    background-color: #f1f3f4;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
}

.header-item {
    font-family: var(--font-mono);
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.header-item:last-child {
    margin-bottom: 0;
}

.header-key {
    color: #ce9178;
    /* VS Code key color approx */
}

.header-value {
    color: #9cdcfe;
    /* VS Code string color approx */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--button-bg);
    color: var(--button-text);
}

.btn-primary:hover {
    background-color: #0a2342;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Orange PDF Button */
#pdf-btn {
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    transition: all 0.3s ease;
}

#pdf-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff5722 0%, #ff7733 100%);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
    transform: translateY(-2px);
}

#pdf-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

#pdf-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Response Viewer */
.code-viewer {
    background-color: #f1f3f4;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    flex: 1;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
    color: #202124;
}

.placeholder-text {
    color: var(--text-secondary);
    font-family: var(--font-family);
    text-align: center;
    margin-top: 40px;
}

/* Status Badge */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.status-badge.success {
    background-color: rgba(129, 201, 149, 0.2);
    color: var(--success-color);
}

.status-badge.error {
    background-color: rgba(242, 139, 130, 0.2);
    color: var(--error-color);
}

/* Login Overlay */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    text-align: center;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card input {
    height: 48px;
    background-color: #f1f3f4;
}

.login-btn {
    width: 100%;
    height: 48px;
    font-size: 16px;
    margin-top: 8px;
}

#login-error {
    margin-top: 16px;
    font-size: 13px;
    text-align: center;
}

.json-key {
    color: #9cdcfe;
}

.json-string {
    color: #ce9178;
}

.json-number {
    color: #b5cea8;
}

.json-boolean {
    color: #569cd6;
}

.json-null {
    color: #569cd6;
}

/* Admin Panel Styles */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.admin-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family);
}

.admin-tab:hover {
    color: var(--accent-color);
    background-color: rgba(13, 44, 84, 0.04);
}

.admin-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}

.admin-tab-content {
    margin-top: 24px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.tab-panel h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--accent-color);
}

/* Gauge Chart Styles */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 200px;
}

.gauge-svg {
    width: 100%;
    height: auto;
}

.gauge-needle {
    transition: transform 0.8s ease-out;
}

.gauge-value {
    position: absolute;
    bottom: 25px;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-color);
}

.gauge-label {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}