/* =====================================================================
 * THEME-MATCHED (updated) — this tool's colors now follow the Myanas
 * theme's own purple/cyan palette (inc/design-tokens.php), by explicit
 * request. Values are stored as "H S% L%" triplets (the format
 * hsl(var(--x)) / Tailwind's CDN config expects), converted 1:1 from
 * the theme's hex tokens:
 *   --background       -> --bg-deep
 *   --foreground        -> --text-primary
 *   --card / --muted    -> --bg-surface / --bg-elevated
 *   --primary           -> --cyan-bright
 *   --accent            -> --coral-bright (the theme's purple accent)
 *   --border / --input  -> derived from --border-subtle's hue, but at a
 *                          higher lightness than the old value so the
 *                          border is actually visible against the very
 *                          dark background (the previous 24% lightness
 *                          was too close to the background's 8%).
 * ===================================================================== */

/* FIX (width/overflow safety net): this tool's Tailwind build has
   Preflight disabled (see electricity-calculator-tailwind.css's header
   comment), so it never got Tailwind's usual global box-sizing reset.
   Any element combining a width utility (w-full, p-4, etc.) with a
   border or padding is therefore sized under the browser's default
   content-box, where border/padding is added ON TOP of the declared
   width instead of inside it -- the same class of bug already found
   and fixed for other tools' inputs/selects in this plugin. Scoped to
   this tool only, so it stays a bug fix, not a redesign of anything
   outside .ashraf-elec-calc. */
.ashraf-elec-calc,
.ashraf-elec-calc *,
.ashraf-elec-calc *::before,
.ashraf-elec-calc *::after {
    box-sizing: border-box;
}

/* FIX (mobile horizontal overflow): CSS Grid items default to
   min-width: auto, meaning a grid child won't shrink below its own
   content's intrinsic width no matter what width utility (w-full etc.)
   is on the element inside it. The unit-input grids (2-col peak/off-peak,
   3-col peak/off-peak/super-off-peak in electricity-calculator.js, and
   the meter-type/load 2-col grid) have no "grid-cols-1" mobile fallback,
   so on narrow phones each <input>/<select>'s native min-content width
   was forcing the whole grid — and the page — wider than the viewport,
   cutting the tool off / creating horizontal scroll. Resetting min-width
   to 0 on every direct grid-item lets them shrink to the track width as
   intended, with no visual change on screens where it already fit. */
.ashraf-elec-calc .grid > * {
    min-width: 0;
}

/* FIX (mobile horizontal overflow, ~5px leftover on the right): the same
   min-width: auto default that affects grid items above also applies to
   Flexbox children, and this tool's rows (name-input/unit-input/badge in
   each .user-row, the summary/result-card rows, the CTA and stat rows,
   etc.) are all built with Tailwind's .flex / .inline-flex, not .grid --
   so the earlier ".grid > *" rule never touched them. Each of those rows
   still had at least one child (typically a text input or label) sized
   to its own min-content width, which on narrow phones pushed the row --
   and the page -- a few px past the viewport. Since the overflow was
   sub-pixel-small it didn't create a visible scrollbar; it just meant
   the page's right edge (and therefore the tool's right padding) started
   a few px past x=viewport-width, so the padding was clipped along with
   it. Resetting min-width to 0 here lets every flex child shrink to fit
   its row instead of forcing the row wider than its container; elements
   that must stay a fixed size (shrink-0, explicit width utilities) are
   unaffected since flex-shrink: 0 already stops them from shrinking. */
.ashraf-elec-calc .flex > *,
.ashraf-elec-calc .inline-flex > * {
    min-width: 0;
}

        /*
         * This block is the dark-mode (default) palette, matching the
         * theme's default state. The light-mode override further down
         * responds to html[data-theme="light"], the same attribute the
         * theme's toggle (myanas_dark_mode_toggle_button) sets.
         */
        .ashraf-elec-calc {
            --background: 231 39% 6%;
            --foreground: 231 47% 97%;
            --card: 231 37% 7%;
            --card-foreground: 231 47% 97%;
            --primary: 188 86% 53%;
            --primary-foreground: 231 39% 6%;
            --accent: 258 90% 66%;
            --accent-foreground: 231 47% 97%;
            --muted: 233 45% 11%;
            --muted-foreground: 234 21% 65%;
            --border: 234 20% 30%;
            --input: 234 24% 34%;
            --ring: 188 86% 53%;
            --radius: 0.75rem;
            color-scheme: dark;
        }
        /* Light mode — mirrors the theme's html[data-theme="light"] palette */
        html[data-theme="light"] .ashraf-elec-calc {
            --background: 240 60% 99%;
            --foreground: 237 37% 12%;
            --card: 0 0% 100%;
            --card-foreground: 237 37% 12%;
            --primary: 192 91% 36%;
            --primary-foreground: 0 0% 100%;
            --accent: 262 83% 58%;
            --accent-foreground: 0 0% 100%;
            --muted: 248 57% 97%;
            --muted-foreground: 0 0% 10%;
            --border: 237 20% 85%;
            --input: 237 20% 80%;
            --ring: 192 91% 36%;
            color-scheme: light;
        }
        .ashraf-elec-calc {
            font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
            color: hsl(var(--foreground));
        }
        /*
         * Browsers don't inherit `color` onto form controls, and since this
         * theme's dark/light mode is a manual data-theme toggle (not
         * prefers-color-scheme), the browser has no way to know it should
         * flip an input's native text color on its own. Without this, inputs
         * kept their default (usually black) text color while --background
         * went dark, making anything typed effectively invisible.
         */
        .ashraf-elec-calc input,
        .ashraf-elec-calc select,
        .ashraf-elec-calc textarea {
            color: hsl(var(--foreground));
        }
        .ashraf-elec-calc input::placeholder,
        .ashraf-elec-calc textarea::placeholder {
            color: hsl(var(--muted-foreground));
            opacity: 1;
        }
        /*
         * Real hover + focus feedback for every input in the tool. Before
         * this, plain inputs (the "border border-input" Tailwind pair) had
         * no hover state at all, and focus only added a faint ring without
         * the border itself changing color — so the field never looked
         * "selected" at a glance. This makes both states visible while
         * keeping the tool's own cyan/primary color, not a redesign.
         */
        .ashraf-elec-calc input:not([type="checkbox"]):not([readonly]):hover {
            border-color: hsl(var(--primary) / 0.55);
        }
        .ashraf-elec-calc input:not([type="checkbox"]):focus {
            border-color: hsl(var(--primary));
            outline: none;
        }
        .ashraf-elec-calc h1, .ashraf-elec-calc h2, .ashraf-elec-calc h3 {
            font-family: var(--font-display, 'Inter'), ui-sans-serif, system-ui, sans-serif;
        }
        .ashraf-elec-calc .icon {
            display: inline-block;
            vertical-align: middle;
        }
        .ashraf-elec-calc select.trigger {
            appearance: none;
            -webkit-appearance: none;
            background-image: none;
        }
        /*
         * Tailwind's preflight (base reset) is intentionally disabled for
         * this tool (see tailwind.config.js) so it doesn't strip default
         * heading/list/margin styles from the rest of the site. But that
         * also means plain <button> elements fall back to the browser's
         * own default chrome (solid grey background, borders) unless they
         * carry an explicit bg/border class. This restores a neutral,
         * theme-aware baseline for every button in the tool.
         */
        .ashraf-elec-calc button {
            background: transparent;
            border: none;
            font: inherit;
            color: inherit;
            cursor: pointer;
            -webkit-appearance: none;
            appearance: none;
        }
        .ashraf-elec-calc .faq-panel {
            max-height: 0;
            overflow: hidden;
            transition: max-height .25s ease;
        }
        .ashraf-elec-calc .faq-item.open .faq-panel {
            max-height: 260px;
        }
        .ashraf-elec-calc .faq-item.open .chev {
            transform: rotate(0deg);
            color: hsl(var(--primary));
        }
        .ashraf-elec-calc /* hero illustration animations */
        .hero-sun-rays {
            animation: hero-spin 14s linear infinite;
        }
        @keyframes hero-spin {
            from {
                transform: rotate(0deg);
            }
            to {
                transform: rotate(360deg);
            }
        }
        .ashraf-elec-calc .hero-fade {
            opacity: 0;
            animation: hero-fade-in .6s ease forwards;
        }
        @keyframes hero-fade-in {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
        .ashraf-elec-calc .hero-bill-in {
            opacity: 0;
            transform: rotate(-6deg) scale(.96);
            animation: hero-bill .6s ease .25s forwards;
        }
        @keyframes hero-bill {
            from {
                opacity: 0;
                transform: rotate(-6deg) scale(.96);
            }
            to {
                opacity: 1;
                transform: rotate(2deg) scale(1);
            }
        }
        .ashraf-elec-calc .hero-line-draw {
            stroke-dasharray: 1px 1px;
            stroke-dashoffset: 1px;
            animation: hero-draw 1.2s ease .9s forwards;
        }
        @keyframes hero-draw {
            from {
                stroke-dashoffset: 1px;
            }
            to {
                stroke-dashoffset: 0px;
            }
        }
        .ashraf-elec-calc .hero-blink {
            animation: hero-blink 1.8s ease-in-out infinite;
        }
        @keyframes hero-blink {
            0%,
            100% {
                opacity: .5;
            }
            50% {
                opacity: 1;
            }
        }
        .ashraf-elec-calc .hero-float {
            animation: hero-float 3.2s ease-in-out infinite;
        }
        @keyframes hero-float {
            0%,
            100% {
                opacity: .35;
                transform: translateY(0);
            }
            50% {
                opacity: .9;
                transform: translateY(-4px);
            }
        }

        .ashraf-elec-calc .bar-grow {
            transform-origin: left;
            transform: scaleX(0);
            transition: transform .9s cubic-bezier(.4, 0, .2, 1);
            transition-delay: var(--d, 0s);
        }
        .ashraf-elec-calc .bar-grow.in-view {
            transform: scaleX(1);
        }
        /*
         * The "High usage / Top slab" progress bar fill relies on Tailwind's
         * JIT-generated .bg-accent utility. Pinning it here with the theme's
         * own --accent variable guarantees the red fill always renders, even
         * if the Tailwind CDN class isn't available/loaded in time.
         */
        .ashraf-elec-calc .bar-grow.bg-accent {
            background: hsl(var(--accent));
        }
        .ashraf-elec-calc .card-enter {
            opacity: 0;
            transform: translateY(28px);
            transition: opacity .7s ease, transform .7s ease;
            transition-delay: var(--d, 0s);
        }
        .ashraf-elec-calc .card-enter.in-view {
            opacity: 1;
            transform: translateY(0);
        }

        .ashraf-elec-calc /* CTA buttons row */
        .cta-row {
            display: flex;
            justify-content: center;
            gap: 1rem;
            flex-wrap: wrap;
            padding: 0.5rem 0 0.25rem;
        }
        .ashraf-elec-calc .cta-row .cta-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.55rem 1.4rem;
            border-radius: 9999px;
            font-weight: 600;
            font-size: 0.9rem;
            text-decoration: none;
            transition: all .2s;
            border: 2px solid transparent;
            background: hsl(var(--primary));
            color: hsl(var(--primary-foreground));
            box-shadow: 0 2px 14px hsl(var(--primary) / 0.35);
        }
        .ashraf-elec-calc .cta-row .cta-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 24px hsl(var(--primary) / 0.5);
            filter: brightness(1.05);
        }
        .ashraf-elec-calc .cta-row .cta-btn-outline {
            background: transparent;
            color: hsl(var(--accent));
            border-color: hsl(var(--accent));
            box-shadow: none;
        }
        .ashraf-elec-calc .cta-row .cta-btn-outline:hover {
            background: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
            box-shadow: 0 6px 24px hsl(var(--accent) / 0.35);
        }
        @media (max-width: 480px) {
            .ashraf-elec-calc .cta-row {
                gap: 0.6rem;
            }
            .ashraf-elec-calc .cta-row .cta-btn {
                padding: 0.4rem 1rem;
                font-size: 0.75rem;
                gap: 0.3rem;
            }
            .ashraf-elec-calc .cta-row .cta-btn svg {
                width: 14px;
                height: 14px;
            }
        }

        /* FIX (mobile width getting cut off): for HT/EHT "peak / off-peak /
           super off-peak" categories, onCategoryChange() in
           electricity-calculator.js injects a fixed 3-column grid
           (Tailwind's grid-cols-3, no responsive variant) for the three
           unit inputs. grid-cols-3 has no minimum track width, so grid
           doesn't wrap or shrink the row below what its content actually
           needs -- on a narrow phone the three number inputs + labels
           genuinely don't fit in three equal columns, and the same
           .at-tool-page-embed overflow-x:hidden band-aid mentioned above
           clips whatever doesn't fit instead of showing it. Dropping to a
           single column below 480px (matching this file's other mobile
           breakpoints) removes the need to squeeze three inputs into one
           row on a phone screen. */
        @media (max-width: 480px) {
            .ashraf-elec-calc #unitFields .grid-cols-3 {
                grid-template-columns: 1fr;
            }
        }

        .ashraf-elec-calc /* ---- Sub-meter styles (minimal, .ashraf-elec-calc uses Tailwind where possible) ---- */
        .submeter-wrap .field input:focus {
            outline: none;
            border-color: hsl(var(--primary));
            box-shadow: 0 0 0 3px hsl(var(--primary) / 0.2);
        }
        /*
         * "সাব-মিটার যোগ করুন" (add-btn) was relying on Tailwind's
         * bg-accent / text-accent-foreground utilities, which rendered
         * transparent when the Tailwind CDN class wasn't picked up in time.
         * Pinning the colors here with the theme's own variables guarantees
         * a solid red button regardless.
         */
        .ashraf-elec-calc .add-btn {
            background: hsl(var(--accent));
            color: hsl(var(--accent-foreground));
            border: none;
            cursor: pointer;
        }
        .ashraf-elec-calc .add-btn:hover {
            filter: brightness(1.1);
        }
        .ashraf-elec-calc .submeter-wrap .user-row.main-user {
            background: hsl(var(--accent) / 0.1);
            border: 1px solid hsl(var(--accent) / 0.3);
        }
        .ashraf-elec-calc .submeter-wrap .user-row.main-user .name-input, .ashraf-elec-calc .submeter-wrap .user-row.main-user .unit-input {
            background: hsl(var(--muted));
            cursor: not-allowed;
            opacity: .7;
        }
        .ashraf-elec-calc .submeter-wrap .user-badge {
            font-size: .6rem;
            font-weight: 700;
            text-transform: uppercase;
            color: hsl(var(--accent));
            background: hsl(var(--accent) / 0.16);
            padding: 2px 8px;
            border-radius: 20px;
            margin-right: 4px;
        }
        .ashraf-elec-calc .submeter-wrap .submeter-section {
            display: none;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px dashed hsl(var(--border));
        }
        .ashraf-elec-calc .submeter-wrap .submeter-section.visible {
            display: block;
        }
        /* FIX (mobile width getting cut off): a .user-row (main meter row
           and every "সাব-মিটার যোগ করুন" row added by JS) lays out
           name-input(flex-1, min-w-80px) + unit-input(w-20 = 80px,
           default flex-shrink:1) + badge/remove-btn side by side with
           flex-wrap:nowrap (the Tailwind default). On real mobile
           widths the two inputs' own floors (80px + 80px) don't fit next
           to the badge/remove-btn inside the card's padding, so the row
           overflows its container. .at-tool-page-embed's overflow-x:
           hidden (tool-pages.css) then silently clips that overflow
           instead of letting the page scroll -- which is exactly what
           shows up as the row's right edge (the unit input / ✕ button)
           being cut off on a phone. Narrowing unit-input to a fixed,
           non-shrinking width and letting name-input's floor drop below
           80px only below 480px keeps both inputs fully visible instead
           of fighting for space they don't have. */
        @media (max-width: 480px) {
            .ashraf-elec-calc .submeter-wrap .user-row {
                gap: 6px;
                padding: 6px;
            }
            .ashraf-elec-calc .submeter-wrap .user-row .name-input {
                min-width: 0;
            }
            .ashraf-elec-calc .submeter-wrap .user-row .unit-input {
                width: 64px;
                flex: 0 0 64px;
                padding-left: 6px;
                padding-right: 6px;
                text-align: center;
            }
            .ashraf-elec-calc .submeter-wrap .user-badge {
                padding: 2px 6px;
                margin-right: 2px;
                font-size: .55rem;
            }
            .ashraf-elec-calc .submeter-wrap .remove-btn {
                padding: 2px 6px;
                flex-shrink: 0;
            }
        }
        .ashraf-elec-calc .submeter-wrap .allocation-summary {
            background: hsl(var(--primary) / 0.08);
            border-left: 4px solid hsl(var(--primary));
            padding: 12px 16px;
            border-radius: 8px;
            margin-bottom: 16px;
            font-size: .9rem;
            display: flex;
            flex-wrap: wrap;
            gap: 12px 20px;
        }
        .ashraf-elec-calc .submeter-wrap .allocation-summary .item {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .ashraf-elec-calc .submeter-wrap .allocation-summary .item .label {
            color: hsl(var(--muted-foreground));
            font-weight: 500;
        }
        .ashraf-elec-calc .submeter-wrap .allocation-summary .item .value {
            font-weight: 700;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card {
            background: hsl(var(--card));
            border: 1px solid hsl(var(--primary) / 0.4);
            border-radius: 14px;
            padding: 16px 14px;
            box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
            transition: transform .15s, box-shadow .15s, border-color .15s;
            display: flex;
            flex-direction: column;
            height: 100%;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 24px hsl(var(--primary) / 0.15);
            border-color: hsl(var(--primary));
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid hsl(var(--primary));
            padding-bottom: 6px;
            margin-bottom: 10px;
            flex-shrink: 0;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-header .name {
            font-size: 1rem;
            font-weight: 700;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-header .units {
            font-size: .75rem;
            background: hsl(var(--primary));
            padding: 2px 10px;
            border-radius: 20px;
            color: hsl(var(--primary-foreground));
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .slab-breakdown {
            font-size: .72rem;
            color: hsl(var(--muted-foreground));
            background: hsl(var(--muted));
            padding: 6px 8px;
            border-radius: 6px;
            margin: 0 0 10px 0;
            flex: 1 1 auto;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .slab-breakdown div {
            display: flex;
            justify-content: space-between;
            padding: 1px 0;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .slab-breakdown .slab-total {
            border-top: 1px dashed hsl(var(--border));
            margin-top: 2px;
            padding-top: 2px;
            font-weight: 600;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .lifeline-label {
            font-size: .8rem;
            font-weight: 500;
            background: hsl(var(--accent) / 0.1);
            padding: 6px 8px;
            border-radius: 6px;
            border: 1px solid hsl(var(--accent));
            margin: 0 0 10px 0;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer {
            margin-top: auto;
            padding-top: 8px;
            border-top: 2px solid hsl(var(--border));
            flex-shrink: 0;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row {
            display: flex;
            justify-content: space-between;
            font-size: .8rem;
            padding: 3px 0;
            border-bottom: 1px dashed hsl(var(--border));
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row:last-child {
            border-bottom: none;
            font-weight: 700;
            font-size: .9rem;
            padding-top: 4px;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row .lbl {
            color: hsl(var(--muted-foreground));
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row .val {
            font-weight: 600;
            font-variant-numeric: tabular-nums;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row .val.positive {
            color: #2dd4bf;
        }
        .ashraf-elec-calc .submeter-wrap .user-result-card .card-footer .row .val.negative {
            color: hsl(var(--accent));
        }
        .ashraf-elec-calc .submeter-wrap .placeholder-note {
            font-size: .9rem;
            color: hsl(var(--muted-foreground));
            text-align: center;
            padding: 20px 10px;
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box {
            margin-top: 16px;
            background: hsl(var(--accent) / 0.06);
            border-radius: 12px;
            padding: 16px 18px;
            border: 1px solid hsl(var(--primary) / 0.2);
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box h4 {
            margin: 0 0 6px;
            font-size: 1rem;
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box p {
            margin: 0 0 8px;
            font-size: .85rem;
            color: hsl(var(--muted-foreground));
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box .calc-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            font-size: .82rem;
            background: hsl(var(--card));
            padding: 10px 12px;
            border-radius: 8px;
            margin: 8px 0;
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box .calc-grid .right {
            text-align: right;
            font-weight: 600;
        }
        .ashraf-elec-calc .submeter-wrap .explanation-box .calc-grid .highlight {
            color: hsl(var(--primary));
        }

        .ashraf-elec-calc /* reset & action button consistency */
        .btn-reset {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            border-radius: 0.375rem;
            font-size: 0.875rem;
            font-weight: 500;
            transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
            transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
            transition-duration: 0.15s;
            border: 1px solid hsl(var(--input));
            background: hsl(var(--background));
            height: 2.5rem;
            padding-left: 1rem;
            padding-right: 1rem;
            color: hsl(var(--foreground));
        }
        .ashraf-elec-calc .btn-reset:hover {
            background: hsl(var(--accent) / 0.12);
            border-color: hsl(var(--accent));
        }
        .ashraf-elec-calc .btn-reset svg {
            margin-right: 0.5rem;
        }

        .ashraf-elec-calc .btn-primary-action {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            border-radius: 0.375rem;
            font-size: 0.875rem;
            transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
            transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
            transition-duration: 0.15s;
            height: 2.5rem;
            padding-left: 1rem;
            padding-right: 1rem;
            background: hsl(var(--primary));
            color: hsl(var(--primary-foreground));
            font-weight: 600;
            box-shadow: 0 4px 14px hsl(var(--primary) / 0.35);
            border: none;
        }
        .ashraf-elec-calc .btn-primary-action:hover {
            background: hsl(var(--primary) / 0.9);
            box-shadow: 0 6px 20px hsl(var(--primary) / 0.5);
        }
        .ashraf-elec-calc .btn-primary-action svg {
            margin-right: 0.5rem;
        }
    