/* Base Calculator Container */
.ai-savings-calculator {
    background: #0f0122;
    padding: 20px;
    color: white;
    margin: 2rem auto;
    border-radius: 8px;
    width: 95%;
    max-width: 1200px;
}

/* Form Container */
#ai-savings-form {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Section Styling */
.calculator-section {
    margin-bottom: 2rem;
}

.calculator-section h3 {
    color: #28A3F2;
    margin-bottom: 1.5rem;
    font-weight: bold;
}

/* Form Group Styling */
.input-group {
    margin-bottom: 1.5rem;
}

/* Default (Mobile) Layout */
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: white;
}

/* Number Input Styling */
.input-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #333;
    background: #111;
    color: white;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1rem;
    /* Remove default -moz styling */
    -moz-appearance: textfield;
}

/* Style the spinners */
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    background: #28A3F2;
    border-left: 1px solid #333;
    height: 30px;
    position: relative;
    right: 4px;
    padding: 0 4px;
    cursor: pointer;
    -webkit-appearance: inner-spin-button;
}

/* Hover state for spinners */
.input-group input[type="number"]::-webkit-inner-spin-button:hover,
.input-group input[type="number"]::-webkit-outer-spin-button:hover {
    background: #1e8ad7;
}

/* Firefox specific styling */
@supports (-moz-appearance: none) {
    .input-group input[type="number"] {
        padding-right: 30px;
    }
    
    .input-group {
        position: relative;
    }
    
    .input-group::after {
        content: "";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 20px;
        height: 100%;
        background: #28A3F2;
        border-left: 1px solid #333;
        border-radius: 0 4px 4px 0;
        pointer-events: none;
    }
}

/* Tablet and Desktop Layout */
@media screen and (min-width: 768px) {
    .input-group {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        max-width: 700px;
        margin-left: auto;
        margin-right: auto;
    }

    .input-group label {
        width: 250px;
        margin-bottom: 0;
        padding-right: 20px;
        -ms-flex-negative: 0;
        flex-shrink: 0;
        text-align: right;
    }

    .input-group input[type="number"],
    .input-group select {
        -webkit-box-flex: 1;
        -ms-flex: 1;
        flex: 1;
        max-width: 300px;
        margin-bottom: 0;
    }
}

/* Button Styling */
.calculate-button {
    background: #28A3F2;
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    -webkit-transition: background 0.3s ease;
    transition: background 0.3s ease;
    font-weight: bold;
    width: 100%;
    max-width: 300px;
    margin: 2rem auto;
    display: block;
}

.calculate-button:hover {
    background: #1e8ad7;
}

/* Results Section Base Styling */
.results-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #1a0235;
    border: 1px solid #333;
    border-radius: 4px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* Results Header */
.results-header {
    margin-bottom: 2rem;
    text-align: center;
}

.results-header h3 {
    color: #28A3F2;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.feasibility-score {
    background: rgba(40, 163, 242, 0.1);
    padding: 0.75rem;
    border-radius: 4px;
    display: inline-block;
}

.score-label {
    color: #ccc;
    margin-right: 0.5rem;
}

.score-value {
    color: #28A3F2;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Results Overview Cards */
.results-overview {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    margin-left: -1rem;
    margin-right: -1rem;
}

.overview-card {
    flex: 1 1 200px;
    background: rgba(40, 163, 242, 0.05);
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
    border: 1px solid rgba(40, 163, 242, 0.2);
    margin: 0 1rem 1rem 1rem;
    min-width: 200px;
}

.card-label {
    color: #ccc;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.card-value {
    color: white;
    font-size: 1.25rem;
    font-weight: bold;
}

/* Results Table */
.results-table-wrapper {
    margin: 2rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.results-table th,
.results-table td {
    padding: 1rem;
    text-align: left;
    border: 1px solid #333;
}

.results-table th {
    background: #28A3F2;
    color: #0f0122;
    font-weight: bold;
    white-space: nowrap;
}

.results-table td {
    color: white;
}

.results-table tr:hover {
    background: rgba(40, 163, 242, 0.05);
}

.results-table tr.highlight {
    background: rgba(40, 163, 242, 0.1);
}

/* Savings Breakdown */
.savings-breakdown {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(40, 163, 242, 0.05);
    border-radius: 4px;
}

.savings-breakdown h4 {
    color: #28A3F2;
    margin-bottom: 1rem;
    text-align: center;
}

.breakdown-grid {
    display: flex;
    flex-wrap: wrap;
    margin-left: -1rem;
    margin-right: -1rem;
}

.breakdown-card {
    flex: 1 1 200px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    text-align: center;
    margin: 0 1rem 1rem 1rem;
    min-width: 200px;
}

.breakdown-label {
    color: #28A3F2;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.breakdown-value {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.breakdown-percent {
    color: #ccc;
    font-size: 0.9rem;
}

/* Implementation Notes */
.savings-notes {
    margin-top: 2rem;
    padding: 1.5rem;
    border-top: 1px solid #333;
}

.savings-notes h4 {
    color: #28A3F2;
    margin-bottom: 1rem;
}

.savings-notes ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.savings-notes li {
    color: #ccc;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.savings-notes li:before {
    content: "•";
    color: #28A3F2;
    position: absolute;
    left: 0;
}

/* Mobile Responsiveness */
@media screen and (max-width: 767px) {
    /* Base container adjustments */
    .results-section {
        padding: 1rem;
        margin: 0;  /* Remove side margins */
        width: 100%;  /* Use full width */
        max-width: none;  /* Remove max-width constraint */
        border-radius: 0;  /* Remove border radius */
    }

    /* Overview and breakdown cards */
    .results-overview,
    .breakdown-grid {
        margin-left: 0;
        margin-right: 0;
    }

    .overview-card,
    .breakdown-card {
        flex: 1 1 100%;
        min-width: unset;
        margin: 0 0 1rem 0;  /* Remove side margins, keep bottom margin */
        width: 100%;
    }

    /* Table adjustments */
    .results-table-wrapper {
        margin: 1rem -1rem;  /* Negative margin to allow full width scroll */
        padding: 0 1rem;
        width: 100vw;  /* Use viewport width */
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        background: #1a0235;  /* Match section background */
    }

    .results-table {
        min-width: 100%;
    }

    .results-table th,
    .results-table td {
        padding: 0.75rem;
        font-size: 0.9rem;
        min-width: 100px;  /* Ensure minimum column width */
    }

    /* Savings breakdown section */
    .savings-breakdown {
        margin: 1rem 0;
        padding: 1rem;
        width: 100%;
    }

    /* Notes section */
    .savings-notes {
        padding: 1rem;
        margin-top: 1rem;
    }

    .savings-notes li {
        padding-left: 1.25rem;  /* Slightly reduce padding for mobile */
    }

    /* Header adjustments */
    .results-header {
        margin-bottom: 1rem;
    }

    .results-header h3 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .feasibility-score {
        padding: 0.5rem 0.75rem;
        width: 100%;  /* Full width score display */
        box-sizing: border-box;
    }

    /* Value text adjustments */
    .card-value,
    .breakdown-value {
        font-size: 1.1rem;
        word-break: break-word;  /* Prevent overflow */
    }
}

/* Small mobile devices */
@media screen and (max-width: 375px) {
    .results-section {
        padding: 0.75rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .card-value,
    .breakdown-value {
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {
    .results-section {
        background: white;
        color: black;
        border: 1px solid #000;
    }

    .results-table th {
        background: #f0f0f0;
        color: black;
    }

    .overview-card,
    .breakdown-card {
        border: 1px solid #000;
        background: none;
    }

    .results-table td {
        color: black;
    }

    .savings-notes li {
        color: black;
    }
}

/* Accessibility Focus States */
.input-group input[type="number"]:focus,
.input-group select:focus,
.calculate-button:focus {
    outline: none;
    border-color: #28A3F2;
    box-shadow: 0 0 0 2px rgba(40, 163, 242, 0.2);
}

/* Error State */
.error-message {
    color: #ff3939;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Loading State */
.calculate-button.loading {
    opacity: 0.7;
    cursor: wait;
}

/* Print Styles */
@media print {
    .ai-savings-calculator {
        background: white;
        color: black;
    }
    
    .calculate-button {
        display: none;
    }
    
    .results-table {
        border: 1px solid #000;
    }
    
    .results-table th,
    .results-table td {
        border: 1px solid #000;
    }
    
    .results-section {
        background: none;
        border: 1px solid #000;
    }
}