/* ==========================================================================
   EASIWise Calculators – Shared Design System
   Version 2.0.0
   Self-contained styles; no Bootstrap required.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS custom properties (design tokens)
   -------------------------------------------------------------------------- */
.ew-calc {
    --ew-brand:         #2b92fd;
    --ew-brand-dark:    #1a7de8;
    --ew-success:       #28a745;
    --ew-text:          #212529;
    --ew-muted:         #6c757d;
    --ew-border:        #dee2e6;
    --ew-bg-card:       #ffffff;
    --ew-bg-body:       #f8f9fa;
    --ew-radius:        0.5rem;
    --ew-shadow:        0 2px 8px rgba(0, 0, 0, 0.10);
    --ew-input-height:  42px;
    --ew-font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   Wrapper
   -------------------------------------------------------------------------- */
.ew-calc {
    font-family: var(--ew-font);
    font-size: 1rem;
    color: var(--ew-text);
    line-height: 1.5;
    box-sizing: border-box;
    max-width: 820px;
    margin: 1.5rem auto;
}

.ew-calc *,
.ew-calc *::before,
.ew-calc *::after {
    box-sizing: inherit;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.ew-calc__card {
    background: var(--ew-bg-card);
    border-radius: var(--ew-radius);
    box-shadow: var(--ew-shadow);
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.ew-calc__header {
    background: var(--ew-brand);
    padding: 1.1rem 1.5rem;
}

.ew-calc__header h4 {
    margin: 0;
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Body
   -------------------------------------------------------------------------- */
.ew-calc__body {
    padding: 1.5rem;
    background: var(--ew-bg-body);
}

.ew-calc__intro {
    margin: 0 0 1.25rem;
    color: var(--ew-muted);
    font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   Input grid (two-column on wider screens)
   -------------------------------------------------------------------------- */
.ew-calc__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 540px) {
    .ew-calc__grid {
        grid-template-columns: 1fr;
    }
}

/* Full-width field override */
.ew-calc__field--full {
    grid-column: 1 / -1;
}

/* --------------------------------------------------------------------------
   Field
   -------------------------------------------------------------------------- */
.ew-calc__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ew-calc__field label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ew-text);
}

.ew-calc__hint {
    font-weight: 400;
    color: var(--ew-muted);
    font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Input group (input + unit adornment)
   -------------------------------------------------------------------------- */
.ew-calc__input-group {
    display: flex;
    align-items: stretch;
}

.ew-calc__input-group input,
.ew-calc__input-group .ew-calc__unit,
.ew-calc__input-group .ew-calc__prefix {
    height: var(--ew-input-height);
    border: 1px solid var(--ew-border);
    font-size: 1rem;
    line-height: 1;
}

.ew-calc__input-group input {
    flex: 1;
    min-width: 0;
    padding: 0 0.65rem;
    border-right: none;
    border-radius: var(--ew-radius) 0 0 var(--ew-radius);
    background: #fff;
    color: var(--ew-text);
    -webkit-appearance: none;
    appearance: none;
}

/* Read-only field */
.ew-calc__readonly {
    background: var(--ew-bg-body) !important;
    color: var(--ew-muted) !important;
    cursor: default;
}

.ew-calc__input-group input:focus {
    outline: 2px solid var(--ew-brand);
    outline-offset: -1px;
    z-index: 1;
    position: relative;
}

.ew-calc__unit {
    display: flex;
    align-items: center;
    padding: 0 0.65rem;
    background: #e9ecef;
    color: var(--ew-muted);
    font-size: 0.85rem;
    border-radius: 0 var(--ew-radius) var(--ew-radius) 0;
    white-space: nowrap;
}

/* Prefix variant (R prefix + unit suffix) */
.ew-calc__input-group--prefix .ew-calc__prefix {
    display: flex;
    align-items: center;
    padding: 0 0.65rem;
    background: #e9ecef;
    color: var(--ew-muted);
    font-size: 0.85rem;
    border-radius: var(--ew-radius) 0 0 var(--ew-radius);
    white-space: nowrap;
}

.ew-calc__input-group--prefix input {
    border-left: none;
    border-radius: 0;
}

/* --------------------------------------------------------------------------
   Select
   -------------------------------------------------------------------------- */
.ew-calc__select {
    width: 100%;
    height: var(--ew-input-height);
    padding: 0 0.75rem;
    border: 1px solid var(--ew-border);
    border-radius: var(--ew-radius);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236c757d' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    -webkit-appearance: none;
    appearance: none;
    font-size: 1rem;
    color: var(--ew-text);
    cursor: pointer;
}

.ew-calc__select:focus {
    outline: 2px solid var(--ew-brand);
    outline-offset: -1px;
}

/* --------------------------------------------------------------------------
   Actions
   -------------------------------------------------------------------------- */
.ew-calc__actions {
    margin-bottom: 1.25rem;
}

.ew-calc__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    height: 46px;
    padding: 0 1.5rem;
    background: var(--ew-brand);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--ew-radius);
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ew-calc__btn:hover,
.ew-calc__btn:focus {
    background: var(--ew-brand-dark);
    outline: none;
}

.ew-calc__btn:focus-visible {
    outline: 2px solid var(--ew-brand-dark);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Validation message
   -------------------------------------------------------------------------- */
.ew-calc__validation {
    padding: 0.6rem 0.9rem;
    margin-bottom: 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--ew-radius);
    font-size: 0.9rem;
    color: #664d03;
}

/* --------------------------------------------------------------------------
   Results section
   -------------------------------------------------------------------------- */
.ew-calc__results {
    border-top: 1px solid var(--ew-border);
    padding-top: 1.25rem;
    margin-top: 0.25rem;
}

.ew-calc__results h5 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ew-text);
}

/* Results grid */
.ew-calc__results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 480px) {
    .ew-calc__results-grid {
        grid-template-columns: 1fr;
    }
}

/* Individual result card */
.ew-calc__result-card {
    background: #fff;
    border: 1px solid var(--ew-border);
    border-radius: var(--ew-radius);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ew-calc__result-card--highlight {
    border-color: var(--ew-brand);
    background: #eaf4ff;
}

.ew-calc__result-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ew-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ew-calc__result-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ew-text);
}

.ew-calc__result-value--saving {
    color: var(--ew-success);
}

/* --------------------------------------------------------------------------
   Summary note
   -------------------------------------------------------------------------- */
.ew-calc__summary {
    background: #fff;
    border: 1px solid var(--ew-border);
    border-radius: var(--ew-radius);
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    color: var(--ew-muted);
    margin-top: 0.25rem;
}

.ew-calc__summary p {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Panel recommendation display
   -------------------------------------------------------------------------- */
.ew-calc__recommendation {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: #fff;
    border: 1px solid var(--ew-border);
    border-radius: var(--ew-radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.ew-calc__rec-icon {
    font-size: 2.5rem;
    color: var(--ew-brand);
    line-height: 1;
    flex-shrink: 0;
}

.ew-calc__rec-body {
    flex: 1;
}

.ew-calc__rec-count {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ew-brand);
}

.ew-calc__rec-package {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ew-text);
}

.ew-calc__rec-note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ew-muted);
}

@media (max-width: 400px) {
    .ew-calc__recommendation {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* --------------------------------------------------------------------------
   Utility: hidden elements (JS will toggle via `hidden` attribute)
   -------------------------------------------------------------------------- */
.ew-calc [hidden] {
    display: none !important;
}
