/* =======================================================
   SECTION 4 : CAD WORKSPACE
======================================================= */
.cad-workspace {
    position: relative;
    padding: 110px 5.5%;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 20%, rgba(46, 196, 255, 0.07), transparent 32%),
        linear-gradient(180deg, #07121f 0%, #081827 100%);
}
.cad-workspace::before {
    position: absolute;
    inset: 0;
    content: "";
    opacity: 0.28;
    background-image:
        linear-gradient(rgba(99, 202, 248, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 202, 248, 0.035) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}
.cad-workspace .section-header,
.cad-layout {
    position: relative;
    z-index: 1;
    width: min(1380px, 100%);
    margin-right: auto;
    margin-left: auto;
}
/* ---------- CAD layout ---------- */
.cad-layout {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr) minmax(245px, 0.31fr);
    align-items: stretch;
    gap: 16px;
    min-height: 700px;
}
/* ---------- Tool rail ---------- */
.cad-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 12px 9px;
    border: 1px solid rgba(132, 215, 248, 0.18);
    border-radius: 13px;
    background: rgba(8, 29, 46, 0.77);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(15px);
}
.cad-toolbar::after {
    width: 30px;
    height: 1px;
    margin: 4px 0;
    content: "";
    background: rgba(127, 205, 240, 0.18);
    order: 6;
}
.cad-toolbar button {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    color: #b8d9e8;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    font-size: 1.05rem;
    cursor: pointer;
    place-items: center;
    transition:
        transform 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        background 0.2s ease;
}
.cad-toolbar button:hover,
.cad-toolbar button.active {
    transform: translateY(-1px);
    color: #e8fbff;
    border-color: rgba(46, 196, 255, 0.38);
    background: rgba(46, 196, 255, 0.11);
    box-shadow: 0 0 16px rgba(46, 196, 255, 0.1);
}
/* ---------- Main drawing panel ---------- */
.drawing-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(132, 215, 248, 0.2);
    border-radius: 14px;
    background: #061521;
    box-shadow:
        0 22px 65px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
/* ---------- Top drawing toolbar ---------- */
.drawing-panel > .drawing-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 58px;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(128, 211, 247, 0.15);
    background: rgba(13, 38, 58, 0.92);
}
.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 9px;
}
.toolbar-left button,
.toolbar-right button {
    min-height: 32px;
    padding: 6px 10px;
    color: #b8d9e8;
    border: 1px solid rgba(136, 213, 247, 0.18);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.72rem;
    cursor: pointer;
    transition: 0.2s ease;
}
.toolbar-left button {
    display: grid;
    width: 32px;
    padding: 0;
    color: #dff7ff;
    font-size: 1.1rem;
    place-items: center;
}
.toolbar-left button:hover,
.toolbar-right button:hover {
    color: #ffffff;
    border-color: rgba(46, 196, 255, 0.5);
    background: rgba(46, 196, 255, 0.11);
}
#zoomSlider {
    width: 115px;
    height: 4px;
    margin: 0 2px;
    accent-color: var(--cyan);
    cursor: pointer;
}
#zoomValue {
    min-width: 43px;
    color: #a9c9d8;
    font-family: "Courier New", monospace;
    font-size: 0.72rem;
    text-align: right;
}
/* ---------- Drawing viewport ---------- */
.drawing-window {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 545px;
    overflow: hidden;
    background: #06131f;
}
.grid-background {
    position: absolute;
    top: 28px;
    right: 0;
    bottom: 0;
    left: 28px;
    background-color: #081b2a;
    background-image:
        linear-gradient(rgba(74, 186, 232, 0.075) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 186, 232, 0.075) 1px, transparent 1px),
        linear-gradient(rgba(74, 186, 232, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 186, 232, 0.035) 1px, transparent 1px);
    background-size:
        32px 32px,
        32px 32px,
        8px 8px,
        8px 8px;
    pointer-events: none;
}
/* ---------- Rulers ---------- */
.ruler {
    position: absolute;
    z-index: 3;
    overflow: hidden;
    background: #0b2638;
}
.ruler-top {
    top: 0;
    right: 0;
    left: 28px;
    height: 28px;
    border-bottom: 1px solid rgba(133, 211, 244, 0.21);
}
.ruler-left {
    top: 28px;
    bottom: 0;
    left: 0;
    width: 28px;
    border-right: 1px solid rgba(133, 211, 244, 0.21);
}
.ruler-top::before {
    position: absolute;
    top: 0;
    left: -28px;
    width: 28px;
    height: 28px;
    content: "";
    border-right: 1px solid rgba(133, 211, 244, 0.21);
    border-bottom: 1px solid rgba(133, 211, 244, 0.21);
    background: #081d2d;
}
.ruler-top .ticks {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(145, 218, 246, 0.58) 0 1px,
            transparent 1px 16px,
            rgba(145, 218, 246, 0.4) 16px 17px,
            transparent 17px 32px
        );
    mask-image: linear-gradient(
        to bottom,
        transparent 0 42%,
        #000 42% 100%
    );
}
.ruler-left .ticks {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(145, 218, 246, 0.58) 0 1px,
            transparent 1px 16px,
            rgba(145, 218, 246, 0.4) 16px 17px,
            transparent 17px 32px
        );
    mask-image: linear-gradient(
        to right,
        transparent 0 42%,
        #000 42% 100%
    );
}
/* ---------- SVG drawing surface ---------- */
.svg-container {
    position: relative;
    z-index: 2;
    display: grid;
    flex: 1;
    min-width: 0;
    margin: 28px 0 0 28px;
    padding: 30px;
    overflow: auto;
    place-items: center;
}
#drawingCanvas {
    width: min(100%, 920px);
    height: auto;
    min-height: 430px;
    overflow: visible;
    border: 1px solid rgba(123, 213, 249, 0.2);
    background: #0b2332;
    box-shadow:
        0 20px 48px rgba(0, 0, 0, 0.32),
        0 0 30px rgba(46, 196, 255, 0.05);
}
/* ---------- Status bar ---------- */
.status-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    min-height: 38px;
    padding: 0 14px;
    color: #7ea1b1;
    border-top: 1px solid rgba(128, 211, 247, 0.13);
    background: #092133;
    font-family: "Courier New", monospace;
    font-size: 0.67rem;
}
.status-bar > div {
    padding: 0 14px;
    border-right: 1px solid rgba(132, 207, 240, 0.15);
}
.status-bar > div:first-child {
    padding-left: 0;
}
.status-bar strong,
.status-bar span {
    color: #c9ebf8;
    font-weight: 600;
}
/* ---------- CAD right sidebar ---------- */
.drawing-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.drawing-sidebar .glass-card {
    padding: 19px;
    border-radius: 13px;
}
.drawing-sidebar .glass-card h3 {
    margin-bottom: 16px;
    font-size: 0.88rem;
}
/* ---------- Layer controls ---------- */
.layer-list {
    display: grid;
    gap: 11px;
}
.layer-list label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #aecbd8;
    font-size: 0.73rem;
    cursor: pointer;
}
.layer-list input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--cyan);
    cursor: pointer;
}
/* ---------- Sidebar tables ---------- */
.drawing-info td,
.object-properties td {
    padding: 9px 0;
    border-bottom: 1px solid rgba(132, 211, 244, 0.1);
    color: #8baab9;
    font-size: 0.71rem;
}
.drawing-info tr:last-child td,
.object-properties tr:last-child td {
    border-bottom: 0;
}
.drawing-info td:last-child,
.object-properties td:last-child {
    color: #d8f0f9;
    font-weight: 500;
    text-align: right;
}
/* ---------- Generation progress ---------- */
.progress-wrapper {
    width: 100%;
    height: 7px;
    margin: 15px 0 15px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(3, 15, 26, 0.7);
}
.progress-bar {
    width: 62%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    box-shadow: 0 0 12px rgba(46, 196, 255, 0.45);
}
.progress-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    color: #90b1c0;
    font-size: 0.7rem;
    line-height: 1.35;
    list-style: none;
}
.progress-list li:nth-child(-n + 2) {
    color: #90edb9;
}
.progress-list li:nth-child(3) {
    color: #f7c978;
}
/* ---------- Responsive CAD section ---------- */
@media (max-width: 1180px) {
    .cad-workspace {
        padding: 88px 4%;
    }
    .cad-layout {
        grid-template-columns: 58px minmax(0, 1fr);
    }
    .drawing-sidebar {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .drawing-sidebar .glass-card:last-child {
        grid-column: 1 / -1;
    }
}
@media (max-width: 760px) {
    .cad-workspace {
        padding: 72px 22px;
    }
    .cad-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .cad-toolbar {
        display: grid;
        grid-template-columns: repeat(8, 1fr);
        width: 100%;
        padding: 8px;
    }
    .cad-toolbar::after {
        display: none;
    }
    .cad-toolbar button {
        width: 100%;
        height: 38px;
        font-size: 0.92rem;
    }
    .drawing-panel > .drawing-toolbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        overflow-x: auto;
    }
    .toolbar-right {
        padding-bottom: 2px;
    }
    #zoomSlider {
        flex: 1;
        min-width: 85px;
    }
    .drawing-window {
        min-height: 390px;
    }
    .svg-container {
        padding: 16px;
    }
    #drawingCanvas {
        min-width: 600px;
        min-height: 340px;
    }
    .status-bar {
        gap: 7px 0;
        padding: 8px 12px;
        font-size: 0.61rem;
    }
    .status-bar > div {
        padding: 0 9px;
    }
    .drawing-sidebar {
        display: flex;
    }
}
@media (max-width: 460px) {
    .cad-toolbar {
        grid-template-columns: repeat(4, 1fr);
    }
    .toolbar-right button {
        white-space: nowrap;
    }
    .drawing-window {
        min-height: 340px;
    }
    .drawing-sidebar .glass-card {
        padding: 17px;
    }
}
