/* ─── canada-hst-tool.css ─────────────────────────────────────────────────────
   Shared design for Canada HST Calculator and Province Template.
   Scoped to .hst-app. Mirrors the reverse-tax-calculator design system.
   Colors come from global CSS variables defined in style.css.
─────────────────────────────────────────────────────────────────────────── */

/* ─── ROOT ─── */
.hst-app {
    font-family: var(--font-sans);
    color: var(--text-1);
}

/* ─── MAIN TOOL CARD ─── */
.hst-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    border: 1px solid var(--border-1);
    border-radius: var(--r-lg);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
@media (min-width: 1024px) {
    .hst-layout-grid {
        grid-template-columns: 7fr 5fr;
    }
}

/* ─── LEFT PANEL (Inputs) ─── */
.hst-panel--inputs {
    padding: var(--sp-6);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-1);
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}
@media (min-width: 768px) {
    .hst-panel--inputs { padding: var(--sp-8); }
}
@media (min-width: 1024px) {
    .hst-panel--inputs {
        border-bottom: none;
        border-right: 1px solid var(--border-1);
    }
}

/* ─── RIGHT PANEL (Results) ─── */
.hst-panel--output {
    padding: var(--sp-6);
    background: var(--bg);
    display: flex;
    flex-direction: column;
}
@media (min-width: 768px) {
    .hst-panel--output { padding: var(--sp-8); }
}

/* ─── OUTPUT SECTION TITLE ─── */
.hst-output-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.hst-output-title svg { color: var(--green); flex-shrink: 0; }

/* ─── STEP LABELS ─── */
.hst-step-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-3);
    display: block;
}

/* ─── MODE TOGGLE ─── */
.hst-seg-control {
    display: flex;
    background: var(--bg);
    padding: 6px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-1);
    gap: 4px;
}
.hst-seg-control button {
    flex: 1;
    padding: var(--sp-2) var(--sp-4);
    border-radius: calc(var(--r-md) - 2px);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-2);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t-fast);
}
.hst-seg-control button.active {
    background: var(--surface-1);
    border-color: var(--green);
    color: var(--green-dark);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* ─── PROVINCE GRID ─── */
.hst-grid-prov {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-2);
}
@media (min-width: 768px) {
    .hst-grid-prov { grid-template-columns: repeat(5, 1fr); }
}
.btn-prov {
    padding: var(--sp-2);
    border-radius: var(--r-md);
    text-align: center;
    background: var(--bg);
    border: 1px solid var(--border-1);
    cursor: pointer;
    transition: all var(--t-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 46px;
}
.btn-prov:hover { border-color: var(--green-light); }
.btn-prov.active {
    border: 2px solid var(--green);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
}
.btn-prov .prov-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-1);
}
.btn-prov .prov-rate {
    font-size: 9px;
    color: var(--text-3);
    margin-top: 2px;
    white-space: nowrap;
}

/* ─── AMOUNT INPUT ─── */
.hst-input-wrap {
    position: relative;
}
.hst-input-wrap .prefix {
    position: absolute;
    left: var(--sp-4);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-xl);
    color: var(--text-3);
    pointer-events: none;
}
.hst-input-wrap input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-10);
    font-size: var(--text-2xl);
    color: var(--green-dark);
    outline: none;
    transition: box-shadow var(--t-fast), border-color var(--t-fast);
    font-family: var(--font-mono);
}
.hst-input-wrap input:focus {
    box-shadow: 0 0 0 3px var(--green-light);
    border-color: var(--green);
}

/* ─── PRESET BUTTONS ─── */
.hst-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}
.btn-preset {
    flex: 1;
    padding: var(--sp-2);
    background: var(--bg);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
    transition: all var(--t-fast);
    white-space: nowrap;
}
.btn-preset:hover { border-color: var(--green); color: var(--green-dark); }

/* ─── RESULT HIGHLIGHT BOX ─── */
.hst-result-highlight {
    padding: var(--sp-4);
    border-radius: var(--r-md);
    background: linear-gradient(to bottom right, var(--green-light), var(--bg));
    border: 1px solid var(--green-light);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-6);
}

/* ─── BIG RESULT NUMBER ─── */
.hst-big-result-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-3);
    margin-bottom: var(--sp-2);
    display: block;
}
.hst-big-result {
    font-size: var(--text-4xl);
    font-weight: 900;
    color: var(--text-1);
    margin-bottom: var(--sp-8);
    word-break: break-all;
    line-height: 1;
    letter-spacing: -0.025em;
    font-family: var(--font-mono);
}
@media (min-width: 768px) {
    .hst-big-result { font-size: clamp(40px, 6vw, 60px); }
}

/* ─── BREAKDOWN ROWS ─── */
.hst-breakdown {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    margin-bottom: var(--sp-8);
}
.hst-bd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sm);
}
.hst-bd-row .label { color: var(--text-2); }
.hst-bd-row .val { font-weight: 600; color: var(--text-1); }
.hst-bd-divider {
    height: 1px;
    background: var(--border-1);
    width: 100%;
}
.hst-bd-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--green-dark);
}

/* ─── PRO TIP BOX ─── */
.hst-pro-tip {
    background: var(--surface-1);
    border: 1px solid var(--green);
    border-radius: var(--r-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    display: flex;
    gap: var(--sp-3);
}
.hst-pro-tip .icon-wrap {
    width: 20px;
    height: 20px;
    background: var(--green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.hst-pro-tip .icon-wrap span { color: white; font-size: 10px; font-weight: 700; }
.hst-pro-tip .text { font-size: var(--text-xs); color: var(--text-2); line-height: 1.5; }

/* ─── COPY BUTTON ─── */
.btn-copy {
    width: 100%;
    padding: var(--sp-3);
    background: var(--green);
    color: var(--text-inv);
    border: none;
    border-radius: var(--r-pill);
    font-weight: 700;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: opacity var(--t-fast);
}
.btn-copy:hover { opacity: 0.9; }

/* ─── AI FOOTER PANEL ─── */
.hst-ai-footer {
    background: var(--surface-1);
    border-top: 1px solid var(--border-1);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    padding: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}
@media (min-width: 1024px) {
    .hst-ai-footer {
        flex-direction: row;
        align-items: center;
        padding: var(--sp-6) var(--sp-8);
    }
}

/* ─── AI PANEL INTERNALS ─── */
.ai-panel-left { flex: 1; display: flex; flex-direction: column; gap: var(--sp-2); }
.ai-panel-header { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.ai-panel-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--green-dark);
}
.ai-quick-qs { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.btn-quick-q {
    padding: var(--sp-1) var(--sp-3);
    background: var(--bg);
    border: 1px solid var(--border-1);
    border-radius: var(--r-pill);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
}
.btn-quick-q:hover { border-color: var(--green); color: var(--green-dark); }

/* ─── AI CHAT INPUT ─── */
.ai-input-wrap { display: flex; gap: var(--sp-2); width: 100%; }
@media (min-width: 768px) { .ai-input-wrap { width: auto; min-width: 280px; } }
.ai-input-wrap input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border-1);
    border-radius: var(--r-pill);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-xs);
    outline: none;
    color: var(--text-1);
    transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.ai-input-wrap input:focus { box-shadow: 0 0 0 2px var(--green-light); border-color: var(--green); }
.btn-ai-send {
    background: var(--green);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity var(--t-fast);
}
.btn-ai-send:hover { opacity: 0.9; }
.btn-ai-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── AI CHAT HISTORY ─── */
.ai-chat-history {
    margin-top: var(--sp-4);
    background: var(--bg);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    border: 1px solid var(--border-1);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    max-height: 500px;
    overflow-y: auto;
}
.ai-msg-row { display: flex; width: 100%; }
.ai-msg-row.user { justify-content: flex-end; }
.ai-msg-row.model { justify-content: flex-start; }
.ai-msg-bubble { display: flex; align-items: flex-start; gap: var(--sp-4); max-width: 90%; }
@media (min-width: 768px) { .ai-msg-bubble { max-width: 85%; } }
.ai-msg-row.user .ai-msg-bubble { flex-direction: row-reverse; }
.ai-msg-icon {
    width: 32px; height: 32px;
    background: var(--green-xlight);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--green);
    margin-top: 4px;
}
.ai-msg-content {
    font-size: var(--text-sm);
    border-radius: var(--r-md);
    padding: var(--sp-4) var(--sp-5);
    line-height: 1.6;
}
.ai-msg-row.user .ai-msg-content {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    color: var(--green-dark);
    white-space: pre-wrap;
}
.ai-msg-row.model .ai-msg-content {
    background: transparent;
    color: var(--text-1);
    padding: 0;
}
.ai-msg-content strong { font-weight: 700; color: var(--text-1); }
.ai-msg-content p { margin: 0 0 var(--sp-3) 0; }
.ai-msg-content p:last-child { margin-bottom: 0; }
.ai-msg-content ul { margin: 0 0 var(--sp-3) 0; padding-left: var(--sp-5); }
.ai-msg-content li { margin-bottom: 4px; }
.ai-msg-content a { color: var(--green); text-decoration: underline; }

/* ─── LOADING SPINNER ─── */
.loader-spin {
    animation: hst-spin 1s linear infinite;
    height: 16px;
    width: 16px;
    border: 2px solid var(--green);
    border-top-color: transparent;
    border-radius: 50%;
}
@keyframes hst-spin { 100% { transform: rotate(360deg); } }

/* ─── POP-IN ANIMATION (matches .rtc-anim-pop) ─── */
.hst-anim-pop {
    animation: hstResultPop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes hstResultPop {
    0%   { opacity: 0; transform: translateY(12px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ─── MOBILE RESPONSIVENESS ─── */

/* Smallest phones (≤ 360px) */
@media (max-width: 360px) {
    .hst-app {
        padding-left: 0;
        padding-right: 0;
    }
    .hst-panel--inputs {
        padding: var(--sp-4);
    }
    .hst-panel--output {
        padding: var(--sp-4);
    }
    .hst-big-result {
        font-size: 2rem;
    }
    .hst-grid-prov {
        grid-template-columns: repeat(2, 1fr);
    }
    .hst-input-wrap input {
        font-size: var(--text-xl);
        padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-8);
    }
    .btn-preset {
        font-size: 10px;
        padding: var(--sp-1) var(--sp-2);
    }
}

/* Standard phones (≤ 480px) */
@media (max-width: 480px) {
    .hst-app {
        padding: 0 var(--sp-2);
    }
    .hst-panel--inputs {
        padding: var(--sp-5);
        gap: var(--sp-4);
    }
    .hst-panel--output {
        padding: var(--sp-5);
    }
    .hst-big-result {
        font-size: 2.25rem;
    }
    .hst-seg-control button {
        font-size: 11px;
        padding: var(--sp-2) var(--sp-2);
    }
    /* Province grid: 3 cols on small phones */
    .hst-grid-prov {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--sp-1);
    }
    .btn-prov {
        min-height: 40px;
        padding: var(--sp-1);
    }
    .btn-prov .prov-name { font-size: 9px; }
    .btn-prov .prov-rate { font-size: 8px; }
    /* Presets wrap nicely */
    .hst-presets {
        gap: var(--sp-1);
    }
    .btn-preset {
        min-width: 0;
        font-size: 11px;
    }
    /* AI footer stacks */
    .hst-ai-footer {
        padding: var(--sp-4);
        flex-direction: column;
        gap: var(--sp-3);
    }
    .ai-quick-qs {
        gap: var(--sp-1);
    }
    .btn-quick-q {
        font-size: 10px;
        padding: 4px var(--sp-2);
    }
    .ai-input-wrap {
        width: 100%;
    }
    /* Chat messages */
    .ai-msg-content {
        font-size: 13px;
        padding: var(--sp-3) var(--sp-3);
    }
    .ai-chat-history {
        padding: var(--sp-4);
    }
}

/* All phones (≤ 640px) */
@media (max-width: 640px) {
    /* Ensure the tool card is full width */
    .hst-app {
        margin-top: calc(var(--sp-4) * -1) !important;
        padding: 0 var(--sp-3);
    }
    .hst-layout-grid {
        border-radius: var(--r-md);
    }
    .hst-panel--inputs {
        border-bottom: 1px solid var(--border-1);
        border-right: none !important;
    }
    /* Input font size — prevent iOS zoom (stays above 16px) */
    .hst-input-wrap input {
        font-size: 1.25rem;
    }
    /* Result number is readable but not overflow */
    .hst-big-result {
        font-size: clamp(1.75rem, 8vw, 2.75rem);
        margin-bottom: var(--sp-5);
    }
    /* Result highlight — tighter */
    .hst-result-highlight {
        padding: var(--sp-3);
    }
    /* Pro tip — smaller */
    .hst-pro-tip {
        padding: var(--sp-3);
    }
    .hst-pro-tip .text {
        font-size: 11px;
    }
    /* AI footer */
    .hst-ai-footer {
        border-radius: 0 0 var(--r-md) var(--r-md);
    }
    .ai-panel-header {
        margin-bottom: var(--sp-1);
    }
    /* Breakdown rows — prevent long labels from wrapping badly */
    .hst-bd-row .label,
    .hst-bd-row .val {
        font-size: 13px;
    }
    .hst-bd-total {
        font-size: 15px;
    }
}

/* ─── PRINT ─── */
@media print {
    .hst-panel--inputs,
    .hst-ai-footer,
    .ai-chat-history { display: none !important; }
    .hst-layout-grid { display: block !important; border: none !important; box-shadow: none !important; }
}
