/*
    layout_style.css — macroBIM 공통 스타일
    GitHub에서 관리, PHP에서 <link>로 로드
*/

*{margin:0;padding:0;box-sizing:border-box;}
body{font-family:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;background:#f0f2f5;color:#444;display:flex;height:100vh;overflow:hidden;font-size:14px;padding:16px;gap:16px;}

/* ── APP ROOT (layout_body.js 사용 시) ── */
#app-root{display:flex;flex:1;height:100%;min-height:0;gap:16px;overflow:hidden;}

/* ── SIDEBAR ── */
#sidebar{width:270px;min-width:270px;background:#fff;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;}
#sidebar::-webkit-scrollbar{width:4px;}
#sidebar::-webkit-scrollbar-thumb{background:#ddd;border-radius:4px;}
.sidebar-header{display:flex;align-items:center;gap:12px;padding:20px 20px 16px;}
.logo-info .name{font-size:15px;font-weight:700;color:#0f172a;}
.nav-menu{padding:4px 12px;flex:1;}
.nav-item{display:flex;align-items:center;gap:10px;padding:9px 12px;font-size:13.5px;font-weight:500;color:#64748b;cursor:pointer;border-radius:6px;margin-bottom:1px;text-decoration:none;transition:all .15s;}
.nav-item:hover{background:#f1f5f9;color:#334155;}
.nav-item.active{background:#eff6ff;color:#2563eb;}
.nav-item i{font-size:17px;width:22px;text-align:center;flex-shrink:0;}
.nav-item .arrow{margin-left:auto;font-size:11px;color:#94a3b8;transition:transform .2s;}
.nav-item.open .arrow{transform:rotate(90deg);}
.nav-section{font-size:10px;font-weight:600;letter-spacing:1.5px;color:#94a3b8;text-transform:uppercase;padding:18px 12px 8px;}
.nav-sub{display:none;padding-left:22px;}
.nav-sub.show{display:block;}
.nav-sub a{display:flex;align-items:center;gap:8px;padding:7px 12px;font-size:13px;font-weight:400;color:#94a3b8;text-decoration:none;border-radius:6px;transition:all .15s;position:relative;}
.nav-sub a::before{content:'';width:5px;height:5px;border-radius:50%;background:#cbd5e1;flex-shrink:0;transition:background .15s;}
.nav-sub a:hover{color:#334155;}
.nav-sub a:hover::before{background:#64748b;}
.nav-sub a.active{color:#2563eb;font-weight:500;}
.nav-sub a.active::before{background:#2563eb;}

/* ── MAIN ── */
#main{flex:1;display:flex;flex-direction:column;overflow:hidden;}
.content-wrap{flex:1;overflow-y:auto;background:#fff;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);padding:24px;}
.content-wrap::-webkit-scrollbar{width:6px;}
.content-wrap::-webkit-scrollbar-thumb{background:#ddd;border-radius:4px;}

.page-view{display:none;}
.page-view.active{display:block;}

/* ── COMMON ── */
.page-heading{font-size:22px;font-weight:700;color:#0f172a;margin-bottom:4px;}
.breadcrumb{font-size:13px;color:#94a3b8;margin-bottom:24px;}
.breadcrumb a{color:#94a3b8;text-decoration:none;}
.breadcrumb a:hover{color:#2563eb;}
.breadcrumb span{color:#64748b;}
.table-card{background:#fff;border-radius:10px;border:1px solid #e2e8f0;margin-bottom:20px;overflow:hidden;}
.table-card-header{display:flex;justify-content:space-between;align-items:center;padding:13px 16px;border-bottom:1px solid #e2e8f0;background:#f1f5f9;}
.table-card-title{font-size:15px;font-weight:600;color:#0f172a;display:flex;align-items:center;}
.table-card-title::before{content:'';display:inline-block;width:4px;height:15px;border-radius:2px;background:#2563eb;margin-right:9px;flex-shrink:0;}
.table-card-desc{font-size:12.5px;color:#94a3b8;}

/* ── REBAR TABLE ── */
.ea-table{width:100%;border-collapse:collapse;font-size:13.5px;}
.ea-table.striped tbody tr:nth-child(even){background:#fafbfc;}
.ea-table.striped tbody tr:hover{background:#f1f5f9;}
.ea-table.rebar thead th{background:#1e293b;color:#fff;font-size:12px;font-weight:600;text-transform:none;letter-spacing:0;border-bottom:1px solid #334155;padding:12px 16px;text-align:center;}
.ea-table.rebar tbody td{text-align:center;padding:12px 16px;font-size:13px;border-bottom:1px solid #f1f5f9;color:#475569;}
.ea-table.rebar tbody td:nth-child(1){font-weight:700;color:#0f172a;background:#f8fafc;}
.ea-table.rebar tbody tr:last-child td{border-bottom:none;}

/* ── STEEL SECTION ── */
.section-selector-row{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:24px;}
.section-card{border:2px solid #e2e8f0;border-radius:12px;padding:16px;cursor:pointer;transition:all .2s;display:flex;flex-direction:column;align-items:center;gap:10px;background:#fff;position:relative;overflow:hidden;}
.section-card:hover{border-color:#94a3b8;box-shadow:0 4px 12px rgba(0,0,0,.08);}
.section-card.selected{border-color:#2563eb;background:#eff6ff;box-shadow:0 4px 16px rgba(37,99,235,.15);}
.section-card.selected::after{content:'';position:absolute;top:0;left:0;right:0;height:3px;background:#2563eb;border-radius:12px 12px 0 0;}
.section-card-img{width:100%;height:100px;display:flex;align-items:center;justify-content:center;background:#f8fafc;border-radius:8px;overflow:hidden;}
.section-card-img img{max-width:90%;max-height:90%;object-fit:contain;}
.section-card-name{font-size:13px;font-weight:600;color:#0f172a;text-align:center;}

/* Name-only selector. The dimension drawing lives once, in the figure band
   below, so the cards go back to being what they always were: the row you
   pick a type from. Kept as a modifier rather than an edit to .section-card,
   because layout_body.js still ships the thumbnail variant of the same card. */
.section-selector-row.chips{grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:10px;margin-bottom:14px;}
.section-selector-row.chips .section-card{padding:12px 10px;gap:0;justify-content:center;}

.steel-table-wrap{overflow-x:auto;border-radius:10px;border:1px solid #e2e8f0;}
.steel-table-wrap::-webkit-scrollbar{height:6px;}
.steel-table-wrap::-webkit-scrollbar-thumb{background:#ccc;border-radius:4px;}
.steel-table{width:100%;border-collapse:collapse;font-size:12.5px;min-width:900px;}
.steel-table thead th{background:#1e293b;color:#fff;font-size:11px;font-weight:600;padding:10px 12px;text-align:center;border-right:1px solid #334155;border-bottom:1px solid #334155;white-space:nowrap;position:sticky;top:0;z-index:10;}
.steel-table thead th:last-child{border-right:none;}
.steel-table tbody td{padding:10px 12px;text-align:center;color:#475569;font-size:12px;border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9;white-space:nowrap;}
.steel-table tbody td:last-child{border-right:none;}
.steel-table tbody td:first-child{font-weight:700;color:#0f172a;background:#f8fafc;position:sticky;left:0;z-index:5;}
.steel-table tbody tr:nth-child(even){background:#fafbfc;}
.steel-table tbody tr:nth-child(even) td:first-child{background:#f1f5f9;}
.steel-table tbody tr{transition:background .12s;}
.steel-table tbody tr:hover{background:#eef2ff !important;}
.steel-table tbody tr:hover td:first-child{background:#e0e7ff !important;}
.steel-table tbody tr:last-child td{border-bottom:none;}

/* ── DRAWING PAGE ── */
.draw-card{background:#fff;border-radius:10px;border:1px solid #e2e8f0;margin-bottom:20px;overflow:hidden;}
.draw-card-header{display:flex;justify-content:space-between;align-items:center;padding:13px 16px;border-bottom:1px solid #e2e8f0;background:#f1f5f9;}
.draw-card-title{font-size:15px;font-weight:600;color:#0f172a;display:flex;align-items:center;}
.draw-card-title::before{content:'';display:inline-block;width:4px;height:15px;border-radius:2px;background:#2563eb;margin-right:9px;flex-shrink:0;}
.draw-card-desc{font-size:12.5px;color:#94a3b8;}
.draw-card-body{padding:20px;}

.form-grid{display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:16px 24px;}
.form-group{display:flex;flex-direction:column;gap:5px;}
.form-group.full{grid-column:1/-1;}
.form-label{font-size:13px;font-weight:600;color:#0f172a;}
.form-label span{font-weight:400;color:#94a3b8;}
.form-input{
  padding:10px 14px;border:1px solid #e2e8f0;border-radius:8px;
  font-size:13.5px;font-family:inherit;color:#334155;
  transition:border-color .15s,box-shadow .15s;outline:none;
  background:#fff;
}
.form-input:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.1);}
.form-input::placeholder{color:#cbd5e1;}
.btn-generate{
  display:inline-flex;align-items:center;gap:8px;
  padding:10px 24px;border:none;border-radius:8px;cursor:pointer;
  font-size:13.5px;font-weight:600;font-family:inherit;
  background:#1e293b;color:#fff;transition:background .15s;
  margin-top:8px;
}
.btn-generate:hover{background:#334155;}

/* ── DRAWING VIEWPORT (KonvaViewer 컨테이너) ── */
.drawing-viewport{
  background:#1e293b;border-radius:10px;overflow:hidden;
  min-height:560px;
}
#spliceplot{
  width:100%;height:560px;background:#000;border-radius:10px;
  cursor:grab;
}
#hsecplot,#channelplot,#ibeamplot,#box1cellplot,#liftinglugplot,#rectplot,#circleplot,#octagonplot,#trackplot{
  width:100%;background:#000;border-radius:10px;
  cursor:grab;
}

/* ── DASHBOARD STAT CARDS ── */
.stat-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:20px;margin-bottom:24px;}
.stat-card{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:24px;display:flex;align-items:center;justify-content:space-between;box-shadow:0 1px 3px rgba(0,0,0,.04);}
.stat-card .stat-value{font-size:30px;font-weight:700;color:#0f172a;line-height:1.1;}
.stat-card .stat-label{font-size:13.5px;color:#64748b;margin-top:8px;}
.stat-card .stat-icon{width:52px;height:52px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:24px;flex-shrink:0;}
.stat-icon.blue{background:#eff6ff;color:#2563eb;}
.stat-icon.green{background:#ecfdf5;color:#10b981;}
@media(max-width:720px){.stat-grid{grid-template-columns:1fr;}}

/* ── BOX1CELL 9-COLUMN GRID (3 pairs of Variable/Begin/End per row) ── */
.form-grid-9col{display:grid;grid-template-columns:80px 1fr 1fr 80px 1fr 1fr 80px 1fr 1fr;gap:8px 10px;align-items:center;}
.form-grid-9col .col-label{font-size:12px;font-weight:600;color:#0f172a;}
.form-grid-9col .col-header{font-size:11px;font-weight:700;color:#2563eb;text-align:center;padding-bottom:4px;border-bottom:1px solid #e2e8f0;}
.form-grid-9col .col-header.var-header{text-align:left;}
.form-grid-9col .form-input{padding:8px 8px;font-size:12.5px;}

/* ── HSEC / CHANNEL / LIFTINGLUG 6-COLUMN GRID (3 pairs of Variable/Value per row) ── */
.form-grid-6col{display:grid;grid-template-columns:130px 1fr 130px 1fr 130px 1fr;gap:8px 12px;align-items:center;}
.form-grid-6col .col-label{font-size:12px;font-weight:600;color:#0f172a;}
.form-grid-6col .col-header{font-size:11px;font-weight:700;color:#2563eb;text-align:center;padding-bottom:4px;border-bottom:1px solid #e2e8f0;}
.form-grid-6col .col-header.var-header{text-align:left;}
.form-grid-6col .form-input{padding:8px 10px;font-size:12.5px;}

/* ── LOADING / ERROR ── */
.loading-row{text-align:center;padding:40px 20px !important;color:#94a3b8;}
.spinner{display:inline-block;width:18px;height:18px;border:2px solid #e2e8f0;border-top-color:#2563eb;border-radius:50%;animation:spin .6s linear infinite;vertical-align:middle;margin-right:8px;}
@keyframes spin{to{transform:rotate(360deg);}}
.error-msg{text-align:center;padding:30px 20px;color:#dc2626;font-size:13px;}

/* ══ QNA 게시판 ══ */
.qna-wrap{max-width:100%;margin:0 auto;padding:4px 0;}
.qna-toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:12px;flex-wrap:wrap;}
.qna-search-box{display:flex;align-items:center;background:#fff;border:1px solid #e2e8f0;border-radius:8px;padding:0 12px;flex:1;max-width:600px;}
.qna-search-box i{color:#94a3b8;font-size:14px;margin-right:8px;}
.qna-search-box input{border:none;outline:none;padding:10px 0;font-size:13.5px;width:100%;background:transparent;color:#334155;}
.qna-btn{display:inline-flex;align-items:center;gap:6px;padding:9px 16px;border:1px solid #e2e8f0;border-radius:8px;font-size:13px;font-weight:500;cursor:pointer;background:#fff;color:#334155;transition:all .15s;}
.qna-btn:hover{background:#f8fafc;border-color:#cbd5e1;}
.qna-btn-primary{background:#2563eb;color:#fff;border-color:#2563eb;}
.qna-btn-primary:hover{background:#1d4ed8;}
.qna-btn-danger{background:#dc2626;color:#fff;border-color:#dc2626;}
.qna-btn-danger:hover{background:#b91c1c;}
.qna-btn-back{background:transparent;border:none;color:#64748b;padding:6px 0;margin-bottom:12px;}
.qna-btn-back:hover{color:#2563eb;}
.qna-btn-cancel{background:#f1f5f9;color:#64748b;border-color:#e2e8f0;}
.qna-loading{text-align:center;padding:60px 20px;color:#94a3b8;font-size:14px;}
.qna-empty{text-align:center;padding:60px 20px;color:#94a3b8;}
.qna-empty i{font-size:40px;display:block;margin-bottom:12px;}
.qna-accordion{display:flex;flex-direction:column;gap:2px;}
.qna-item{background:#fff;border:1px solid #e2e8f0;border-radius:8px;overflow:hidden;transition:all .15s;}
.qna-item:hover{border-color:#cbd5e1;box-shadow:0 1px 3px rgba(0,0,0,.06);}
.qna-item-header{display:flex;justify-content:space-between;align-items:center;padding:14px 18px;cursor:pointer;gap:12px;}
.qna-item-left{display:flex;align-items:center;gap:8px;flex:1;min-width:0;}
.qna-item-right{display:flex;align-items:center;gap:12px;flex-shrink:0;color:#94a3b8;font-size:12.5px;}
.qna-item-no{color:#94a3b8;font-size:12px;font-weight:600;min-width:32px;}
.qna-item-title{font-weight:500;color:#0f172a;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.qna-item-author,.qna-item-date{white-space:nowrap;}
.qna-chevron{font-size:14px;color:#cbd5e1;transition:transform .15s;}
.qna-badge{display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:4px;font-size:11px;font-weight:600;white-space:nowrap;}
.qna-badge-secret{background:#fef3c7;color:#92400e;}
.qna-badge-answered{background:#d1fae5;color:#065f46;}
.qna-badge-reply{background:#e0e7ff;color:#3730a3;}
.qna-pag{display:flex;justify-content:center;gap:4px;margin-top:16px;}
.qna-pag-btn{padding:7px 12px;border:1px solid #e2e8f0;border-radius:6px;background:#fff;color:#334155;font-size:13px;cursor:pointer;transition:all .15s;}
.qna-pag-btn:hover{background:#f1f5f9;}
.qna-pag-btn.active{background:#2563eb;color:#fff;border-color:#2563eb;}
.qna-view-card{background:#fff;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden;}
.qna-view-header{padding:20px 24px;border-bottom:1px solid #f1f5f9;}
.qna-view-title{font-size:18px;font-weight:700;color:#0f172a;margin-bottom:10px;}
.qna-view-meta{display:flex;align-items:center;gap:14px;color:#94a3b8;font-size:12.5px;flex-wrap:wrap;}
.qna-view-body{padding:24px;}
.qna-view-content{font-size:14px;line-height:1.7;color:#334155;}
.qna-view-image{margin-top:16px;}
.qna-view-image img{max-width:100%;border-radius:8px;border:1px solid #e2e8f0;}
.qna-view-actions{display:flex;gap:8px;padding:16px 24px;border-top:1px solid #f1f5f9;}
.qna-replies-section{margin-top:20px;}
.qna-replies-title{font-size:15px;font-weight:600;color:#0f172a;margin-bottom:12px;display:flex;align-items:center;gap:8px;}
.qna-reply-card{background:#fff;border:1px solid #e2e8f0;border-radius:8px;padding:16px;margin-bottom:8px;}
.qna-reply-header{display:flex;gap:14px;color:#94a3b8;font-size:12.5px;margin-bottom:10px;}
.qna-reply-body{font-size:13.5px;line-height:1.6;color:#334155;}
.qna-reply-actions{margin-top:8px;padding-top:8px;border-top:1px solid #f1f5f9;}
.qna-btn-reply-small{background:transparent;border:1px solid #e2e8f0;color:#64748b;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;display:inline-flex;align-items:center;gap:4px;transition:all .15s;}
.qna-btn-reply-small:hover{background:#f1f5f9;color:#2563eb;border-color:#cbd5e1;}
.qna-form-card{background:#fff;border:1px solid #e2e8f0;border-radius:10px;padding:28px;}
.qna-form-title{font-size:18px;font-weight:700;color:#0f172a;margin-bottom:20px;display:flex;align-items:center;gap:8px;}
.qna-form-row{display:flex;gap:16px;margin-bottom:0;}
.qna-half{flex:1;}
.qna-form-group{margin-bottom:16px;}
.qna-form-group label{display:block;font-size:13px;font-weight:600;color:#334155;margin-bottom:6px;}
.qna-required{color:#dc2626;}
.qna-input{width:100%;padding:10px 14px;border:1px solid #e2e8f0;border-radius:8px;font-size:13.5px;color:#334155;outline:none;transition:border-color .15s;}
.qna-input:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.1);}
.qna-textarea{width:100%;padding:12px 14px;border:1px solid #e2e8f0;border-radius:8px;font-size:13.5px;color:#334155;outline:none;resize:vertical;font-family:inherit;transition:border-color .15s;}
.qna-textarea:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.1);}
.qna-checkbox-label{display:flex;align-items:center;gap:6px;font-size:13px;color:#334155;cursor:pointer;padding:10px 0;}
.qna-form-actions{display:flex;gap:8px;margin-top:8px;}
.qna-contenteditable{width:100%;min-height:200px;padding:12px 14px;border:1px solid #e2e8f0;border-radius:8px;font-size:13.5px;color:#334155;outline:none;font-family:inherit;line-height:1.7;overflow-y:auto;transition:border-color .15s;}
.qna-contenteditable:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.1);}
.qna-contenteditable:empty::before{content:'Write your message here... (Ctrl+V to paste images)';color:#cbd5e1;}
.qna-contenteditable img{max-width:100%;border-radius:6px;margin:8px 0;display:block;}
.qna-view-content img{max-width:100%;border-radius:6px;margin:8px 0;display:block;}
.qna-reply-body img{max-width:100%;border-radius:6px;margin:8px 0;display:block;}
.qna-error{color:#dc2626;font-size:13px;margin-top:10px;}
.qna-list-table{width:100%;border-collapse:collapse;border:1px solid #e2e8f0;border-radius:8px;overflow:hidden;}
.qna-list-table thead th{background:#1e293b;color:#fff;font-size:12px;font-weight:600;padding:11px 16px;text-align:center;border-right:1px solid #334155;}
.qna-list-table thead th:last-child{border-right:none;}
.qna-list-table tbody td{padding:12px 16px;text-align:center;font-size:13px;color:#475569;border-bottom:1px solid #f1f5f9;}
.qna-row:hover td{background:#f8fafc;}
.qna-empty-row{padding:60px 20px !important;color:#94a3b8;font-size:14px;line-height:2;}

/* Steel Section Tables — the dimension drawing above the table */
.steel-fig{display:flex;flex-direction:column;align-items:center;gap:6px;
  background:#f8fafc;border:1px solid #e2e8f0;border-radius:10px;
  padding:14px 12px;margin:0 0 14px;}
/* Sized by width so the drawing scales as a whole: the caption and the
   dimension letters are drawn into the SVG by mk_section_svg.js, and they
   grow with it. Nothing here retypes what the drawing already says. */
.steel-fig img{width:min(340px,100%);height:auto;}
.steel-fig.empty{display:none;}
