:root {
    --primary-color: #FF7A00;
    --primary-hover: #E06B00;
    --primary-glow: rgba(255, 122, 0, 0.25);
    --bg-dark: #0D1117;
    --bg-card: rgba(22, 27, 34, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.12);
    --border-glass-focus: rgba(255, 122, 0, 0.5);
    --text-main: #F0F6FC;
    --text-muted: #8B949E;
    --text-dim: #6E7681;
    --success: #00E676;
    --success-glow: rgba(0, 230, 118, 0.2);
    --danger: #FF3B30;
    --warning: #FF9800;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 10% 15%, rgba(255, 122, 0, 0.12) 0%, transparent 40%),
                      radial-gradient(circle at 90% 85%, rgba(0, 150, 255, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
}

/* App Containers */
.app-container {
    width: 96%;
    max-width: 1440px;
    height: 94vh;
    height: 94dvh;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 1.5rem auto;
}

.hub-container {
    width: 92%;
    max-width: 1240px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sandbox-container {
    width: 96%;
    max-width: 1400px;
    margin: 1.5rem auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Header */
.main-header {
    position: relative;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.6rem;
    border-radius: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--text-main);
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.logo span {
    color: var(--primary-color);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-main);
    background: var(--bg-glass-hover);
}

/* Country Switcher Dropdown */
.country-switcher {
    position: relative;
    display: inline-block;
    z-index: 1001;
}

.country-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 122, 0, 0.1);
    border: 1px solid rgba(255, 122, 0, 0.3);
    border-radius: 24px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.country-selector-btn:hover {
    background: rgba(255, 122, 0, 0.2);
    border-color: var(--primary-color);
    box-shadow: 0 0 12px var(--primary-glow);
}

.country-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: #161B22 !important;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
    padding: 0.5rem;
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 99999 !important;
}

.country-menu.open {
    display: flex !important;
    animation: fadeIn 0.2s ease;
}

.country-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.country-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.country-item.active {
    background: rgba(255, 122, 0, 0.2);
    color: var(--primary-color);
    font-weight: 600;
}

.country-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.flag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 18px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    line-height: 1;
}
.flag-pe { background: #D91023; color: white; border: 1px solid rgba(255,255,255,0.3); }
.flag-bo { background: #007934; color: #F8D12D; border: 1px solid rgba(255,255,255,0.3); }
.flag-co { background: #FCD116; color: #003893; border: 1px solid rgba(255,255,255,0.3); }

/* Indicators */
.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.indicator.offline {
    background-color: var(--danger);
    box-shadow: 0 0 8px rgba(255, 59, 48, 0.4);
}

/* Layout Side-by-Side */
.main-layout {
    display: flex;
    flex: 1;
    gap: 1rem;
    overflow: hidden;
}

.control-panel {
    width: 420px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.map-area {
    flex: 1;
    position: relative;
    border-radius: 14px;
    overflow: hidden;
}

.mapviewer-container {
    width: 100%;
    height: 100%;
    background: #1B212C;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

iframe.map-frame {
    width: 100%;
    height: 100%;
    border: none;
}

.empty-map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    gap: 1rem;
}

.empty-map-placeholder svg {
    width: 56px;
    height: 56px;
    opacity: 0.5;
    stroke: var(--primary-color);
}

/* Formularios */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
    margin-bottom: 1rem;
}

label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.6px;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 0.95rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

input:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Autocomplete list */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #1A202C;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    margin-top: 4px;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-list li {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover { background: rgba(255, 122, 0, 0.15); color: var(--primary-color); }

/* Botones */
.btn-primary, .btn-secondary, .btn-success {
    padding: 0.8rem 1.4rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
}

.btn-success {
    background: #00C853;
    color: #000;
    font-weight: 700;
    box-shadow: 0 4px 14px var(--success-glow);
}

.btn-success:hover:not(:disabled) {
    background: #00E676;
    transform: translateY(-2px);
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-success:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: #161B22;
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(20px);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover { color: var(--text-main); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-orange {
    background: rgba(255, 122, 0, 0.18);
    color: var(--primary-color);
    border: 1px solid rgba(255, 122, 0, 0.3);
}

.badge-green {
    background: rgba(0, 230, 118, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 230, 118, 0.3);
}

.badge-blue {
    background: rgba(0, 150, 255, 0.15);
    color: #40C4FF;
    border: 1px solid rgba(0, 150, 255, 0.3);
}

/* Hub Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.75rem;
}

.country-card {
    padding: 2.25rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 16px;
    position: relative;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.country-card:hover {
    transform: translateY(-6px);
    border-color: var(--primary-color);
    box-shadow: 0 12px 36px var(--primary-glow);
}

.country-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.country-flag-title {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.flag-icon {
    font-size: 2.2rem;
}

.country-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.country-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.features-list {
    list-style: none;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.features-list li span.check {
    color: var(--success);
    font-weight: bold;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Sandbox Layout */
.sandbox-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
}

.endpoints-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.25rem;
}

.endpoint-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.endpoint-btn:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.25);
}

.endpoint-btn.active {
    background: rgba(255, 122, 0, 0.15);
    border-color: var(--primary-color);
}

.method-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.method-get { background: rgba(0, 150, 255, 0.2); color: #40C4FF; }
.method-post { background: rgba(0, 230, 118, 0.2); color: #00E676; }

.sandbox-console {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
}

.code-editor, .code-viewer {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    background: #090D13;
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 1rem;
    color: #9CDCFE;
    white-space: pre;
    overflow-x: auto;
    line-height: 1.5;
}

.code-editor {
    min-height: 140px;
    resize: vertical;
    width: 100%;
    color: #E2E8F0;
}

/* Spinners & Animations */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsividad */
@media (max-width: 960px) {
    .main-layout {
        flex-direction: column;
    }
    .control-panel {
        width: 100%;
        max-height: 50vh;
    }
    .map-area {
        min-height: 380px;
    }
    .sandbox-grid {
        grid-template-columns: 1fr;
    }
}
