/* ============================================
   CUBIC METER CALCULATOR PRO - CSS
   Version 1.0
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

.cbf-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.cbf-wrap {
    --blue:        #0D9488;
    --darkblue:    #0F2A3D;
    --cyan:        #14B8A6;
    --amber:       #E8A33D;
    --red:         #E0554F;
    --grad:        #0D9488;
    --grad-soft:   rgba(13,148,136,0.08);
    --white:       #FFFFFF;
    --bg:          #F2F7F6;
    --card-bg:     #FFFFFF;
    --border:      rgba(13,148,136,0.14);
    --text:        #0F2A3D;
    --text-muted:  #5C7A80;
    --shadow-card: 0 32px 80px rgba(15,42,61,0.16), 0 8px 24px rgba(13,148,136,0.10);
    --shadow-btn:  0 12px 32px rgba(13,148,136,0.40);
    --radius-xl:   24px;
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;
    font-family: 'Inter', sans-serif;
    position: relative;
    padding: 32px 20px 60px;
    background: var(--bg);
    min-height: 100%;
    color: var(--text);
}

.cbf-blob { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: 0; }
.cbf-blob-1 { width: 380px; height: 380px; background: rgba(13,148,136,0.13); top: -100px; left: -100px; }
.cbf-blob-2 { width: 320px; height: 320px; background: rgba(15,42,61,0.08); bottom: 0; right: -100px; }

.cbf-card { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; }

/* ---- Header ---- */
.cbf-header { background: var(--grad); border-radius: var(--radius-xl); padding: 26px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-card); margin-bottom: 20px; }
.cbf-header::after { content: ''; position: absolute; width: 260px; height: 260px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -100px; right: -60px; }
.cbf-header-left { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.cbf-header-icon { width: 50px; height: 50px; background: rgba(255,255,255,0.18); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); }
.cbf-header-text h1 { color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -0.4px; }
.cbf-header-text p { color: rgba(255,255,255,0.78); font-size: 12px; margin-top: 4px; }
.cbf-icon-btn { width: 40px; height: 40px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; z-index: 1; transition: background 0.2s; }
.cbf-icon-btn:hover { background: rgba(255,255,255,0.26); }

/* ---- History panel ---- */
.cbf-history-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.cbf-history-panel.cbf-history-open { max-height: 420px; overflow-y: auto; margin-bottom: 20px; }
.cbf-history-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; font-size: 13px; font-weight: 800; color: var(--text); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg); }
.cbf-history-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.cbf-history-list { padding: 14px 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.cbf-history-empty { font-size: 13px; color: var(--text-muted); padding: 20px 0; text-align: center; }
.cbf-history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; }
.cbf-history-item-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.cbf-history-item-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.cbf-history-item-btn { border: 1.5px solid var(--border); background: var(--white); color: var(--red); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 700; border-radius: 7px; padding: 6px 11px; cursor: pointer; flex-shrink: 0; }

/* ---- Explainer ---- */
.cbf-explainer { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden; }
.cbf-explainer-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--grad-soft); border: none; cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--text); font-family: 'Inter', sans-serif; }
.cbf-explainer-toggle svg { color: var(--blue); transition: transform 0.25s ease; flex-shrink: 0; }
#cbf_explainer_arrow.cbf-explainer-arrow-open { transform: rotate(180deg); }
.cbf-explainer-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; padding: 0 24px; }
.cbf-explainer-body.cbf-explainer-open { max-height: 320px; padding: 16px 24px; }
.cbf-explainer-body p { font-size: 12.5px; color: var(--text-muted); line-height: 1.65; margin-bottom: 10px; }
.cbf-explainer-body p:last-child { margin-bottom: 0; }
.cbf-explainer-body strong { color: var(--text); }

/* ---- Mode tabs ---- */
.cbf-mode-tabs { display: flex; gap: 8px; margin-bottom: 20px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px; box-shadow: var(--shadow-card); }
.cbf-mode-tab { flex: 1; background: none; border: none; color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700; border-radius: var(--radius-md); padding: 12px; cursor: pointer; transition: all 0.15s; }
.cbf-mode-tab:hover { color: var(--blue); }
.cbf-mode-tab.cbf-mode-active { background: var(--grad); color: #fff; }

.cbf-mode-panel { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; margin-bottom: 20px; }

/* ---- Shape picker ---- */
.cbf-shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cbf-shape-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 12px 6px; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 10.5px; font-weight: 700; color: var(--text-muted); transition: all 0.15s; }
.cbf-shape-btn svg { width: 26px; height: 26px; }
.cbf-shape-btn:hover { border-color: var(--blue); color: var(--blue); }
.cbf-shape-btn.cbf-shape-active { background: var(--grad-soft); border-color: var(--blue); color: var(--blue); }

/* ---- Custom polygon editor ---- */
.cbf-poly-editor { grid-column: 1 / -1; }
.cbf-poly-count-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cbf-poly-count-row span { font-size: 12.5px; font-weight: 700; color: var(--text); text-transform: none; }
.cbf-poly-sides-select { width: auto; min-width: 70px; }
.cbf-poly-sides { display: flex; flex-direction: column; gap: 8px; }
.cbf-poly-side-row { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.cbf-poly-side-num { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.cbf-poly-hint { margin-top: 10px; margin-bottom: 0; }

/* ---- Fields ---- */
.cbf-field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.cbf-field { margin-bottom: 16px; }
.cbf-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.4px; }
.cbf-hint-inline { text-transform: none; font-weight: 500; opacity: 0.75; font-size: 11px; }
.cbf-input, .cbf-plain-input {
    width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 11px 12px; font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600; color: var(--text);
    background: var(--white); outline: none; transition: border-color 0.2s;
}
.cbf-input:focus, .cbf-plain-input:focus { border-color: var(--blue); }

.cbf-unit-input-wrap { display: flex; gap: 6px; }
.cbf-unit-input-wrap .cbf-plain-input { flex: 1; min-width: 0; }
.cbf-unit-select { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 11px 8px; font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--text); background: var(--white); outline: none; cursor: pointer; flex-shrink: 0; }
.cbf-unit-static { display: flex; align-items: center; padding: 0 12px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); background: var(--bg); border-radius: var(--radius-sm); border: 1.5px solid var(--border); flex-shrink: 0; white-space: nowrap; }

.cbf-dims-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 4px; }

/* ---- Diagram ---- */
.cbf-diagram-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-top: 10px; }
.cbf-diagram-wrap { display: flex; justify-content: center; }
.cbf-diagram-wrap svg { max-width: 100%; height: auto; }

/* ---- Multi-room rows ---- */
.cbf-multi-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.cbf-multi-row { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; }
.cbf-multi-row-head { display: grid; grid-template-columns: 1.3fr 1.3fr 34px; gap: 8px; align-items: center; margin-bottom: 10px; }
.cbf-multi-dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.cbf-row-remove { width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(224,85,79,0.10); color: var(--red); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cbf-add-row-btn { width: 100%; background: var(--white); border: 2px dashed var(--border); color: var(--blue); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700; border-radius: var(--radius-md); padding: 12px; cursor: pointer; }
.cbf-add-row-btn:hover { background: var(--grad-soft); }

/* ---- Result ---- */
.cbf-result { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; }
.cbf-result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cbf-result-badge { font-size: 13px; font-weight: 800; color: var(--text); }
.cbf-input-recap { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.cbf-input-recap:empty { display: none; margin: 0; }

.cbf-due-card { background: var(--grad); border-radius: var(--radius-lg); padding: 22px; text-align: center; margin-bottom: 16px; position: relative; overflow: hidden; }
.cbf-due-card::after { content: ''; position: absolute; width: 160px; height: 160px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -70px; right: -50px; }
.cbf-due-label { color: rgba(255,255,255,0.8); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; position: relative; }
.cbf-due-value { color: #fff; font-size: 32px; font-weight: 900; letter-spacing: -0.5px; margin: 6px 0; position: relative; word-break: break-word; }
.cbf-due-sub { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; position: relative; }

.cbf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.cbf-stats:empty { display: none; margin-bottom: 0; }
.cbf-stat-card { background: var(--bg); border-radius: var(--radius-md); padding: 14px; text-align: center; border: 1px solid var(--border); }
.cbf-stat-icon { font-size: 16px; margin-bottom: 4px; }
.cbf-stat-value { font-size: 15.5px; font-weight: 800; color: var(--text); word-break: break-word; }
.cbf-stat-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }

.cbf-breakdown-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.cbf-breakdown-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.cbf-table-wrap { overflow-x: auto; }
.cbf-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cbf-table th { text-align: left; font-weight: 700; color: var(--text-muted); padding: 6px 8px; border-bottom: 1.5px solid var(--border); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.cbf-table td { padding: 8px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 600; white-space: nowrap; }
.cbf-table tr:last-child td { border-bottom: none; }
.cbf-table tr.cbf-table-total td { font-weight: 800; color: var(--blue); border-top: 2px solid var(--border); }

.cbf-actions-row { margin-bottom: 10px; }
.cbf-save-btn { width: 100%; background: var(--grad); color: #fff; border: none; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 800; border-radius: var(--radius-md); padding: 14px; cursor: pointer; box-shadow: var(--shadow-btn); }
.cbf-export-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.cbf-export-btn { background: var(--white); border: 1.5px solid var(--border); color: var(--text); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); padding: 11px 6px; cursor: pointer; }
.cbf-export-btn:hover { border-color: var(--blue); color: var(--blue); }

.cbf-footer-note { font-size: 10.5px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* ---- Multi-product dims grid (4 fields per row) ---- */
.cbf-multi-dims-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cbf-multi-dims-grid .cbf-field { margin-bottom: 0; }
.cbf-multi-row-head { display: grid; grid-template-columns: 1fr 34px; gap: 8px; align-items: center; margin-bottom: 10px; }

/* ---- Radio row group (fit / cost volume source) ---- */
.cbf-radio-row-group { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.cbf-radio-inline { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.cbf-radio-inline input { accent-color: var(--blue); width: 15px; height: 15px; cursor: pointer; }

/* ---- Fit-check gauge ---- */
.cbf-fit-gauge { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 14px; }
.cbf-fit-gauge-track { width: 100%; height: 10px; border-radius: 100px; background: var(--border); overflow: hidden; margin-top: 8px; }
.cbf-fit-gauge-fill { height: 100%; border-radius: 100px; background: var(--grad); transition: width 0.3s ease; }
.cbf-fit-gauge-fill.cbf-fit-over { background: var(--red); }
.cbf-fit-gauge-label { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 700; color: var(--text-muted); }

/* ---- Sub-tabs (Multi-Product: Simple / Shipping & Freight) ---- */
.cbf-subtabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 4px; }
.cbf-subtab { flex: 1; background: none; border: none; color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 700; border-radius: var(--radius-sm); padding: 9px; cursor: pointer; transition: all 0.15s; }
.cbf-subtab:hover { color: var(--blue); }
.cbf-subtab.cbf-subtab-active { background: var(--white); color: var(--blue); box-shadow: 0 2px 6px rgba(13,148,136,0.15); }

/* ---- Advanced mode: quick container-fit preview ---- */
.cbf-quickfit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.cbf-quickfit-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.cbf-quickfit-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.cbf-quickfit-value { font-size: 14px; font-weight: 800; color: var(--blue); }

/* ---- Multi-product: per-row result + freight fields ---- */
.cbf-multi-freight-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
.cbf-multi-row-result { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 12.5px; font-weight: 700; color: var(--blue); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.cbf-multi-row-result:empty { display: none; margin: 0; padding: 0; border: none; }
.cbf-multi-row-result span.cbf-row-result-sub { color: var(--text-muted); font-weight: 500; font-size: 11.5px; }
.cbf-multi-grand-total { margin-top: 4px; }

/* ---- Responsive ---- */
@media (max-width: 780px) {
    .cbf-field-grid, .cbf-dims-grid { grid-template-columns: 1fr; }
    .cbf-shape-grid { grid-template-columns: repeat(3, 1fr); }
    .cbf-stats { grid-template-columns: 1fr 1fr; }
    .cbf-multi-dims-grid { grid-template-columns: 1fr 1fr; }
    .cbf-radio-row-group { flex-direction: column; gap: 10px; }
    .cbf-mode-tabs { flex-wrap: wrap; }
    .cbf-mode-tab { flex: 1 1 45%; }
    .cbf-quickfit-grid { grid-template-columns: 1fr 1fr; }
}
