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

/* ============================================================
   GLOBAL SWAY IMPERFECTIONS STUDIO
   SFS-EN 1992-1-1 §5.2 / SFS-EN 1993-1-1 §5.3.2 / SFS-EN 1995-1-1 §5.4.4
   Standardized Studio Command Dock & Continuous A4 Printable Sheet Styles
   ============================================================ */

/* --- 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.collapsible {
    cursor: pointer;
    user-select: none;
}

.dock-section-title.collapsible:hover {
    color: var(--color-accent);
}

.collapse-icon {
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.dock-section.collapsed .dock-section-body {
    display: none;
}

.dock-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.dock-meta-field {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.dock-meta-field:last-child {
    margin-bottom: 0;
}

.dock-meta-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-heading);
    margin-bottom: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.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-text);
    box-sizing: border-box;
    font-family: var(--font-sans);
}

.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;
}

.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 Scorecard --- */
.dock-hud-card {
    background: #ffffff;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border-light);
}

.hud-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-heading);
    text-transform: uppercase;
}

.hud-meter-row {
    margin-bottom: 6px;
}

.hud-meter-row:last-child {
    margin-bottom: 0;
}

.hud-meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    font-weight: 600;
}

.hud-meter-name {
    color: var(--color-text-secondary);
}

.hud-meter-val {
    font-family: var(--font-mono);
    color: var(--color-heading);
}

/* Storey Table inside Dock */
.dock-storey-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    margin-top: 6px;
}

.dock-storey-table th {
    background: #e2e8f0;
    color: #1e293b;
    font-weight: 700;
    padding: 4px 6px;
    text-align: left;
    border: 1px solid #cbd5e1;
}

.dock-storey-table td {
    padding: 3px 4px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.dock-storey-table input {
    width: 100%;
    padding: 2px 4px;
    font-size: 0.74rem;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    box-sizing: border-box;
}

.btn-dock-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-dock-action:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-dock-action.primary {
    background: var(--color-accent);
    color: #ffffff;
    border-color: var(--color-accent);
}

.btn-dock-action.primary:hover {
    background: #a84828;
}

/* --- Right Side Main Workspace (Continuous Container) --- */
.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;
    border-radius: 8px 8px 0 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 Printable 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;
}

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

.visualizer-card svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Math Blocks & Report Sections */
.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;
}

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

.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;
}

/* 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;
    margin-top: 8px;
}

.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);
}

/* Modal Dialog Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

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

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

.modal-close-btn:hover {
    color: var(--color-heading);
    background: #f1f5f9;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fafaf8;
}

/* --- Active Member Indicator & Drawer Navigation --- */
.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;
}

.btn-toggle-drawer {
    background: #ffffff;
    border: 1px solid var(--color-border);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.btn-toggle-drawer:hover {
    background: var(--color-accent-bg, #f0f7ff);
    border-color: var(--color-accent);
}

/* --- Slide-out Member Drawer --- */
.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-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);
}

.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; }

.suite-badge {
    margin-left: 10px;
}

/* Dock Locked State */
.dock-locked-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 8px 10px;
    border-radius: 4px;
    margin-top: 8px;
    color: #92400e;
    font-size: 0.74rem;
}

.dock-locked-banner .locked-icon {
    font-size: 1.1rem;
}

.dock-locked-banner .locked-text {
    display: flex;
    flex-direction: column;
}

.dock-locked-banner .locked-text strong {
    font-weight: 700;
    color: #78350f;
}

.dock-is-locked input:not(#proj-date),
.dock-is-locked select,
.dock-is-locked button:not(#btn-toggle-project-settings):not(#btn-lock-sway) {
    pointer-events: none;
    opacity: 0.65;
    background-color: #f1f5f9;
}

.card-pill.locked {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.card-lock-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 1px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.card-lock-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.card-lock-btn.locked {
    color: #b45309;
}

.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);
}

/* Print Media Rules */
@media print {
    .app-sidebar-dock,
    .top-hub-nav,
    .doc-actions-bar,
    .tab-nav,
    .btn-export,
    .action-btn,
    .member-drawer,
    .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: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
    }

    .doc-section,
    .math-block,
    .report-table,
    .visualizer-card,
    .engineering-title-block {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
