/* ================================================================
   components.css — Cards, inputs, results, tables, contacts, banner
   ================================================================ */

/* ===== Card ===== */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.card__icon {
    width: 32px;
    height: 32px;
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary));
    flex-shrink: 0;
}

.card__icon svg {
    width: 16px;
    height: 16px;
}

.card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

@media (min-width: 640px) {
    .card {
        padding: 1.5rem;
    }
}

/* ===== Inputs ===== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.input-field {
    position: relative;
}

.input-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 0.375rem;
}

.input-field input {
    width: 100%;
    height: 44px;
    padding: 0 1rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    font-size: 1rem;
    font-weight: 600;
    direction: ltr;
    text-align: right;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.input-field input::-webkit-outer-spin-button,
.input-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field input:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsla(221, 83%, 53%, 0.12);
}

.input-field input::placeholder {
    color: hsl(var(--muted-foreground));
    font-weight: 400;
}

.input-field .unit {
    position: absolute;
    left: 0.875rem;
    bottom: 0;
    height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

/* ===== Buttons ===== */
.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
}

.btn-danger {
    background: hsl(var(--destructive, 0 84.2% 60.2%));
    color: white;
}

[class^="btn-"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: filter 0.2s ease;
    gap: 0.5rem;
}

[class^="btn-"]:active {
    filter: brightness(0.9);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: hsl(var(--muted-foreground));
    transition: all 0.2s ease;
}

.btn-ghost--danger {
    color: hsl(var(--destructive, 0 84.2% 60.2%));
}

.btn-ghost--danger:active {
    background: hsla(0, 84%, 60%, 0.1);
    border-color: hsla(0, 84%, 60%, 0.2);
}

.btn-ghost--sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ===== Results ===== */
.results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}

.result-item {
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.875rem 0.75rem;
    text-align: center;
    transition: border-color 0.2s ease;
}

.result-item.active {
    border-color: hsl(var(--primary));
}

.result-item__label {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.result-item__value {
    font-size: 1.3rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    font-variant-numeric: tabular-nums;
    direction: ltr;
    transition: color 0.2s ease;
}

.result-item.active .result-item__value {
    color: hsl(var(--primary));
}

.result-item__unit {
    font-size: 0.625rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.125rem;
}

.result-item__usd {
    font-size: 0.75rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin-top: 0.25rem;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
    min-height: 1.1em;
}

/* ===== Summary Card (Breakdown tab) ===== */
.card--summary {
    padding: 0.875rem 1rem;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0;
}

.summary-row+.summary-row {
    border-top: 1px solid hsl(var(--border));
}

.summary-row__label {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

.summary-row__value {
    font-size: 0.9rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.summary-row__value--primary {
    color: hsl(var(--primary));
}

/* ===== Tier Table ===== */
.tier-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8rem;
}

.tier-table thead th {
    background: hsl(var(--secondary));
    color: hsl(var(--muted-foreground));
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.5rem 0.375rem;
    text-align: center;
    white-space: nowrap;
}

.tier-table thead th:first-child {
    border-radius: 0 calc(var(--radius) - 2px) 0 0;
}

.tier-table thead th:last-child {
    border-radius: calc(var(--radius) - 2px) 0 0 0;
}

.tier-table tbody td {
    padding: 0.5rem 0.375rem;
    text-align: center;
    border-bottom: 1px solid hsl(var(--border));
    font-variant-numeric: tabular-nums;
}

.tier-table tbody tr:last-child td {
    border-bottom: none;
}

.tier-table tbody tr.active td {
    background: hsla(217, 91%, 60%, 0.06);
    color: hsl(var(--primary));
    font-weight: 600;
}

.tier-table tbody tr.inactive td {
    opacity: 0.35;
}

.tier-table tfoot td {
    padding: 0.6rem 0.375rem;
    text-align: center;
    font-weight: 700;
    background: hsl(var(--secondary));
    color: hsl(var(--primary));
}

.tier-table tfoot td:first-child {
    border-radius: 0 0 calc(var(--radius) - 2px) 0;
}

.tier-table tfoot td:last-child {
    border-radius: 0 0 0 calc(var(--radius) - 2px);
}

/* ===== Tariff Grid ===== */
.tariff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tariff-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: hsl(var(--secondary));
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.625rem 0.5rem;
    text-align: center;
}

.tariff-pill--flat {
    grid-column: 1 / -1;
    border-color: hsla(217, 91%, 60%, 0.15);
    background: hsla(217, 91%, 60%, 0.04);
}

.tariff-pill__range {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

.tariff-pill__price {
    font-size: 0.95rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    direction: ltr;
    margin-top: 0.125rem;
}

.tariff-pill__unit {
    font-size: 0.6rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.0625rem;
}

.tariff-pill__cumulative {
    margin-top: 0.625rem;
    padding-top: 0.5rem;
    border-top: 1px dashed hsl(var(--border));
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tariff-pill__cumulative-label {
    font-size: 0.6rem;
    color: hsl(var(--primary));
    font-weight: 600;
}

.tariff-pill__cumulative-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    direction: ltr;
}

/* ===== Note Text ===== */
.note-text {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.7;
}

/* ===== Contact List ===== */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

.contact-item:active {
    border-color: hsl(var(--primary));
}

.contact-item__icon {
    width: 36px;
    height: 36px;
    border-radius: calc(var(--radius) - 2px);
    background: hsla(217, 91%, 60%, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary));
    flex-shrink: 0;
}

.contact-item__icon svg {
    width: 16px;
    height: 16px;
}

.contact-item__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.contact-item__label {
    font-size: 0.65rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

.contact-item__value {
    font-size: 0.85rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    direction: ltr;
    text-align: right;
}

.contact-item__arrow {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.contact-item__arrow svg {
    width: 14px;
    height: 14px;
}

/* ===== Select Field ===== */
.select-field {
    width: 100%;
    height: 44px;
    padding: 0 1rem;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.select-field:focus {
    border-color: hsl(var(--ring));
}

/* ===== Result Summary (Advanced/Refrig) ===== */
.result-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.result-summary__label {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

.result-summary__value {
    font-size: 1.1rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.result-summary__value--primary {
    color: hsl(var(--primary));
    font-size: 1.35rem;
}

.result-summary__usd {
    font-size: 0.8rem;
    color: hsl(var(--primary));
    font-weight: 600;
    margin-right: 8px;
}

/* ===== Divider ===== */
.card__divider {
    height: 1px;
    background: hsl(var(--border));
    margin: 1rem 0;
}

/* ===== Toggles & Switches ===== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.toggle-row__label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.toggle-row__sub {
    display: block;
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
}

.toggle-group {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: hsl(var(--secondary) / 0.5);
    border-radius: var(--radius);
    animation: fadeIn 0.2s ease;
}

.toggle-group.visible {
    display: flex;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: hsl(var(--primary));
}

.check-row label {
    font-size: 0.85rem;
    color: hsl(var(--foreground));
    cursor: pointer;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: hsl(var(--muted));
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: hsl(var(--primary));
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* ===== Surcharge Rows ===== */
.surcharge-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.8rem;
}

.surcharge-article {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
}

.surcharge-label {
    flex: 1;
    color: hsl(var(--muted-foreground));
}

.surcharge-amount {
    font-weight: 600;
    color: hsl(var(--foreground));
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.surcharge-empty {
    text-align: center;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    padding: 10px 0;
    font-style: italic;
}

/* ===== Accordion ===== */
.accordion {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background-color: hsl(var(--card));
    margin-bottom: 16px;
    overflow: hidden;
}

.accordion__header {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: hsl(var(--foreground));
    font-weight: 600;
    font-family: inherit;
    transition: background 0.2s;
}

.accordion__header:hover {
    background-color: hsl(var(--muted) / 0.5);
}

.accordion__content {
    display: none;
    padding: 0 12px 16px;
    border-top: 1px solid hsl(var(--border));
}

.accordion.active .accordion__content {
    display: block;
    animation: fadeIn 0.2s ease;
}

.accordion__icon {
    transition: transform 0.2s;
    width: 16px;
    height: 16px;
}

.accordion.active .accordion__icon {
    transform: rotate(180deg);
}

.accordion .card {
    border: none;
    box-shadow: none;
    margin-bottom: 0;
    padding: 12px 0;
    background: transparent;
}

/* ===== Install Banner (positioned above bottom bar) ===== */
.install-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    position: fixed;
    bottom: calc(var(--bottombar-h) + 12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    max-width: 456px;
    margin: 0 auto;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    z-index: 100;
    box-shadow: 0 4px 20px hsla(0, 0%, 0%, 0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-banner.visible {
    display: flex;
}

.install-banner__text {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: hsl(var(--foreground));
}

.install-banner__btn {
    padding: 0.5rem 1rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.2s;
}

.install-banner__btn:active {
    filter: brightness(0.9);
}

.install-banner__close {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.install-banner__close svg {
    width: 20px;
    height: 20px;
}

/* ===== Info Icon Button ===== */
.info-trigger {
    background: none;
    border: none;
    padding: 2px;
    margin-inline-start: 6px;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.info-trigger:hover {
    color: hsl(var(--primary));
    background: hsl(var(--secondary));
}

.info-trigger svg {
    width: 14px;
    height: 14px;
}

/* ===== Modal (Dialog) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: hsla(0, 0%, 0%, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.visible {
    display: flex;
}

.modal-container {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px hsla(0, 0%, 0%, 0.1);
    padding: 1.5rem;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

/* Modal Variants */
.modal-container--decree {
    max-width: 440px;
    padding: 0;
    /* Header and body will handle padding */
}

.modal-header {
    margin-bottom: 1.25rem;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
}

.modal-description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.5;
}

.modal-header--decree {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    margin-bottom: 0;
}

.modal-body--decree {
    padding: 1.25rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: hsl(var(--foreground));
    white-space: pre-wrap;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-container--decree .modal-footer {
    padding: 1rem 1.5rem 1.25rem;
    margin-top: 0;
    border-top: 1px solid hsl(var(--border));
}

.modal-footer button {
    flex: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(12px) scale(0.98);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ===== Animations ===== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin-animation {
    animation: spin 1s linear infinite;
}

/* ===== Queue Results ===== */
.queue-item {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.1s ease, border-color 0.2s ease;
}

.queue-item:active {
    transform: scale(0.98);
    border-color: hsl(var(--primary));
}

.queue-item__rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: hsl(var(--primary));
    margin-bottom: 2px;
}

.queue-item__detail {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
    line-height: 1.4;
}

.queue-item__detail strong {
    color: hsl(var(--foreground));
    font-weight: 600;
}