/* Education Cost Calculator Styles - Fixed Dropdown Visibility */
.ecc-calculator-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Fix: Ensure container has proper stacking context */
    z-index: 1;
}

/* Header */
.ecc-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin: -20px -20px 30px -20px;
    /* Fix: Ensure header doesn't interfere with dropdowns */
    position: relative;
    z-index: 2;
}

.ecc-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
}

.ecc-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 16px;
}

/* Form Styles */
.ecc-form {
    margin-bottom: 30px;
    /* Fix: Ensure form has proper z-index context */
    position: relative;
    z-index: 10;
}

.ecc-input-group {
    background: #f8f9ff;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    /* Fix: Prevent input group from clipping dropdowns */
    position: relative;
    z-index: 5;
    overflow: visible;
}

.ecc-input-group h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.ecc-field {
    margin-bottom: 20px;
    position: relative;
    /* Fix: Ensure each field container allows dropdown overflow */
    z-index: 1;
}

/* Fix: Special handling for select fields */
.ecc-field:has(select) {
    z-index: 100;
}

.ecc-field select:focus,
.ecc-field select:active,
.ecc-field select[aria-expanded="true"] {
    z-index: 200;
}

.ecc-field-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    /* Fix: Ensure row containers don't clip dropdowns */
    position: relative;
    z-index: 1;
}

.ecc-field-half {
    flex: 1;
    /* Fix: Allow dropdown overflow in half-width fields */
    position: relative;
}

/* Fix: Ensure first field in row has higher z-index */
.ecc-field-row .ecc-field-half:first-child {
    z-index: 101;
}

.ecc-field-row .ecc-field-half:last-child {
    z-index: 100;
}

.ecc-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.ecc-field input[type="number"],
.ecc-field select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
    background: #ffffff;
    /* Fix: Remove problematic appearance settings that can cause rendering issues */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    position: relative;
}

/* Fix: Improved dropdown arrow and positioning */
.ecc-field select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23667eea"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 45px;
    cursor: pointer;
    /* Fix: Ensure select dropdown is properly positioned */
    position: relative;
    z-index: 10;
}

/* Fix: Enhanced focus and active states for better dropdown visibility */
.ecc-field input[type="number"]:focus,
.ecc-field select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #ffffff;
    /* Fix: Ensure focused elements are on top */
    position: relative;
    z-index: 50;
}

/* Fix: Specific styles for active/open select dropdowns */
.ecc-field select:focus,
.ecc-field select:active {
    z-index: 200 !important;
    position: relative;
}

.ecc-input-with-currency {
    position: relative;
    display: block;
}

.ecc-currency-symbol {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #667eea;
    z-index: 3;
    font-size: 16px;
    pointer-events: none;
    background: transparent;
}

.ecc-input-with-currency input {
    padding-left: 45px !important;
}

/* Field help and notes */
.ecc-field-help {
    cursor: help;
    display: inline-block;
    margin-left: 5px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    font-size: 12px;
}

.ecc-field-help:hover {
    opacity: 1;
}

.ecc-field-note {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
    line-height: 1.3;
}

/* Fix: Improved select dropdown option visibility */
.ecc-field select option {
    padding: 8px 12px;
    background: #ffffff;
    color: #333;
    border: none;
    /* Fix: Ensure options are readable */
    font-size: 14px;
    line-height: 1.4;
}

.ecc-field select:hover {
    border-color: #667eea;
}

/* Advanced Options */
.ecc-advanced-section {
    margin: 25px 0;
    /* Fix: Ensure advanced section doesn't interfere with dropdowns */
    position: relative;
    z-index: 3;
}

.ecc-toggle-advanced {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 4;
}

.ecc-toggle-advanced:hover {
    background: #5a6fd8;
}

.ecc-toggle-icon {
    transition: transform 0.3s ease;
}

.ecc-toggle-advanced.active .ecc-toggle-icon {
    transform: rotate(180deg);
}

.ecc-advanced-options {
    background: #f5f7ff;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-top: 10px;
    animation: slideDown 0.3s ease;
    /* Fix: Ensure advanced options allow dropdown overflow */
    position: relative;
    z-index: 10;
    overflow: visible;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 20px;
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding: 20px;
    }
}

/* Checkbox Styling */
.ecc-field input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    transform: scale(1.2);
}

.ecc-field label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Form Actions */
.ecc-form-actions {
    text-align: center;
    margin-top: 30px;
    position: relative;
    z-index: 2;
}

.ecc-calculate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    min-width: 200px;
    position: relative;
}

.ecc-calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(102, 126, 234, 0.3);
}

.ecc-calculate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.ecc-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Results Section */
.ecc-results {
    background: #ffffff;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.ecc-results-header h3 {
    margin: 0 0 25px 0;
    color: #333;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.ecc-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ecc-result-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8edff 100%);
    border: 2px solid #d1d9ff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ecc-result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.15);
}

.ecc-result-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.ecc-result-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.ecc-result-value.primary {
    color: #667eea;
    font-size: 28px;
}

.ecc-result-subtitle {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* Chart Section */
.ecc-chart-section {
    margin: 30px 0;
    text-align: center;
    position: relative;
    z-index: 1;
}

.ecc-toggle-chart {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.ecc-toggle-chart:hover {
    background: #218838;
}

.ecc-chart-container {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.ecc-chart-container canvas {
    max-width: 100%;
    height: auto;
}

/* Share Section */
.ecc-share-section {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

.ecc-share-btn,
.ecc-print-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.ecc-print-btn {
    background: #6c757d;
}

.ecc-share-btn:hover {
    background: #138496;
}

.ecc-print-btn:hover {
    background: #545b62;
}

/* Monetization Section */
.ecc-monetization-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e1e5e9;
    position: relative;
    z-index: 1;
}

.ecc-ad-placement {
    margin: 20px 0;
    text-align: center;
    min-height: 100px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-style: italic;
}

.ecc-ad-placement:empty::before {
    content: "Advertisement";
}

.ecc-affiliate-section h4 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.ecc-affiliate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.ecc-affiliate-card {
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.ecc-affiliate-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.15);
}

.ecc-affiliate-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.ecc-affiliate-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    line-height: 1.4;
}

.ecc-affiliate-cta {
    background: #fd7e14;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.ecc-affiliate-cta:hover {
    background: #e8690b;
    color: white;
    text-decoration: none;
}

/* Mobile Sticky Ad */
.ecc-mobile-sticky-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #e1e5e9;
    padding: 10px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.1);
    display: none;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .ecc-calculator-container {
        margin: 10px;
        padding: 15px;
        border-radius: 8px;
    }
    
    .ecc-header {
        margin: -15px -15px 20px -15px;
        padding: 15px;
    }
    
    .ecc-header h2 {
        font-size: 22px;
    }
    
    .ecc-subtitle {
        font-size: 14px;
    }
    
    /* Fix: Stack field rows on mobile to prevent dropdown clipping */
    .ecc-field-row {
        flex-direction: column;
        gap: 0;
    }
    
    .ecc-field-half {
        margin-bottom: 20px;
        /* Fix: Reset z-index on mobile for proper stacking */
        z-index: auto;
    }
    
    .ecc-input-group {
        padding: 20px 15px;
        /* Fix: Ensure mobile input groups don't clip */
        overflow: visible;
    }
    
    .ecc-results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .ecc-result-card {
        padding: 15px;
    }
    
    .ecc-result-value {
        font-size: 20px;
    }
    
    .ecc-result-value.primary {
        font-size: 24px;
    }
    
    .ecc-affiliate-grid {
        grid-template-columns: 1fr;
    }
    
    .ecc-share-section {
        flex-direction: column;
        align-items: center;
    }
    
    .ecc-share-btn,
    .ecc-print-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .ecc-mobile-sticky-ad {
        display: block;
    }
    
    /* Add bottom padding to body when sticky ad is visible */
    body.ecc-mobile-sticky-visible {
        padding-bottom: 80px;
    }

    /* Fix: Mobile dropdown improvements */
    .ecc-field select {
        /* Ensure dropdowns are properly sized on mobile */
        min-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .ecc-calculator-container {
        margin: 5px;
        padding: 10px;
    }
    
    .ecc-header {
        margin: -10px -10px 15px -10px;
        padding: 12px;
    }
    
    .ecc-header h2 {
        font-size: 20px;
    }
    
    .ecc-input-group {
        padding: 15px 10px;
    }
    
    .ecc-field input[type="number"],
    .ecc-field select {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 48px; /* Touch-friendly size */
    }
    
    .ecc-calculate-btn {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
    }
    
    .ecc-results {
        padding: 20px 15px;
    }
    
    .ecc-chart-container {
        padding: 15px 10px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ecc-calculator-container {
        background: #1a1a1a;
        color: #e0e0e0;
        border: 2px solid #333;
    }
    
    .ecc-input-group {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .ecc-input-group h3 {
        color: #e0e0e0;
        border-bottom-color: #667eea;
    }
    
    .ecc-field label {
        color: #e0e0e0;
    }
    
    .ecc-field input[type="number"],
    .ecc-field select {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .ecc-field input[type="number"]:focus,
    .ecc-field select:focus {
        border-color: #667eea;
        background: #2a2a2a;
    }
    
    .ecc-advanced-options {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .ecc-results {
        background: #1a1a1a;
        border-color: #444;
    }
    
    .ecc-results-header h3 {
        color: #e0e0e0;
    }
    
    .ecc-result-card {
        background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
        border-color: #555;
    }
    
    .ecc-result-label {
        color: #bbb;
    }
    
    .ecc-result-value {
        color: #e0e0e0;
    }
    
    .ecc-affiliate-card {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .ecc-affiliate-title {
        color: #e0e0e0;
    }
    
    .ecc-affiliate-description {
        color: #bbb;
    }

    /* Fix: Dark mode dropdown options */
    .ecc-field select option {
        background: #333;
        color: #e0e0e0;
    }
}

/* Loading States */
.ecc-loading {
    opacity: 0.6;
    pointer-events: none;
}

.ecc-fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Accessibility Improvements */
.ecc-field input:focus-visible,
.ecc-field select:focus-visible,
.ecc-calculate-btn:focus-visible,
.ecc-toggle-advanced:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .ecc-calculator-container {
        border: 3px solid #000;
    }
    
    .ecc-field input[type="number"],
    .ecc-field select {
        border: 3px solid #000;
    }
    
    .ecc-calculate-btn {
        background: #000;
        border: 2px solid #fff;
    }
}

/* Fix: Additional dropdown-specific improvements */
.ecc-field select::-ms-expand {
    display: none; /* Remove IE dropdown arrow */
}

/* Fix: Ensure dropdowns work properly on touch devices */
@media (hover: none) and (pointer: coarse) {
    .ecc-field select {
        font-size: 16px;
        min-height: 44px;
    }
    
    .ecc-field select:focus {
        font-size: 16px; /* Maintain size to prevent zoom */
    }
}

/* Fix: Specific z-index management for overlapping elements */
.ecc-field:nth-child(1) { z-index: 105; }
.ecc-field:nth-child(2) { z-index: 104; }
.ecc-field:nth-child(3) { z-index: 103; }
.ecc-field:nth-child(4) { z-index: 102; }
.ecc-field:nth-child(5) { z-index: 101; }

/* Fix: Ensure select dropdowns are always on top when active */
.ecc-field select:focus,
.ecc-field select:active,
.ecc-field select[size]:not([size="1"]) {
    z-index: 999 !important;
    position: relative;
}
