/* ============================================================================
   GOSTOL PLAN / TOC ENTERPRISE MODULE
   Compact professional TOC + TOC Admin styling
   Loaded separately from views.templ to keep the main template maintainable.
   ============================================================================ */

:root {
    --toc-red: #cc2027;
    --toc-red-dark: #a81a20;
    --toc-blue: #155ca8;
    --toc-ink: #172033;
    --toc-muted: #536170;
    --toc-border: #cbd5e1;
    --toc-panel: #ffffff;
    --toc-canvas-bg: #f8fafc;
    --toc-grid-dot: #d8dee9;
    --toc-soft: #eef3f9;
}

/* -------------------- TOC tab density -------------------- */
#tab-tp {
    padding: 6px 8px !important;
    overflow: hidden !important;
    font-size: 11.5px;
    line-height: 1.25;
}

#tab-tp .toc-topbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 5px;
}

#tab-tp .toc-title h2 {
    font-size: 18px !important;
    line-height: 1.05;
    margin: 0 0 1px 0 !important;
    color: var(--toc-ink);
    letter-spacing: -0.03em;
}

#tab-tp .toc-subtitle,
#tab-tp .toc-breadcrumbs {
    font-size: 10px !important;
    line-height: 1.2;
    color: var(--toc-muted);
}

#tab-tp .toc-breadcrumbs {
    margin: 0 0 5px 0 !important;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tab-tp .toc-breadcrumbs a {
    color: var(--toc-blue);
    text-decoration: none;
    font-weight: 700;
}

#tab-tp .toc-actions {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
}

#tab-tp .toc-actions .filter-select {
    height: 30px;
    min-width: 260px;
    padding: 4px 8px !important;
    font-size: 11px !important;
    border-radius: 5px;
}

#tab-tp .toc-actions .btn,
#tab-tp .btn {
    padding: 6px 9px !important;
    font-size: 11px !important;
    line-height: 1.15;
    border-radius: 5px;
    min-height: 28px;
}

#tab-tp .toc-workarea {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 7px;
    min-height: 0;
}

#tab-tp .toc-control-panel {
    padding: 8px 9px !important;
    margin: 0 !important;
    border-radius: 7px !important;
    max-height: calc(100vh - 170px);
    overflow: auto;
}

#tab-tp .toc-control-panel h3 {
    font-size: 12px !important;
    padding-bottom: 5px !important;
    margin-bottom: 7px !important;
    letter-spacing: -0.01em;
}

#tab-tp .view-label {
    font-size: 8.5px !important;
    line-height: 1.05 !important;
    margin-bottom: 2px !important;
    letter-spacing: .04em;
}

#tab-tp .view-value {
    font-size: 11px !important;
    line-height: 1.16 !important;
    margin-bottom: 5px !important;
}

#tab-tp .view-desc-box {
    padding: 6px 7px !important;
    font-size: 10.5px !important;
    line-height: 1.2 !important;
    margin-bottom: 7px !important;
    border-radius: 5px;
    max-height: 58px;
    overflow: auto;
}

#tab-tp .mini-link {
    font-size: 10px !important;
    padding: 4px 0 !important;
    display: flex;
    justify-content: space-between;
    gap: 5px;
    align-items: center;
}

#tab-tp .dept-dot {
    width: 8px !important;
    height: 8px !important;
    display: inline-block;
    border-radius: 999px;
    margin-right: 4px;
    vertical-align: middle;
}

#tab-tp .toc-canvas-column {
    min-width: 0;
    min-height: 0;
}

#tab-tp .tp-canvas-wrapper {
    height: calc(100vh - 156px) !important;
    min-height: calc(100vh - 156px) !important;
    border-radius: 6px !important;
    background: #d8dee8 !important;
    overflow: auto !important;
}

#tab-tp .tp-canvas {
    width: 3000px !important;
    height: 2000px !important;
    background-color: var(--toc-canvas-bg) !important;
    background-image: radial-gradient(var(--toc-grid-dot) .8px, transparent .8px) !important;
    background-size: 28px 28px !important;
}

#tab-tp .tp-bubble {
    width: 155px !important;
    padding: 6px 7px !important;
    border-width: 1px !important;
    border-left-width: 5px !important;
    border-radius: 5px !important;
    box-shadow: 0 4px 10px rgba(15,23,42,.12) !important;
}

#tab-tp .bubble-owner {
    font-size: 7.5px !important;
    line-height: 1.08 !important;
    margin: -6px -7px 4px -7px !important;
    padding: 5px 7px 4px 7px !important;
    letter-spacing: .02em !important;
}

/* Department identity is shown as a full-width top band. The problem/type
   accent on the card edge remains unchanged and keeps its original meaning. */
#tab-tp .tp-bubble .department-header {
    border-bottom: 0 !important;
    border-radius: 4px 4px 0 0;
    font-weight: 900 !important;
    text-shadow: none;
}

/* -------------------- Multilingual node content -------------------- */
.toc-content-language-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
}

.toc-content-language-select {
    min-width: 118px;
    height: 26px;
    padding: 2px 5px;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    background: #fff;
    color: #172033;
    font-size: 10px;
    font-weight: 800;
}

.toc-legacy-language-field {
    display: none !important;
}

.toc-multilingual-editor {
    margin: 10px 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.toc-language-editor-heading {
    padding: 9px 11px;
    background: #eef2f7;
    border-bottom: 1px solid #cbd5e1;
    color: #334155;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.toc-language-tabs {
    display: flex;
    gap: 3px;
    padding: 8px 8px 0;
    background: #fff;
}

.toc-language-tab {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    font-weight: 800;
}

.toc-language-tab.active {
    border-bottom-color: #cc2027;
    background: #fff;
    color: #cc2027;
}

.toc-language-panels {
    padding: 12px;
    background: #fff;
}

.toc-language-panel {
    display: none;
}

.toc-language-panel.active {
    display: grid;
    gap: 6px;
}

.toc-language-panel label {
    margin-top: 4px;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .04em;
}

.toc-language-panel input,
.toc-language-panel textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #172033;
    font: inherit;
}

.toc-language-panel textarea {
    min-height: 92px;
    resize: vertical;
}

#tab-tp .bubble-title {
    font-size: 10.5px !important;
    line-height: 1.12 !important;
    margin-bottom: 3px !important;
    font-weight: 800 !important;
}

#tab-tp .bubble-text {
    font-size: 9.5px !important;
    line-height: 1.16 !important;
}

#tab-tp .bubble-meta {
    font-size: 7.2px !important;
    line-height: 1.12 !important;
    margin-top: 4px !important;
}

#tab-tp .bubble-actions {
    margin-top: 4px !important;
    gap: 4px !important;
    opacity: .55 !important;
}

#tab-tp .bubble-actions button {
    width: 18px !important;
    height: 18px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    border-radius: 4px !important;
    padding: 0 !important;
}

#tab-tp .node-linked-pill {
    font-size: 7px !important;
    line-height: 1 !important;
    padding: 2px 4px !important;
    margin-top: 4px !important;
}

#tab-tp .zoom-controls {
    width: 96px !important;
    padding: 4px !important;
    bottom: 8px !important;
    left: calc(100% - 108px) !important;
    border-radius: 6px !important;
}

#tab-tp .zoom-btn {
    width: 22px !important;
    height: 22px !important;
    font-size: 11px !important;
}

#tab-tp .zoom-text {
    font-size: 10px !important;
}

#tab-tp .toc-help-line {
    display: none !important;
}

/* -------------------- True fullscreen TOC map only -------------------- */
body.toc-focus-mode .sidebar,
body.toc-focus-mode .tabs-header,
body.toc-focus-mode .mobile-header {
    display: none !important;
}

body.toc-focus-mode {
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    background: #0f172a !important;
}

body.toc-focus-mode .main-content {
    width: 100vw !important;
    height: 100vh !important;
    display: block !important;
    overflow: hidden !important;
    background: #0f172a !important;
}

body.toc-focus-mode .tab-content {
    display: none !important;
}

body.toc-focus-mode #tab-tp {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #0f172a !important;
}

body.toc-focus-mode #tab-tp .toc-topbar,
body.toc-focus-mode #tab-tp .toc-control-panel,
body.toc-focus-mode #tab-tp .toc-help-line,
body.toc-focus-mode #tab-tp .toc-breadcrumbs {
    display: none !important;
}

body.toc-focus-mode #tab-tp .toc-workarea,
body.toc-focus-mode #tab-tp .toc-canvas-column,
body.toc-focus-mode #tab-tp .tp-canvas-wrapper {
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--toc-canvas-bg) !important;
    overflow: auto !important;
}

body.toc-focus-mode #tab-tp .zoom-controls {
    position: fixed !important;
    right: 12px !important;
    bottom: 12px !important;
    left: auto !important;
    z-index: 99999 !important;
}

body.toc-focus-mode #tab-tp .tp-bubble {
    width: 145px !important;
    padding: 5px 6px !important;
}

body.toc-focus-mode #tab-tp .bubble-title { font-size: 10px !important; }
body.toc-focus-mode #tab-tp .bubble-text { font-size: 9px !important; }
body.toc-focus-mode #tab-tp .bubble-owner { font-size: 7px !important; }

/* -------------------- TOC Admin density -------------------- */
#tab-toc-admin {
    padding: 10px 12px !important;
    font-size: 12px;
    line-height: 1.25;
}

#tab-toc-admin > h2 {
    font-size: 18px !important;
    line-height: 1.05;
    margin-bottom: 10px !important;
    letter-spacing: -0.03em;
}

#tab-toc-admin .feature-card {
    padding: 12px 14px !important;
    margin-bottom: 10px !important;
    border-radius: 7px !important;
}

#tab-toc-admin .feature-card h3 {
    font-size: 15px !important;
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
}

#tab-toc-admin .list-group {
    max-height: 255px !important;
    margin-bottom: 10px !important;
}

#tab-toc-admin .list-item {
    padding: 6px 8px !important;
    font-size: 11px !important;
}

#tab-toc-admin .form-group {
    margin-bottom: 8px !important;
}

#tab-toc-admin .form-group label,
#tab-toc-admin .view-label {
    font-size: 9px !important;
    margin-bottom: 3px !important;
    letter-spacing: .04em;
}

#tab-toc-admin input,
#tab-toc-admin select,
#tab-toc-admin textarea {
    padding: 6px 7px !important;
    min-height: 28px;
    font-size: 11px !important;
    border-radius: 5px !important;
}

#tab-toc-admin input[type="color"] {
    padding: 0 !important;
    height: 28px !important;
    min-height: 28px !important;
}

#tab-toc-admin .btn {
    padding: 6px 9px !important;
    min-height: 28px;
    font-size: 11px !important;
    line-height: 1.1;
    border-radius: 5px !important;
}

#tab-toc-admin .gantt-th {
    padding: 6px 8px !important;
    font-size: 9px !important;
}

#tab-toc-admin .gantt-td {
    padding: 6px 8px !important;
    font-size: 10.5px !important;
}

@media (max-width: 1200px) {
    #tab-tp .toc-workarea { grid-template-columns: 190px minmax(0, 1fr); }
    #tab-tp .toc-actions .filter-select { min-width: 210px; }
}

/* ==========================================================================
   TOC-only industrial density / print / plotter formatting
   ========================================================================== */
.toc-only-tabs .tab-btn { padding: 9px 14px; font-size: 0.82rem; }
.toc-only-nav .nav-item { padding: 8px 14px; font-size: 0.82rem; }
.toc-topbar { padding: 8px 0 10px; gap: 8px; }
.toc-title h2 { font-size: 1.05rem; line-height: 1.1; }
.toc-subtitle { font-size: 0.72rem; }
.toc-actions { gap: 5px; }
.toc-actions .btn, .toc-actions select { font-size: 0.72rem; padding: 6px 8px; height: 32px; }
.toc-workarea { grid-template-columns: 230px minmax(0, 1fr); gap: 8px; }
.toc-control-panel { padding: 9px !important; }
.toc-control-panel h3 { font-size: 0.82rem !important; padding-bottom: 6px !important; margin-bottom: 6px !important; }
.toc-control-panel .view-label { font-size: 0.58rem; margin-bottom: 2px; }
.toc-control-panel .view-value { font-size: 0.72rem; margin-bottom: 5px; }
.toc-control-panel .view-desc-box { font-size: 0.68rem; padding: 6px; margin-bottom: 7px; line-height: 1.25; }
.toc-control-panel .btn { font-size: 0.68rem; padding: 5px 7px; }
.toc-side-link-list { max-height: 160px; overflow:auto; border:1px solid var(--border); border-radius:6px; background:#f8fafc; }
.toc-node-link-mini { font-size: 0.62rem; padding: 5px; align-items:center; }
.toc-node-link-mini .btn { padding: 3px 5px; font-size: 0.6rem; }
.tp-canvas-wrapper { min-height: calc(100vh - 182px); }
.tp-bubble { width: 150px !important; padding: 6px !important; border-width: 1px !important; border-left-width: 5px !important; border-radius: 5px !important; }
.bubble-owner { font-size: 0.48rem !important; line-height: 1.05 !important; padding-bottom: 3px !important; margin-bottom: 3px !important; }
.bubble-title { font-size: 0.68rem !important; line-height: 1.15 !important; margin-bottom: 3px !important; }
.bubble-text { font-size: 0.62rem !important; line-height: 1.16 !important; }
.bubble-meta { font-size: 0.48rem !important; line-height: 1.05 !important; margin-top: 4px !important; }
.bubble-actions { gap: 4px !important; margin-top: 4px !important; }
.bubble-actions button { font-size: 0.72rem !important; width: 18px; height: 18px; padding:0; }
.node-linked-pill { font-size: 0.54rem !important; padding: 2px 4px !important; margin-top: 3px !important; }
.zoom-controls { transform: scale(0.82); transform-origin: top right; }
.modal-wide { max-width: 920px !important; }

.toc-print-page { background:#f4f7fb; padding: 12px; }
.toc-print-toolbar { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px; }
.toc-print-toolbar h2 { font-size:1.1rem; margin:0; }
.print-document { background:white; border:1px solid var(--border); border-radius:8px; padding:14px; box-shadow: var(--shadow-soft); }
.print-cover { border-bottom:2px solid var(--border); margin-bottom:12px; padding-bottom:10px; }
.print-cover h1 { font-size:1.35rem; margin-bottom:5px; }
.print-meta-line { font-size:0.78rem; margin-bottom:3px; }
.print-section { margin: 12px 0 16px; page-break-inside: avoid; }
.print-section h3 { font-size:0.95rem; color:var(--gostol-red); margin-bottom:6px; }
.toc-print-table { width:100%; border-collapse:collapse; font-size:0.68rem; background:white; }
.toc-print-table th { text-align:left; background:#e8eef6; border:1px solid #b8c4d4; padding:5px; font-size:0.62rem; text-transform:uppercase; letter-spacing:.03em; }
.toc-print-table td { border:1px solid #cdd6e2; padding:5px; vertical-align:top; line-height:1.22; }
.toc-print-table.compact td { padding:3px 4px; }
.toc-print-table small { color:#475569; font-size:0.58rem; }


/* ============================================================================
   BRAND NEW: Printing the Visual Canvas
   ============================================================================ */
@media print {
    @page { size: A3 landscape; margin: 9mm; }
    body { display:block !important; overflow:visible !important; background:white !important; }
    .sidebar, .mobile-header, .tabs-header, .no-print, .toast { display:none !important; }
    .main-content { display:block !important; overflow:visible !important; background:white !important; }
    .tab-content { display:none !important; overflow:visible !important; padding:0 !important; }
    
    /* Standard Table Printing */
    #tab-toc-map.active, #tab-toc-map { display:block !important; }
    .print-document { border:none !important; box-shadow:none !important; padding:0 !important; }
    .toc-print-table { font-size:8pt; }
    .toc-print-table th { font-size:7pt; padding:3pt; }
    .toc-print-table td { padding:3pt; }
    .print-cover h1 { font-size:18pt; }
    .print-section h3 { font-size:11pt; color:#000; }

    /* Visual Canvas Printing Overrides (Triggered by JS) */
    body.printing-canvas-mode #tab-toc-map { display: none !important; }
    body.printing-canvas-mode #tab-tp { display: block !important; padding: 0 !important; }
    body.printing-canvas-mode .toc-workarea { display: block !important; }
    body.printing-canvas-mode .toc-control-panel { display: none !important; }
    body.printing-canvas-mode .tp-canvas-wrapper {
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        border: none !important;
        background: white !important;
        box-shadow: none !important;
    }
    body.printing-canvas-mode .tp-canvas {
        /* Let the browser scale the explicit width/height we set in JS to fit the paper */
        transform: scale(1) !important;
        background-image: none !important; /* Save Ink! */
        background-color: white !important;
    }
    body.printing-canvas-mode .zoom-controls { display: none !important; }
}

/* ============================================================================
   SURGICAL FIX: TOC MAP FULLSCREEN / FOCUS MODE
   ============================================================================ */

body.toc-focus-mode {
    overflow: hidden !important;
}

body.toc-focus-mode #sidebar,
body.toc-focus-mode .sidebar,
body.toc-focus-mode .topbar,
body.toc-focus-mode .main-topbar,
body.toc-focus-mode .no-print:not(.zoom-controls) {
    display: none !important;
}

body.toc-focus-mode #main-content,
body.toc-focus-mode .main-content,
body.toc-focus-mode .content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    max-width: none !important;
}

body.toc-focus-mode #tab-tp {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #d8dee8 !important;
    overflow: hidden !important;
}

body.toc-focus-mode #tab-tp .toc-topbar,
body.toc-focus-mode #tab-tp .toc-control-panel,
body.toc-focus-mode #tab-tp .toc-breadcrumbs,
body.toc-focus-mode #tab-tp > h2,
body.toc-focus-mode #tab-tp > .toc-subtitle {
    display: none !important;
}

body.toc-focus-mode #tab-tp .toc-workarea {
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
}

body.toc-focus-mode #tab-tp .toc-canvas-column {
    width: 100vw !important;
    height: 100vh !important;
}

body.toc-focus-mode #tab-tp .tp-canvas-wrapper,
#tab-tp .tp-canvas-wrapper.toc-real-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: auto !important;
    background: #d8dee8 !important;
}

body.toc-focus-mode #tab-tp .zoom-controls,
#tab-tp .tp-canvas-wrapper.toc-real-fullscreen .zoom-controls {
    position: fixed !important;
    top: 12px !important;
    right: 16px !important;
    z-index: 100000 !important;
}

/* ============================================================================
   SEMANTIC TOC CONNECTION COLORS
   ============================================================================ */

.toc-edge-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toc-edge-color-input {
    width: 74px !important;
    height: 44px;
    padding: 3px !important;
    cursor: pointer;
    background: #fff;
}

.toc-edge-color-preview {
    min-width: 104px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(15, 23, 42, 0.2);
}

.toc-edge-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.toc-edge-color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #94a3b8;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.toc-edge-color-swatch:hover,
.toc-edge-color-swatch:focus-visible {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px #0f172a;
    outline: none;
}

.toc-edge-inline-editor {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    padding-left: 6px;
}

.toc-edge-inline-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.35);
    flex: 0 0 auto;
}

.toc-edge-inline-form {
    display: inline-flex;
    margin: 0;
}

.toc-edge-inline-input {
    width: 27px !important;
    height: 25px !important;
    padding: 1px !important;
    border-radius: 4px !important;
    cursor: pointer;
    background: #fff;
}

.toc-semantic-legend {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding-left: 10px;
    border-left: 1px solid #cbd5e1;
}

.toc-semantic-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 750;
    white-space: nowrap;
}

.toc-semantic-legend-item i {
    display: inline-block;
    width: 15px;
    height: 4px;
    border-radius: 999px;
}

.tp-edge-path,
.wf-edge-path {
    transition: stroke-width 0.15s ease, opacity 0.15s ease;
}

.tp-edge-path:hover,
.wf-edge-path:hover {
    stroke-width: 4.5 !important;
    opacity: 0.88;
}

@media (max-width: 768px) {
    .toc-semantic-legend {
        width: 100%;
        padding-left: 0;
        padding-top: 7px;
        border-left: 0;
        border-top: 1px solid #cbd5e1;
    }
}
