/**
 * Calc Engine - Base Styles
 * 
 * These are minimal, clean styles that work with any WordPress theme.
 * Each calculator can override these with its own style.css file.
 */

/* Conditional field visibility */
.calc-field-conditional.calc-field-hidden {
    display: none !important;
}

/* Calculator Wrapper */
.calc-wrapper {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Header */
.calc-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.calc-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
}

.calc-description {
    margin: 0;
    color: #666;
    font-size: 0.95rem;
}

/* Form and Fields */
.calc-form {
    margin: 0;
}

.calc-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.calc-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.calc-field label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #333;
}

.calc-field label .required {
    color: #dc3545;
}

.calc-field input[type="text"],
.calc-field input[type="number"],
.calc-field input[type="email"],
.calc-field select,
.calc-field textarea {
    padding: 0.65rem 0.85rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.calc-field input:focus,
.calc-field select:focus,
.calc-field textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.calc-field input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.calc-help {
    font-size: 0.8rem;
    color: #888;
}

/* Radio Group */
.calc-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.calc-radio-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-weight: normal;
}

/* Actions */
.calc-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.calc-button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.calc-button:active {
    transform: scale(0.98);
}

.calc-submit {
    background-color: #0073aa;
    color: #fff;
}

.calc-submit:hover {
    background-color: #005a87;
}

.calc-reset {
    background-color: #f0f0f0;
    color: #333;
}

.calc-reset:hover {
    background-color: #e0e0e0;
}

/* Results */
.calc-results {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border-left: 4px solid #0073aa;
}

.calc-output {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.calc-output:last-child {
    border-bottom: none;
}

.calc-output-label {
    font-weight: 500;
    color: #555;
}

.calc-output-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
}

.calc-output-value.calc-output-updated {
    animation: calc-highlight 0.5s ease;
}

@keyframes calc-highlight {
    0% {
        background-color: rgba(0, 115, 170, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* Errors */
.calc-error {
    padding: 1rem;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    color: #c53030;
    text-align: center;
}

.calc-error-message {
    color: #c53030;
    font-weight: 500;
    text-align: center;
    padding: 0.5rem;
}

/* Block Editor Preview */
.calc-block-preview {
    padding: 2rem;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 6px;
    text-align: center;
}

.calc-block-selected {
    color: #0073aa;
}

.calc-block-empty {
    color: #888;
}

.calc-block-preview .dashicons {
    font-size: 1.5rem;
    vertical-align: middle;
}

/* Responsive */
@media (max-width: 600px) {
    .calc-wrapper {
        margin: 1rem;
        padding: 1rem;
    }
    
    .calc-title {
        font-size: 1.25rem;
    }
    
    .calc-actions {
        flex-direction: column;
    }
    
    .calc-button {
        width: 100%;
    }
    
    .calc-output {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .calc-wrapper {
        background: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .calc-title {
        color: #f0f0f0;
    }
    
    .calc-description {
        color: #aaa;
    }
    
    .calc-field label {
        color: #ddd;
    }
    
    .calc-field input,
    .calc-field select,
    .calc-field textarea {
        background: #2d2d2d;
        border-color: #444;
        color: #f0f0f0;
    }
    
    .calc-results {
        background: linear-gradient(135deg, #2d2d2d 0%, #252525 100%);
    }
    
    .calc-output-label {
        color: #bbb;
    }
    
    .calc-output-value {
        color: #f0f0f0;
    }
}

/* ============================================
   Prominent "Estimated" price indicator
   Shown when a live rate is unavailable (price source = default).
   !important is used deliberately to override per-calculator
   .price-source rules, which are scoped with very high specificity
   (#calc-id #metal-price-display .price-source).
   ============================================ */
.price-source.price-source-estimated {
    display: inline-block !important;
    background: #fff3cd !important;
    color: #8a6d00 !important;
    border: 1px solid #ffe69c !important;
    border-radius: 4px !important;
    padding: 3px 10px !important;
    margin-top: 6px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.2px !important;
}
.price-source.price-source-estimated::before {
    content: "\26A0  ";
    font-weight: 700;
}

/* ============================================
   v2.7.0 UI polish
   ============================================ */

/* Visible keyboard focus on buttons (inputs already have focus rings) */
.calc-button:focus-visible {
    outline: 3px solid rgba(0, 115, 170, 0.55);
    outline-offset: 2px;
}

/* Slight lift on hover; pressed state already scales down */
.calc-button {
    will-change: transform;
}

.calc-submit:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.calc-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Gentle entrance when the results panel first appears */
@keyframes calc-results-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.calc-results {
    animation: calc-results-in 0.25s ease-out;
}

/* Make long select option text behave on small screens */
.calc-field select {
    text-overflow: ellipsis;
}

/* Comfortable touch targets on mobile (WCAG 2.5.8) */
@media (max-width: 600px) {
    .calc-button {
        min-height: 44px;
    }

    .calc-field input[type="text"],
    .calc-field input[type="number"],
    .calc-field select {
        min-height: 44px;
    }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .calc-results {
        animation: none;
    }

    .calc-output-value.calc-output-updated {
        animation: none;
    }

    .calc-button,
    .calc-field input,
    .calc-field select,
    .calc-field textarea {
        transition: none;
    }

    .calc-button:active {
        transform: none;
    }
}
