/* ============================================================
   Scoped Styles — Tank Volume & Capacity Estimator (.tk- prefix)
   ============================================================ */

.tk-calc-wrapper {
    --tk-brand:        var(--color-brand, #f97316);
    --tk-brand-d:      #ea580c;
    --tk-bg:           var(--color-bg-main, #f8fafc);
    --tk-surface:      var(--color-bg-card, #ffffff);
    --tk-border:       var(--color-border, #e2e8f0);
    --tk-text:         var(--color-text-primary, #0f172a);
    --tk-muted:        var(--color-text-secondary, #64748b);
    --tk-radius:       10px;
    --tk-shadow:       0 1px 4px rgba(0,0,0,.07);
    --tk-success:      #16a34a;
    --tk-danger:       #dc2626;

    width: 100%;
    box-sizing: border-box;
    color: var(--tk-text);
}

.tk-calc-wrapper *,
.tk-calc-wrapper *::before,
.tk-calc-wrapper *::after { box-sizing: border-box; }

.tk-calc-wrapper .back-btn { margin-bottom: 16px; }

/* ======================================================
   MODE & SHAPE TABS
   ====================================================== */
.tk-tabs-nav {
    display: inline-flex;
    gap: 4px;
    background: var(--tk-bg);
    border: 1px solid var(--tk-border);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.tk-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--tk-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background .18s, color .18s, box-shadow .18s;
}
.tk-tab-btn svg { width: 14px; height: 14px; }
.tk-tab-btn.active {
    background: var(--tk-surface);
    color: var(--tk-brand);
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* ======================================================
   LAYOUT OVERRIDES
   ====================================================== */
.tk-calc-wrapper .calc-layout {
    width: 100%;
    min-width: 0;
}
.tk-calc-wrapper .calc-panel {
    min-width: 0;
    overflow: hidden;
}

.tk-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tk-muted);
    margin: 22px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--tk-border);
}

/* ======================================================
   FORM INPUTS
   ====================================================== */
.tk-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.tk-fg {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tk-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--tk-text);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tk-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
}

.tk-input {
    width: 100%;
    padding: 8px 36px 8px 10px;
    background: var(--tk-bg);
    border: 1px solid var(--tk-border);
    color: var(--tk-text);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 7px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.tk-input:focus {
    border-color: var(--tk-brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.tk-input[type="number"] { padding-right: 36px; }
select.tk-input { padding-right: 28px; cursor: pointer; }

.tk-unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--tk-muted);
    pointer-events: none;
}

.tk-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    pointer-events: none;
    stroke: var(--tk-muted);
    flex-shrink: 0;
}

/* ======================================================
   CARDS & COLLAPSE
   ====================================================== */
.tk-card {
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--tk-shadow);
    background: var(--tk-surface);
}

.tk-card-head {
    width: 100%;
    padding: 12px 16px;
    background: var(--tk-bg);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tk-text);
    transition: background .15s;
    text-align: left;
}
.tk-card-head:hover { background: var(--tk-border); }
.tk-card-head svg {
    width: 16px; height: 16px;
    stroke: var(--tk-muted);
    transition: transform .2s;
}
.tk-card.open .tk-card-head svg { transform: rotate(180deg); }

.tk-card-body {
    display: none;
    padding: 14px;
    border-top: 1px solid var(--tk-border);
}
.tk-card.open .tk-card-body { display: block; }

/* ======================================================
   TABLES
   ====================================================== */
.tk-tbl-wrap {
    overflow-x: auto;
    border: 1px solid var(--tk-border);
    border-radius: 8px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.tk-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
}
.tk-tbl th, .tk-tbl td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--tk-border);
    text-align: left;
}
.tk-tbl th {
    background: var(--tk-bg);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--tk-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.tk-tbl tbody tr:hover td { background: rgba(249,115,22,.04); }

.tk-tbl input {
    width: 100%;
    min-width: 60px;
    padding: 4px 6px;
    background: var(--tk-bg);
    border: 1px solid transparent;
    color: var(--tk-text);
    font-size: 0.8rem;
    border-radius: 4px;
    outline: none;
}
.tk-tbl input:focus { border-color: var(--tk-brand); }

/* ======================================================
   BUTTONS
   ====================================================== */
.tk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    white-space: nowrap;
}
.tk-btn svg { width: 14px; height: 14px; }
.tk-btn-primary { background: var(--tk-brand); color: #fff; }
.tk-btn-primary:hover { background: var(--tk-brand-d); }
.tk-btn-secondary { background: var(--tk-bg); border-color: var(--tk-border); color: var(--tk-text); }
.tk-btn-secondary:hover { background: var(--tk-border); }
.tk-btn-ghost {
    background: transparent;
    border: 1px dashed var(--tk-brand);
    color: var(--tk-brand);
    width: 100%;
    padding: 6px;
    font-size: 0.8rem;
}
.tk-btn-ghost:hover { background: rgba(249,115,22,.04); }
.tk-btn-del {
    background: transparent;
    border: none;
    color: var(--tk-danger);
    cursor: pointer;
    padding: 2px 4px;
}
.tk-btn-del:hover { background: rgba(220,38,38,.08); border-radius: 4px; }

.tk-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.tk-actions .tk-btn { flex: 1; min-width: 100px; }

/* ======================================================
   RESULTS & KPIS
   ====================================================== */
.tk-res-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--tk-border);
}
.tk-res-header h2 { margin: 0; font-size: 1rem; font-weight: 700; }

.tk-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.tk-kpi {
    background: var(--tk-surface);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--tk-shadow);
}
.tk-kpi.accent { border-left: 4px solid var(--tk-brand); }
.tk-kpi-label { font-size: 0.72rem; font-weight: 600; color: var(--tk-muted); }
.tk-kpi-val   { font-size: 1.3rem; font-weight: 700; color: var(--tk-text); }
.tk-kpi-unit  { font-size: 0.7rem; color: var(--tk-muted); }
.tk-kpi.accent .tk-kpi-val { color: var(--tk-brand); }

/* ======================================================
   VISUAL TANK LEVEL INDICATOR
   ====================================================== */
.tk-visual-container {
    background: var(--tk-bg);
    border: 2px solid var(--tk-border);
    border-radius: var(--tk-radius);
    height: 140px;
    position: relative;
    margin: 15px 0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}
.tk-visual-liquid {
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
    width: 100%;
    height: 0%;
    transition: height 0.6s ease-out;
    position: relative;
}
.tk-visual-bubble {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    z-index: 10;
}
.tk-visual-fb-label {
    position: absolute;
    top: 5px;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--tk-muted);
}

/* Shape specific outlines helper class */
.tk-shape-outline-spherical { border-radius: 50%; width: 140px; margin: 15px auto; }
.tk-shape-outline-hemispherical { border-radius: 0 0 70px 70px; width: 140px; margin: 15px auto; }

/* Formulas step breakdown */
.tk-step {
    background: var(--tk-bg);
    border-left: 3px solid var(--tk-brand);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 8px;
    font-size: 0.8rem;
}
.tk-step-title { font-weight: 700; }
.tk-step-formula { font-family: monospace; color: var(--tk-brand-d); font-size: 0.82rem; }
.tk-step-result  { font-size: 0.75rem; color: var(--tk-muted); margin-top: 2px; }

.tk-export {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 15px;
    border-top: 1px solid var(--tk-border);
    padding-top: 12px;
}

.tk-empty {
    text-align: center;
    padding: 36px 12px;
    color: var(--tk-muted);
}
.tk-empty svg { width: 36px; height: 36px; margin-bottom: 10px; stroke: var(--tk-border); }

/* ======================================================
   RESPONSIVE TWEAKS
   ====================================================== */
@media (max-width: 900px) {
    .tk-calc-wrapper .calc-layout {
        flex-direction: column !important;
    }
    .tk-calc-wrapper .calc-panel { width: 100% !important; }
}

@media (max-width: 560px) {
    .tk-row { grid-template-columns: 1fr; }
    .tk-kpis { grid-template-columns: 1fr 1fr; }
    .tk-actions { flex-direction: column; }
    
    .tk-tbl, .tk-tbl thead, .tk-tbl tbody,
    .tk-tbl th, .tk-tbl td, .tk-tbl tr { display: block; }
    .tk-tbl thead tr { position: absolute; top:-9999px; left:-9999px; }
    .tk-tbl tbody tr {
        border: 1px solid var(--tk-border);
        border-radius: 8px;
        margin-bottom: 8px;
        background: var(--tk-surface);
        overflow: hidden;
    }
    .tk-tbl td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 10px;
        border-bottom: 1px solid var(--tk-border);
    }
    .tk-tbl td:last-child { border-bottom: none; }
    .tk-tbl td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: var(--tk-muted);
        margin-bottom: 2px;
    }
}
