/* 
  PHARMA MAP V2 - DESIGN SYSTEM
  Aesthetic: Light Clinical / Premium Tech
*/

:root {
    --bg-color: #f8fafc;
    --grid-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.2);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.05);
    
    /* Category Colors */
    --color-root: #0f172a;
    --color-liderazgo: #f59e0b;
    --color-puente: #8b5cf6;
    --color-operaciones: #ef4444;
    --color-calidad: #10b981;
    --color-soporte: #06b6d4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* We handle scrolling inside the canvas */
    height: 100vh;
    width: 100vw;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* --- BACKGROUND GRID --- */
.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(var(--grid-color) 1px, transparent 1px);
    background-size: 30px 30px;
    cursor: grab;
    touch-action: none; /* Crucial for D3 touch interaction */
}

.canvas-container:active {
    cursor: grabbing;
}

/* --- LOGIN OVERLAY --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.login-logo {
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.login-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    background: #f1f5f9;
    padding: 0.5rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s;
}

.input-group:focus-within {
    border-color: var(--accent);
}

.input-group input {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    outline: none;
}

.input-group button {
    background: var(--accent);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.input-group button:hover {
    transform: scale(1.05);
}

.error-msg {
    color: #ef4444 !important;
    margin-top: 1rem !important;
    font-weight: 600;
    display: none;
}

.mobile-list-view {
    display: none;
    position: absolute;
    top: 5rem;
    left: 0;
    width: 100%;
    height: calc(100% - 5rem);
    background: var(--bg-color);
    overflow-y: auto;
    padding: 1rem;
    z-index: 5;
}

/* --- UI ELEMENTS --- */
.header {
    position: absolute;
    top: 2rem;
    left: 2rem;
    z-index: 10;
    pointer-events: auto;
}

.hint-overlay {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: monospace;
    text-align: right;
    pointer-events: none;
    z-index: 10;
}

/* --- SIDEBAR / BOTTOM SHEET --- */
.details-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: 420px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid white;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    display: none; /* Empezamos en none para seguridad total */
    flex-direction: column;
    padding: 2.5rem;
    overflow-y: auto;
    opacity: 0;
    transform: translateX(50px);
}

.details-panel.active {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

/* Drag handle for mobile */
.drag-handle {
    display: none;
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 10px;
    margin: -1.5rem auto 1.5rem;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s;
}

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

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.details-title {
    font-size: 2.25rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.details-desc {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    border-left: 2px solid var(--border-color);
    padding-left: 1rem;
}

.bento-grid {
    display: grid;
    gap: 1rem;
}

.bento-card {
    background: white;
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.bento-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bento-card p, .bento-card li {
    font-size: 0.85rem;
    line-height: 1.5;
}

.bento-card ul {
    list-style: none;
}

.bento-card li {
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
}

.view-more-btn {
    display: none; /* Hidden by default on PC */
    background: #06b6d4; /* Cyan vibrante */
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.4);
}

/* --- TREE GRAPH STYLES --- */
.node {
    cursor: pointer;
}

.node-rect {
    fill: white;
    stroke-width: 1px;
    rx: 8;
    ry: 8;
    transition: all 0.3s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

.node:hover .node-rect {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    stroke-width: 2px;
}

.node-label {
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-main);
    pointer-events: none;
    font-family: 'Inter', sans-serif;
}

.node-tag {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    fill: white;
    pointer-events: none;
}

.link {
    fill: none;
    stroke: #cbd5e1;
    stroke-width: 1.5px;
    transition: stroke 0.3s, stroke-width 0.3s;
}

.link.highlighted {
    stroke: var(--accent);
    stroke-width: 3px;
}

.node-dot {
    fill: var(--accent);
}

#canvas svg {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* --- CONTROLS --- */
.controls {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    gap: 0.5rem;
    pointer-events: auto;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--bg-color);
    border-color: var(--text-muted);
}

/* --- MOBILE ADAPTATION --- */
@media (max-width: 768px) {
    .mobile-list-view {
        display: block;
    }

    #canvas, .controls, .hint-overlay {
        display: none !important;
    }

    .list-item {
        background: white;
        margin-bottom: 0.5rem;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        padding: 0.75rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        cursor: pointer;
        transition: all 0.2s;
    }

    /* Depth levels */
    .list-item.depth-1 { margin-left: 1.5rem; border-style: dashed; }
    .list-item.depth-2 { margin-left: 3rem; font-size: 0.85rem; border: none; background: #f1f5f9; }

    .list-item.has-children::after {
        content: '+';
        font-family: monospace;
        color: var(--text-muted);
        font-weight: bold;
    }

    .list-item.expanded::after {
        content: '−';
    }

    .list-item-label {
        font-weight: 600;
        font-size: 0.9rem;
        flex: 1;
    }

    .list-category-header {
        font-size: 0.7rem;
        font-weight: 800;
        text-transform: uppercase;
        color: var(--text-muted);
        letter-spacing: 0.1em;
        margin: 2rem 0 1rem 0.5rem;
    }
    .details-panel {
        width: 100%;
        right: 0;
        bottom: 0;
        left: 0;
        top: auto;
        height: 75vh;
        border-radius: 32px 32px 0 0;
        padding: 2rem 1.5rem;
        opacity: 1;
        display: none;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1);
        z-index: 200;
    }
    
    .details-panel.active {
        display: flex;
        transform: translateY(0);
    }
    
    .drag-handle {
        display: block;
    }

    .details-panel.active.state-peek {
        transform: translateY(calc(100% - 180px)); /* Aumentado de 150 a 180 para evitar cortes */
        overflow: hidden;
    }
    
    .details-panel.state-peek .details-desc,
    .details-panel.state-peek .bento-grid,
    .details-panel.state-peek .close-btn {
        display: none;
    }

    #panel-content {
        padding-bottom: 100px; /* Espacio para el botón flotante si fuera necesario */
    }

    /* Modern Styled Button */
    .view-more-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        padding: 1.25rem;
        background: #06b6d4;
        color: white;
        border: none;
        border-radius: 16px;
        font-weight: 800;
        font-size: 1rem;
        margin-top: 1.5rem;
        cursor: pointer;
        box-shadow: 0 10px 15px -3px rgba(6, 182, 212, 0.4);
        transition: all 0.2s;
        -webkit-appearance: none;
        appearance: none;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .view-more-btn:active {
        transform: scale(0.98);
        background: #0891b2;
    }
    
    .details-panel.active.state-full {
        transform: translateY(0);
        overflow-y: auto;
    }
    
    .details-panel.state-full .view-more-btn {
        display: none;
    }
    
    .details-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .details-desc {
        font-size: 0.85rem;
    }
}

    .header {
        top: 1rem;
        left: 1rem;
    }
    
    .logo-box {
        width: 32px;
        height: 32px;
    }
    
    .title-group h1 {
        font-size: 1.1rem;
    }
}
