/* ================================================================
   GST Calculator Pro — Stylesheet v2.0.0
   ================================================================ */

/* ── CSS Variables ─────────────────────────────────────────────── */
#gst-calculator-wrap {
    --gst-accent: #4F46E5;
    --gst-accent-light: #EEF2FF;
    --gst-accent-dark: #3730A3;
    --gst-bg: #FFFFFF;
    --gst-surface: #F8FAFC;
    --gst-surface2: #F1F5F9;
    --gst-border: #E2E8F0;
    --gst-border-focus: var(--gst-accent);
    --gst-text: #0F172A;
    --gst-text-muted: #64748B;
    --gst-text-light: #94A3B8;
    --gst-success: #10B981;
    --gst-success-light: #D1FAE5;
    --gst-warning: #F59E0B;
    --gst-warning-light: #FEF3C7;
    --gst-error: #EF4444;
    --gst-shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --gst-shadow: 0 4px 16px rgba(15,23,42,.08);
    --gst-shadow-lg: 0 12px 40px rgba(15,23,42,.12);
    --gst-radius: 12px;
    --gst-radius-sm: 8px;
    --gst-radius-xs: 6px;
    --gst-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --gst-transition: 0.22s cubic-bezier(.4,0,.2,1);
    max-width: 600px;
    margin: 0 auto 2rem;
    font-family: var(--gst-font);
}

/* ── Dark Theme ────────────────────────────────────────────────── */
#gst-calculator-wrap.theme-dark {
    --gst-bg: #0F172A;
    --gst-surface: #1E293B;
    --gst-surface2: #334155;
    --gst-border: #334155;
    --gst-text: #F1F5F9;
    --gst-text-muted: #94A3B8;
    --gst-text-light: #64748B;
    --gst-accent-light: rgba(79,70,229,.2);
    --gst-success-light: rgba(16,185,129,.15);
    --gst-warning-light: rgba(245,158,11,.15);
}

/* ── Minimal Theme ─────────────────────────────────────────────── */
#gst-calculator-wrap.theme-minimal {
    --gst-accent: #1D4ED8;
    --gst-accent-light: #EFF6FF;
    --gst-surface: #FAFAFA;
    --gst-surface2: #F5F5F5;
    --gst-border: #E5E5E5;
    --gst-radius: 6px;
    --gst-radius-sm: 4px;
}

/* ── Wrapper ───────────────────────────────────────────────────── */
.gst-calc-wrap {
    background: var(--gst-bg);
    border-radius: var(--gst-radius);
    border: 1px solid var(--gst-border);
    box-shadow: var(--gst-shadow);
    overflow: hidden;
    transition: box-shadow var(--gst-transition);
}
.gst-calc-wrap:hover {
    box-shadow: var(--gst-shadow-lg);
}

/* ── Header ────────────────────────────────────────────────────── */
.gst-calc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 20px;
    background: linear-gradient(135deg, var(--gst-accent) 0%, var(--gst-accent-dark) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.gst-calc-header::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    pointer-events: none;
}
.gst-calc-header::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: 30%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    pointer-events: none;
}
.gst-calc-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}
.gst-calc-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.18);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gst-calc-icon svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
}
.gst-calc-title {
    margin: 0 0 2px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    border: none;
    padding: 0;
}
.gst-calc-subtitle {
    margin: 0;
    font-size: .78rem;
    color: rgba(255,255,255,.75);
    line-height: 1;
}
.gst-calc-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.25);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    color: #fff;
    position: relative;
    z-index: 1;
    transition: background var(--gst-transition);
}
.gst-flag { font-size: 1.1rem; }

/* ── Sections ──────────────────────────────────────────────────── */
.gst-calc-section {
    padding: 20px 28px;
    border-bottom: 1px solid var(--gst-border);
}
.gst-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--gst-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 10px;
}

/* ── Country Select ────────────────────────────────────────────── */
.gst-select-wrapper {
    position: relative;
}
.gst-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: var(--gst-surface);
    border: 1.5px solid var(--gst-border);
    border-radius: var(--gst-radius-sm);
    padding: 12px 42px 12px 14px;
    font-size: .95rem;
    color: var(--gst-text);
    font-family: var(--gst-font);
    cursor: pointer;
    transition: border-color var(--gst-transition), box-shadow var(--gst-transition);
    outline: none;
}
.gst-select:focus {
    border-color: var(--gst-accent);
    box-shadow: 0 0 0 3px var(--gst-accent-light);
}
.gst-select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gst-text-muted);
    font-size: .85rem;
    pointer-events: none;
}

/* ── Rate Pills ────────────────────────────────────────────────── */
.gst-rate-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.gst-rate-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}
.gst-rate-pill {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--gst-border);
    background: var(--gst-surface);
    color: var(--gst-text);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--gst-transition);
    white-space: nowrap;
    outline: none;
}
.gst-rate-pill:hover {
    border-color: var(--gst-accent);
    color: var(--gst-accent);
    background: var(--gst-accent-light);
}
.gst-rate-pill.active {
    background: var(--gst-accent);
    border-color: var(--gst-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.gst-rate-pill.custom-pill {
    border-style: dashed;
}
.gst-custom-rate-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--gst-surface);
    border: 1.5px solid var(--gst-accent);
    border-radius: var(--gst-radius-xs);
    padding: 0 10px;
}
.gst-custom-rate-input {
    border: none !important;
    background: transparent !important;
    padding: 8px 0 !important;
    width: 80px;
    box-shadow: none !important;
    font-size: .9rem;
}
.gst-pct-sign {
    color: var(--gst-text-muted);
    font-weight: 600;
    font-size: .9rem;
}
.gst-rate-display {
    margin-top: 10px;
    font-size: .83rem;
    color: var(--gst-text-muted);
}
.gst-rate-display strong {
    color: var(--gst-accent);
    font-weight: 700;
}

/* ── Amount Input ──────────────────────────────────────────────── */
.gst-amount-row {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--gst-border);
    border-radius: var(--gst-radius-sm);
    overflow: hidden;
    transition: border-color var(--gst-transition), box-shadow var(--gst-transition);
}
.gst-amount-row:focus-within {
    border-color: var(--gst-accent);
    box-shadow: 0 0 0 3px var(--gst-accent-light);
}
.gst-currency-prefix {
    padding: 12px 14px;
    background: var(--gst-surface2);
    border-right: 1.5px solid var(--gst-border);
    font-weight: 700;
    font-size: .9rem;
    color: var(--gst-text);
    display: flex;
    align-items: center;
    white-space: nowrap;
    min-width: 52px;
    justify-content: center;
    transition: background var(--gst-transition);
}
.gst-input {
    flex: 1;
    background: var(--gst-surface);
    border: none;
    padding: 12px 14px;
    font-size: 1.05rem;
    font-family: var(--gst-font);
    color: var(--gst-text);
    outline: none;
    width: 100%;
}
.gst-input::placeholder { color: var(--gst-text-light); }
.gst-amount-input { font-size: 1.15rem; font-weight: 600; }

/* ── Toggle ────────────────────────────────────────────────────── */
.gst-toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.gst-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--gst-surface);
    border: 1.5px solid var(--gst-border);
    border-radius: var(--gst-radius-sm);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    color: var(--gst-text-muted);
    transition: all var(--gst-transition);
    text-align: left;
    outline: none;
    font-family: var(--gst-font);
}
.gst-toggle-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: currentColor;
}
.gst-toggle-btn:hover {
    border-color: var(--gst-accent);
    color: var(--gst-accent);
}
.gst-toggle-btn.active {
    background: var(--gst-accent-light);
    border-color: var(--gst-accent);
    color: var(--gst-accent);
    font-weight: 600;
}

/* ── Calculate Button ──────────────────────────────────────────── */
.gst-calc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: calc(100% - 56px);
    margin: 20px 28px;
    padding: 15px 28px;
    background: linear-gradient(135deg, var(--gst-accent) 0%, var(--gst-accent-dark) 100%);
    color: #fff;
    border: none;
    border-radius: var(--gst-radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--gst-font);
    transition: all var(--gst-transition);
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
    letter-spacing: .02em;
    outline: none;
}
.gst-calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79,70,229,.45);
}
.gst-calc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(79,70,229,.3);
}
.gst-calc-btn.loading { opacity: .7; pointer-events: none; }
.gst-btn-icon {
    width: 18px;
    height: 18px;
    transition: transform var(--gst-transition);
}
.gst-calc-btn:hover .gst-btn-icon { transform: translateX(3px); }

/* ── Results ───────────────────────────────────────────────────── */
.gst-results {
    margin: 0 28px 24px;
    background: var(--gst-surface);
    border: 1.5px solid var(--gst-border);
    border-radius: var(--gst-radius);
    overflow: hidden;
    animation: gstSlideIn .3s cubic-bezier(.4,0,.2,1);
}
@keyframes gstSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.gst-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gst-border);
}
.gst-results-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gst-text-muted);
}
.gst-copy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 1px solid var(--gst-border);
    border-radius: var(--gst-radius-xs);
    padding: 5px 10px;
    font-size: .78rem;
    color: var(--gst-text-muted);
    cursor: pointer;
    font-family: var(--gst-font);
    transition: all var(--gst-transition);
}
.gst-copy-btn:hover {
    background: var(--gst-accent-light);
    color: var(--gst-accent);
    border-color: var(--gst-accent);
}
.gst-copy-btn svg { width: 13px; height: 13px; }
.gst-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}
.gst-result-card {
    padding: 18px 16px;
    border-right: 1px solid var(--gst-border);
    transition: background var(--gst-transition);
}
.gst-result-card:last-child { border-right: none; }
.gst-result-card:hover { background: var(--gst-surface2); }
.gst-result-label {
    font-size: .74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 6px;
    color: var(--gst-text-muted);
}
.gst-result-net .gst-result-label    { color: #0891B2; }
.gst-result-tax .gst-result-label    { color: var(--gst-accent); }
.gst-result-gross .gst-result-label  { color: var(--gst-success); }
.gst-result-value {
    font-size: 1.18rem;
    font-weight: 800;
    color: var(--gst-text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}
.gst-result-sub {
    font-size: .72rem;
    color: var(--gst-text-light);
    margin-top: 4px;
}

/* ── Breakdown Bar ─────────────────────────────────────────────── */
.gst-breakdown-bar {
    display: flex;
    height: 8px;
    border-radius: 0 0 0 0;
    overflow: hidden;
}
.gst-bar-net {
    background: linear-gradient(90deg, #0891B2, #06B6D4);
    transition: width .5s cubic-bezier(.4,0,.2,1);
}
.gst-bar-tax {
    background: linear-gradient(90deg, var(--gst-accent), var(--gst-accent-dark));
    transition: width .5s cubic-bezier(.4,0,.2,1);
    flex: 1;
}
.gst-bar-labels {
    display: flex;
    justify-content: space-between;
    padding: 8px 18px 14px;
    font-size: .75rem;
    color: var(--gst-text-muted);
}
.gst-bar-labels span:first-child { color: #0891B2; font-weight: 600; }
.gst-bar-labels span:last-child  { color: var(--gst-accent); font-weight: 600; }

/* ── History ───────────────────────────────────────────────────── */
.gst-history-wrap {
    margin: 0 28px 24px;
    border: 1px solid var(--gst-border);
    border-radius: var(--gst-radius-sm);
    overflow: hidden;
}
.gst-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gst-surface2);
    border-bottom: 1px solid var(--gst-border);
    font-size: .8rem;
    font-weight: 600;
    color: var(--gst-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.gst-clear-btn {
    background: none;
    border: 1px solid var(--gst-border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: .75rem;
    color: var(--gst-text-muted);
    cursor: pointer;
    font-family: var(--gst-font);
    transition: all var(--gst-transition);
}
.gst-clear-btn:hover {
    background: var(--gst-error);
    color: #fff;
    border-color: var(--gst-error);
}
.gst-history-list { max-height: 200px; overflow-y: auto; }
.gst-history-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gst-border);
    font-size: .83rem;
    gap: 10px;
    cursor: pointer;
    transition: background var(--gst-transition);
}
.gst-history-item:last-child { border-bottom: none; }
.gst-history-item:hover { background: var(--gst-accent-light); }
.gst-history-flag { font-size: 1.1rem; flex-shrink: 0; }
.gst-history-detail { flex: 1; color: var(--gst-text); }
.gst-history-detail strong { font-weight: 700; }
.gst-history-rate {
    font-size: .75rem;
    background: var(--gst-surface2);
    padding: 2px 7px;
    border-radius: 10px;
    color: var(--gst-text-muted);
    white-space: nowrap;
}

/* ── Footer ────────────────────────────────────────────────────── */
.gst-calc-footer {
    padding: 14px 28px;
    font-size: .74rem;
    color: var(--gst-text-light);
    text-align: center;
    border-top: 1px solid var(--gst-border);
    line-height: 1.5;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .gst-calc-header { padding: 18px 20px 16px; flex-wrap: wrap; gap: 10px; }
    .gst-calc-section { padding: 16px 20px; }
    .gst-calc-btn { margin: 16px 20px; width: calc(100% - 40px); }
    .gst-results, .gst-history-wrap { margin: 0 20px 20px; }
    .gst-results-grid { grid-template-columns: 1fr 1fr; }
    .gst-result-card:nth-child(3) { grid-column: 1 / -1; border-right: none; border-top: 1px solid var(--gst-border); }
    .gst-toggle-group { grid-template-columns: 1fr; }
    .gst-calc-footer { padding: 12px 20px; }
    .gst-calc-title { font-size: 1rem; }
}
@media (max-width: 360px) {
    .gst-results-grid { grid-template-columns: 1fr; }
    .gst-result-card { border-right: none; border-bottom: 1px solid var(--gst-border); }
    .gst-result-card:last-child { border-bottom: none; }
}

/* ── Country accent color injection (via JS) ───────────────────── */
.gst-calc-wrap[data-country-color] .gst-rate-pill.active,
.gst-calc-wrap[data-country-color] .gst-calc-btn {
    background: var(--gst-country-color, var(--gst-accent));
}
