/* 
  Estilos para la Interfaz "Primavera P6" Simplificada
  WorkPlan Project Planning Module
*/

:root {
    --p6-blue: #004b8d;
    --p6-accent: #f97316;
    --p6-bg: var(--bg);
    --p6-panel: var(--panel);
    --p6-border: var(--border);
    --p6-header: var(--panel-inner);
    --p6-font: 'Inter', sans-serif;
    --p6-row-h: 32px;
}

/* Layout Principal — Full Width */
.p6-container {
    display: flex;
    height: calc(100vh - 100px);
    background: var(--p6-bg);
    border: 1px solid var(--p6-border);
    border-radius: 12px;
    overflow: hidden;
    color: var(--text);
    font-family: var(--p6-font);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Section override — remove padding so container fills viewport */
#section-proyectos-planificacion {
    padding: 8px 4px !important;
}

/* Sidebar de Modos (Izquierda estrecha) */
.p6-modes-bar {
    width: 52px;
    min-width: 52px;
    background: var(--p6-header);
    border-right: 1px solid var(--p6-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    gap: 18px;
}

.p6-mode-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
    color: var(--muted);
}

.p6-mode-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--accent);
}

.p6-mode-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.3);
}

/* Espacio de trabajo (Main) */
.p6-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Barra de herramientas superior del módulo */
.p6-toolbar {
    height: 46px;
    min-height: 46px;
    background: var(--p6-header);
    border-bottom: 1px solid var(--p6-border);
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 12px;
}

/* Divisor horizontal (Tabla / Gantt) */
.p6-split-v {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}

.p6-table-pane {
    width: 45%;
    min-width: 380px;
    border-right: 2px solid var(--p6-border);
    overflow: auto;
    background: var(--p6-panel);
}

.p6-gantt-pane {
    flex: 1;
    overflow: auto;
    background: var(--p6-bg);
    min-width: 0;
}

/* ===== Detalles inferiores (Aumentado) ===== */
.p6-details-pane {
    height: 220px;
    min-height: 0;
    border-top: 2px solid var(--p6-border);
    background: var(--p6-panel);
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease, opacity 0.25s ease;
    overflow: hidden;
}

.p6-details-pane.p6-details-hidden {
    height: 0;
    min-height: 0;
    border-top: none;
    opacity: 0;
    pointer-events: none;
}

/* Sidebar divider */
.p6-sidebar-divider {
    width: 28px;
    height: 1px;
    background: var(--p6-border);
    margin: 4px 0;
    opacity: 0.5;
}

/* Tabs de detalles */
.p6-details-tabs {
    display: flex;
    background: var(--p6-header);
    border-bottom: 1px solid var(--p6-border);
    padding: 0 10px;
    min-height: 30px;
}

.p6-tab {
    padding: 6px 18px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.p6-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}

.p6-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.p6-tab-content {
    flex: 1;
    padding: 6px 10px;
    overflow-y: auto;
}

/* Compact form grid for details panel */
.p6-compact-form {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 10px;
    padding: 4px 6px;
}

.p6-compact-form .p6-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.p6-compact-form .p6-field.wide {
    grid-column: span 2;
}

.p6-compact-form .p6-field > span {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.p6-compact-form .p6-field input,
.p6-compact-form .p6-field select {
    width: 100%;
    padding: 4px 6px;
    font-size: 11px;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--p6-border);
    border-radius: 4px;
    color: var(--text);
    box-sizing: border-box;
}

.p6-compact-form .p6-field input:focus,
.p6-compact-form .p6-field select:focus {
    border-color: var(--accent);
    outline: none;
}

/* ===== Estilos de Tabla P6 ===== */
.p6-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.p6-table th {
    background: var(--p6-header);
    color: var(--muted);
    font-weight: 700;
    text-align: left;
    padding: 6px 6px;
    border-bottom: 1px solid var(--p6-border);
    position: sticky;
    top: 0;
    z-index: 2;
    text-transform: uppercase;
    font-size: 10px;
}

.p6-table td {
    padding: 0 6px;
    height: var(--p6-row-h);
    border-bottom: 1px solid var(--p6-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.p6-table tr:hover {
    background: rgba(255,255,255,0.03);
    cursor: pointer;
}

.p6-table tr.selected {
    background: rgba(56, 189, 248, 0.15) !important;
    border-left: 3px solid var(--accent);
}

/* ===== WBS Row Styles ===== */
.p6-table tr.wbs-group {
    background: rgba(249, 115, 22, 0.06);
}

.p6-table tr.wbs-group td {
    font-weight: 700;
    color: var(--accent);
    font-size: 10.5px;
}

.wbs-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    margin-right: 4px;
    transition: all 0.15s;
    vertical-align: middle;
}

.wbs-toggle:hover {
    background: var(--accent);
    color: #fff;
}

.wbs-indent {
    display: inline-block;
}

/* ===== Gantt Rows — Matching Table Row Height ===== */
.p6-gantt-row {
    height: var(--p6-row-h);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    position: relative;
    display: flex;
    align-items: center;
    width: max-content;
}

.p6-gantt-row.wbs-group {
    background: rgba(249, 115, 22, 0.04);
}

.p6-gantt-row.hidden {
    display: none;
}
.p6-gantt-milestone {
    width: 14px;
    height: 14px;
    background: #000;
    border: 2px solid #3b82f6;
    transform: rotate(45deg);
    position: absolute;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 2;
    margin-top: 1px;
}
.p6-gantt-milestone .p6-gantt-bar-label {
    transform: rotate(-45deg);
    position: absolute;
    left: 15px;
    top: -5px;
}
.p6-gantt-milestone .p6-gantt-connector-dot.right {
    transform: rotate(-45deg);
    top: -4px;
    right: -4px;
}
.p6-gantt-milestone .p6-gantt-connector-dot.left {
    transform: rotate(-45deg);
    bottom: -4px;
    left: -4px;
    top: auto;
}

.p6-gantt-bar {
    height: 16px;
    background: linear-gradient(to bottom, #3b82f6, #1d4ed8);
    border-radius: 8px;
    position: absolute;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    min-width: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid rgba(255,255,255,0.1);
}

.p6-gantt-bar.wbs-summary {
    height: 8px;
    background: var(--accent);
    border-radius: 0;
    border: none;
    box-shadow: none;
    opacity: 0.8;
}

.p6-gantt-bar.wbs-summary::before,
.p6-gantt-bar.wbs-summary::after {
    content: '';
    position: absolute;
    bottom: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--accent);
}

.p6-gantt-bar.wbs-summary::before { left: 0; }
.p6-gantt-bar.wbs-summary::after { right: 0; }

.p6-gantt-bar:hover {
    transform: scaleY(1.15);
    filter: brightness(1.2);
}

.p6-gantt-connector-dot {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: #2B94CC;
    border: none;
    border-radius: 50%;
    cursor: crosshair;
    z-index: 10;
    opacity: 1;
    transition: transform 0.2s, background-color 0.2s;
}

.p6-gantt-connector-dot.right {
    right: -5px;
}

.p6-gantt-connector-dot.left {
    left: -5px;
}

.p6-gantt-bar:hover .p6-gantt-connector-dot {
    background: #1a719c;
    transform: translateY(-50%) scale(1.3);
}

.p6-gantt-link-line {
    fill: none;
    stroke: #2B94CC;
    stroke-width: 2;
    marker-end: url(#p6ArrowHead);
}

.p6-gantt-link-line.active {
    stroke: var(--accent);
    stroke-width: 3;
}

.p6-gantt-drag-line {
    fill: none;
    stroke: #2B94CC;
    stroke-width: 2;
    stroke-dasharray: 4,2;
}

.p6-gantt-bar.critical {
    background: linear-gradient(to bottom, #ef4444, #b91c1c);
}

.p6-gantt-bar-label {
    position: absolute;
    left: 100%;
    margin-left: 8px;
    font-size: 10px;
    white-space: nowrap;
    color: var(--muted);
    pointer-events: none;
}

.p6-gantt-timeline-header {
    height: 60px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    width: max-content;
}

.p6-gantt-month-row {
    height: 30px;
    display: flex;
    border-bottom: 1px solid var(--border);
    background: #1a1a1a;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    align-items: center;
}

.p6-gantt-month-cell {
    padding: 0 10px;
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.p6-gantt-day-row {
    height: 30px;
    display: flex;
}

.p6-gantt-day {
    flex-shrink: 0;
    width: 40px;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--muted);
}

.p6-gantt-day.weekend {
    background: rgba(249, 115, 22, 0.05); /* Soft orange for weekend */
}
.p6-gantt-day.holiday {
    background: rgba(239, 68, 68, 0.08); /* Soft red for holiday */
}

/* Histogram Area */
.p6-histogram-container {
    height: 100%;
    position: relative;
}

/* Modal specific styles */
.p6-resource-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--panel-inner);
    border-radius: 6px;
    margin-bottom: 5px;
    border: 1px solid var(--border);
}

/* Relationship Connector (SVG simulation or lines) */
.gantt-link {
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

/* ===== Scrollbar sync trick ===== */
.p6-table-pane::-webkit-scrollbar,
.p6-gantt-pane::-webkit-scrollbar {
    height: 8px;
    width: 6px;
}

.p6-table-pane::-webkit-scrollbar-thumb,
.p6-gantt-pane::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
}

.p6-table-pane::-webkit-scrollbar-track,
.p6-gantt-pane::-webkit-scrollbar-track {
    background: transparent;
}
