@import '../shared/document.css';

/* ============================================================
   SNOW LOADS STUDIO (SFS-EN 1991-1-3 + Finnish NA)
   Standardized Studio Command Dock & A4 Printable Sheet Styles
   Identical Architecture & Design Language to Concrete Beam Studio
   ============================================================ */

/* --- Workspace Wrapper (Centered Studio for Desktop) --- */
.workspace-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 100vh;
    box-sizing: border-box;
}

@media (max-width: 1100px) {
    .workspace-wrapper {
        flex-direction: column;
        align-items: center;
    }
}

/* --- Left Sidebar Dock (Left-Hand Ergonomic Scrollbar) --- */
.app-sidebar-dock {
    width: 440px;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: var(--sp-md);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    flex-shrink: 0;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 10;
    box-sizing: border-box;
    margin-bottom: 16px;

    /* Move scrollbar to the left for clean visual boundary */
    direction: rtl;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

.app-sidebar-dock > * {
    direction: ltr; /* Reset children to standard LTR text */
}

.app-sidebar-dock::-webkit-scrollbar {
    width: 5px;
}
.app-sidebar-dock::-webkit-scrollbar-track {
    background: transparent;
}
.app-sidebar-dock::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}
.app-sidebar-dock:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.30);
}

/* --- Dock Sections & Elements --- */
.dock-section {
    background: #fafaf8;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    padding: var(--sp-sm) var(--sp-md);
}

.dock-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-heading);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-xs);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 4px;
}

.dock-section-title .badge-tag {
    font-size: 0.68rem;
    padding: 2px 6px;
    background: #e2e8f0;
    color: #334155;
    border-radius: 3px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

/* Input Fields inside Dock */
.dock-meta-field {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 3px;
    margin-bottom: 6px;
    height: 100%;
    box-sizing: border-box;
}

.dock-meta-field label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    line-height: 1.25;
}

.dock-meta-field label .unit {
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    font-size: 0.70rem;
    flex-shrink: 0;
    margin-left: 4px;
}

.dock-meta-field input,
.dock-meta-field select {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.82rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: #ffffff;
    color: var(--color-heading);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.dock-meta-field input:focus,
.dock-meta-field select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-light);
}

.dock-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 6px;
    align-items: stretch;
}

.dock-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-bottom: 6px;
    align-items: stretch;
}

/* Harmonize heights in multi-column rows so inputs sit on exact same baseline */
.dock-grid-2 .dock-meta-field,
.dock-grid-3 .dock-meta-field {
    display: flex;
    flex-direction: column;
}

.dock-grid-2 .dock-meta-field label,
.dock-grid-3 .dock-meta-field label {
    min-height: 2.6em;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex: 1 0 auto;
    margin-bottom: 4px;
}

.dock-grid-2 .dock-meta-field input,
.dock-grid-2 .dock-meta-field select,
.dock-grid-3 .dock-meta-field input,
.dock-grid-3 .dock-meta-field select {
    margin-top: auto;
}

.dock-range-row {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 8px;
    align-items: center;
}

.dock-hint {
    font-size: 0.70rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Preset Selector Dropdown */
.dock-preset-select {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1.5px solid var(--color-accent);
    border-radius: 4px;
    background: var(--color-accent-bg);
    color: var(--color-accent);
    cursor: pointer;
    margin-bottom: 4px;
}

.dock-preset-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-accent-light);
}

/* Live HUD Cards */
.dock-hud-card {
    background: #ffffff;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.hud-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.hud-stat-card {
    background: #fafaf8;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
}

.hud-stat-label {
    font-size: 0.70rem;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.hud-stat-val {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-heading);
    margin-top: 2px;
}

.hud-stat-sub {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* --- Right Side Main Workspace --- */
.app-main-workspace {
    flex: 1;
    min-width: 0;
    max-width: 1020px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Attached Hub Nav Bar */
.app-main-workspace .top-hub-nav {
    width: 100%;
    background: #e9e6df;
    border: 1px solid var(--color-border);
    border-top: none;
    border-bottom: 1px solid var(--color-border);
    padding: 8px 16px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

/* Attached Export Bar */
.app-main-workspace .doc-actions-bar {
    width: 100%;
    background: #fcfbfa;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    border-top: none;
    border-bottom: 1px solid var(--color-border-light);
    padding: 8px 16px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-md);
    flex-wrap: wrap;
    margin-bottom: 0;
}

/* Attached Tab Navigation */
.app-main-workspace .tab-nav {
    width: 100%;
    background: #ece8df;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    border-top: none;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    margin-bottom: 0;
    padding: 0;
    box-sizing: border-box;
}

.app-main-workspace .tab-btn {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-right: 1px solid var(--color-border);
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-serif);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 0;
    text-decoration: none;
}

.app-main-workspace .tab-btn:last-child {
    border-right: none;
}

.app-main-workspace .tab-btn:hover {
    color: var(--color-heading);
    background: rgba(0, 0, 0, 0.03);
}

.app-main-workspace .tab-btn.active {
    color: var(--color-heading);
    border-bottom: 3px solid var(--color-accent);
    background: var(--color-paper);
}

.app-main-workspace .tab-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.app-main-workspace .tab-btn.active svg {
    opacity: 1;
    color: var(--color-accent);
}

/* --- True A4 Printable Document Sheet --- */
.app-main-workspace .page-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: #fafaf8;
    border: 1px solid var(--color-border);
    border-top: none;
    box-shadow: 0 4px 16px var(--color-paper-shadow);
    padding: 24px 32px;
    box-sizing: border-box;
    border-radius: 0 0 8px 8px;
}

/* Engineering Title Block (Nimiö) */
.engineering-title-block {
    border: 2px solid var(--color-heading);
    margin-bottom: 18px;
    background: #ffffff;
}

.title-block-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-heading);
}

.title-block-main-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-heading);
}

.title-block-main-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.title-block-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr 1.2fr;
}

.title-block-cell {
    padding: 5px 10px;
    border-right: 1px solid var(--color-heading);
}

.title-block-cell:last-child {
    border-right: none;
}

.title-block-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.title-block-val {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Document Sections & Report Content */
.doc-section {
    margin-bottom: 18px;
}

.doc-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 4px;
}

.doc-section-num {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
}

.doc-section-header h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-heading);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.doc-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.summary-cell {
    background: #ffffff;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
}

.cell-label {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.cell-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-heading);
    margin-top: 3px;
}

/* Math blocks */
.math-block {
    background: #ffffff;
    border: 1px solid var(--color-border-light);
    border-left: 3px solid var(--color-accent);
    border-radius: 4px;
    padding: 10px 14px;
}

.math-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 4px;
}

.math-subtext {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin: 4px 0;
}

/* Visualizer Card & SVG */
.snow-visualizer-card {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--sp-md);
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.snow-diagram-svg {
    width: 100%;
    height: auto;
    display: block;
    background: #fafaf8;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
}

/* Report Table */
.report-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    font-size: 0.80rem;
}

.report-table th {
    background: #f4f2ee;
    padding: 8px 10px;
    font-weight: 700;
    color: var(--color-heading);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.report-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--color-border-light);
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Print Media Rules (@media print) ──────────────────────── */
@media print {
    .app-sidebar-dock,
    .top-hub-nav,
    .doc-actions-bar,
    .tab-nav,
    .btn-export,
    .action-btn,
    .print-hide {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .workspace-wrapper {
        display: block !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .app-main-workspace {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .app-main-workspace .page-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 12mm 15mm !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
    }

    .doc-section,
    .math-block,
    .report-table,
    .snow-diagram-svg,
    .engineering-title-block {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============================================================
   MEMBER DRAWER & MULTI-MEMBER CONTROLS (LUMIKUORMALUETTELO)
   ============================================================ */

.btn-toggle-drawer {
    background: var(--color-accent, #0055a3);
    color: #ffffff;
    border: 1px solid rgba(0,0,0,0.15);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.15s;
}

.btn-toggle-drawer:hover {
    background: #004482;
    transform: translateY(-1px);
}

.active-member-indicator {
    background: #ffffff;
    border: 1px solid var(--color-border);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--color-heading);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.active-member-indicator .member-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2e7d32;
}

.member-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    background: #ffffff;
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1050;
}

.member-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    background: #f7f6f3;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-heading-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.drawer-heading {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-heading);
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-subheading {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
}

.btn-drawer-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.drawer-filter-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    background: #fdfdfc;
    border-bottom: 1px solid var(--color-border-light);
    overflow-x: auto;
}

.drawer-filter-btn {
    padding: 3px 8px;
    font-size: 0.70rem;
    font-weight: 600;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    background: #ffffff;
    color: var(--color-text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s;
}

.drawer-filter-btn.active {
    background: var(--color-accent-bg, #e8f0fa);
    color: var(--color-accent, #0055a3);
    border-color: var(--color-accent, #0055a3);
}

.drawer-toolbar {
    padding: 8px 12px;
    background: #ffffff;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    gap: 6px;
}

.btn-drawer-action {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.73rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--color-text-primary, #1a2744);
    transition: all 0.15s;
}

.btn-drawer-action:hover {
    background: #f5f5f4;
    border-color: #d1d5db;
}

.btn-drawer-action--primary {
    background: var(--color-accent-bg, #e8f0fa);
    color: var(--color-accent, #0055a3);
    border-color: var(--color-accent);
}

.dropdown-item:hover {
    background: #f0f7ff !important;
    color: var(--color-accent, #0055a3);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-card {
    border: 1px solid var(--color-border);
    border-radius: 5px;
    padding: 10px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.drawer-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.drawer-card.active {
    border-color: var(--color-accent);
    background: #f0f7ff;
    border-left: 4px solid var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.card-tag {
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--color-heading);
    font-family: var(--font-mono);
}

.card-pill {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
}

.pill-pass { background: #e8f5e9; color: #2e7d32; }
.pill-warn { background: #fff8e1; color: #e65100; }
.pill-fail { background: #ffebee; color: #c62828; }

.card-type-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f1f5f9;
    color: #475569;
    margin-bottom: 3px;
}

.card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    border-top: 1px dashed var(--color-border-light);
    margin-top: 5px;
    padding-top: 4px;
}

.drawer-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--color-border);
    background: #f7f6f3;
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--color-text-secondary);
}

.suite-badge {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.74rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #bae6fd;
    text-transform: uppercase;
    margin-left: 10px;
}

.drawer-card.is-locked {
    border-color: #fde68a;
    background: #fffbeb;
}

.card-pill.locked,
.pill-locked {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.card-lock-btn {
    background: transparent;
    border: 1px solid var(--color-border, #cbd5e1);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #475569;
}

.card-lock-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.dock-is-locked input,
.dock-is-locked select,
.dock-is-locked button:not(#btn-toggle-project-settings) {
    pointer-events: none;
    opacity: 0.75;
    background-color: #f8fafc !important;
}
