.ast-ppc-calculator-wrapper {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif !important;
    font-size: 15px; /* Adjusted size */
    font-weight: 500; /* Medium weight for better presence */
    line-height: 1.6; /* Improved line spacing */
    color: #1F2937; /* Dark Charcoal */
    --theme-primary-color: #1F2937; /* Dark Charcoal */
    --theme-accent-color: #19998b;  /* Emerald 500 */
    --theme-neutral-bg: #F9FAFB;   /* Gray 50 */
    --theme-border-color: #E5E7EB; /* Gray 200 - Default border color */
    box-sizing: border-box;
}

.ast-ppc-calculator-wrapper *,
.ast-ppc-calculator-wrapper *::before,
.ast-ppc-calculator-wrapper *::after {
    box-sizing: inherit;
}

.ast-ppc-calculator-wrapper .ast-ppc-calculator {
    display: flex;
    gap: 2rem; /* Reduced gap between columns */
    flex-wrap: wrap; /* Allow items to wrap */
    max-width: 1100px; /* Reduced width */
    margin: 2rem auto;
    background: #ffffff;
    padding: 28px; /* Reduced overall padding */
    border-radius: 10px;
    /* border: 1px solid var(--theme-border-color); */ /* Removed border, rely on shadow */
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); /* Slightly stronger shadow */
}

.ast-ppc-calculator-wrapper .ast-ppc-column {
    flex: 1;
}

.ast-ppc-calculator-wrapper .ast-ppc-inputs-column {
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Increased vertical gap */
}

.ast-ppc-calculator-wrapper .ast-ppc-input-row {
    display: grid; /* Use Grid */
    grid-template-columns: repeat(3, 1fr); /* Create 3 equal columns */
    align-items: end; /* Align items to the bottom of the cell */
    gap: 1rem;
}

.ast-ppc-calculator-wrapper .ast-ppc-input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    position: relative; /* Needed for absolute positioning of pseudo-element */
}

.ast-ppc-calculator-wrapper .ast-ppc-input-group label {
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #374151 !important; /* Darker grey for labels (Gray 700) */
    margin-bottom: 0.25rem;
    display: inline-flex;
    align-items: center;
    font-family: inherit !important;
    line-height: normal !important;
}

.ast-ppc-calculator-wrapper .ast-ppc-input-group input[type="text"] {
    box-sizing: border-box;
    width: 100%;
    appearance: none;
    padding: 12px 14px; /* Slightly more padding */
    font-family: inherit !important;
    font-size: 16px !important;
    color: #232425 !important;
    background-color: #fff !important;
    border: 1px solid var(--theme-border-color) !important; /* Default light grey border */
    border-radius: 4px !important;
    transition: border-color 150ms ease-in-out, box-shadow 150ms ease-in-out;
    box-shadow: none !important;
}

.ast-ppc-calculator-wrapper .ast-ppc-input-group input[type="text"]:hover {
    border-color: #9CA3AF !important; /* Slightly darker grey on hover */
}

.ast-ppc-calculator-wrapper .ast-ppc-input-group input[type="text"]:focus {
    border-color: var(--theme-accent-color) !important; /* Accent green border on focus */
    box-shadow: 0 0 0 3px rgba(25, 153, 139, 0.15) !important; /* Subtle green glow */
    outline: none !important; /* Remove default outline */
}

.ast-ppc-calculator-wrapper .ast-ppc-range-group {
    margin-top: 1rem;
}

.ast-ppc-calculator-wrapper .ast-range-display {
    text-align: left;
    margin-bottom: 0.25rem;
}

.ast-ppc-calculator-wrapper #ast-conv-rate-display {
    font-weight: bold;
    font-size: 1.2em; /* Slightly larger */
    color: var(--theme-primary-color) !important;
}

.ast-ppc-calculator-wrapper input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--theme-neutral-bg); /* Base track light grey */
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    margin: 0.5rem 0;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

.ast-ppc-calculator-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--theme-accent-color) !important; /* Green thumb */
    border-radius: 50%;
    border: none; /* Remove white border */
    cursor: pointer;
    margin-top: -6px; /* Vertically center thumb */
}

.ast-ppc-calculator-wrapper input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--theme-accent-color) !important; /* Green thumb */
    border-radius: 50%;
    border: none; /* Remove default border */
    cursor: pointer;
}

.ast-ppc-calculator-wrapper .ast-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #555 !important;
}

.ast-ppc-calculator-wrapper .ast-ppc-results-box {
    background-color: #F3F4F6 !important; /* Slightly darker neutral bg (Gray 100) */
    border-radius: 10px !important;
    border: 1px solid var(--theme-border-color) !important; /* Add light border back */
    padding: 24px !important; /* Reduced results padding */
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ast-ppc-calculator-wrapper .ast-ppc-result-row {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.ast-ppc-calculator-wrapper .ast-ppc-result-item {
    flex: 1;
    text-align: left;
}

.ast-ppc-calculator-wrapper .ast-ppc-result-item label {
    font-size: 15px !important;
    font-weight: 500 !important;
    display: block !important;
    margin-bottom: 0.25rem;
    color: #232425 !important;
    font-family: inherit !important;
}

.ast-ppc-calculator-wrapper .ast-result-value {
    font-size: 1.4em !important;
    font-weight: 700 !important;
    display: block !important;
    color: var(--theme-primary-color) !important; /* Ensure primary dark text */
    font-family: inherit !important;
    animation: ast-flash 0.4s linear;
}

@keyframes ast-flash {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

.ast-ppc-calculator-wrapper .ast-tooltip {
    display: inline-block;
    position: relative;
    background-color: var(--theme-accent-color) !important; /* Use accent green */
    color: white !important;
    border-radius: 50%;
    width: 1rem; /* Reverted size */
    height: 1rem;
    line-height: 1rem; /* Match height */
    font-size: 0.75rem !important;
    font-weight: normal !important;
    text-align: center;
    cursor: help;
    margin-left: 5px;
    vertical-align: middle;
}

.ast-ppc-calculator-wrapper .ast-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    background-color: var(--theme-primary-color) !important; /* Use theme primary */
    color: #fefefe !important;
    padding: 0.5rem;
    border-radius: 3px;
    font-size: 0.9rem !important;
    font-weight: normal !important;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif !important;
    text-align: center;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    min-width: 150px;
    max-width: 240px;
    white-space: normal;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ast-ppc-calculator-wrapper .ast-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(130% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--theme-primary-color) transparent transparent transparent !important; /* Match tooltip background */
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.ast-ppc-calculator-wrapper .ast-tooltip:hover::after,
.ast-ppc-calculator-wrapper .ast-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 992px) { /* Adjust breakpoint if needed */
    /* Center labels when inputs stack */
    .ast-ppc-calculator-wrapper .ast-ppc-input-group label {
        text-align: center;
        justify-content: center; /* Center label content (including tooltip icon) */
    }

    .ast-ppc-calculator-wrapper .ast-ppc-calculator {
        grid-template-columns: 1fr; /* Stack columns */
        gap: 1rem; /* Reduced gap between input groups */
    }

    .ast-ppc-calculator-wrapper .ast-ppc-inputs-column {
        gap: 1rem; /* Reduced gap between input groups */
    }

    .ast-ppc-calculator-wrapper .ast-ppc-input-row {
        grid-template-columns: 1fr; /* Stack top inputs */
        gap: 1rem; /* Keep consistent gap */
    }

    .ast-ppc-calculator-wrapper .ast-ppc-results-box {
        padding: 16px; /* Reduced padding */
    }

    /* Adjust relocated save section for mobile */
    .ast-ppc-calculator-wrapper .ast-ppc-save-section {
        margin-top: 1.5rem; /* Add some space above */
        padding-top: 1rem; /* Adjust padding */
        border-top: 1px solid var(--theme-border-color); /* Use border color for divider */
        display: flex; /* Align button better */
        flex-direction: column;
        gap: 1rem;
    }

    .ast-ppc-calculator-wrapper .ast-ppc-save-section .ast-button {
        width: 100%; /* Make button full width */
    }
}

/* --- Save/Load/Export Section Styles --- */
.ast-ppc-calculator-wrapper .ast-ppc-save-section {
    width: 100%; /* Force full width */
    margin-top: 2rem; /* Increased space above */
    padding-top: 1.5rem; /* Keep padding */
    border-top: 1px solid var(--theme-border-color); /* Use standard border color */
    display: flex; /* Align button better */
    flex-direction: column;
    gap: 1rem;
}

.ast-ppc-calculator-wrapper .ast-ppc-save-section .ast-ppc-input-group {
    margin-bottom: 0; /* Remove default margin if wrapped in flex */
}

.ast-ppc-calculator-wrapper .ast-ppc-save-section .ast-button {
    width: 100%; /* Make button full width on desktop too */
    padding: 12px 24px !important;
    background-color: var(--theme-primary-color) !important;
    color: #fff !important;
}

.ast-ppc-calculator-wrapper .ast-button {
    display: inline-block;
    background-color: var(--theme-primary-color); /* Dark Charcoal */
    color: #fff !important;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.ast-ppc-calculator-wrapper .ast-button:hover {
    background-color: #374151; /* Slightly Lighter Dark Charcoal */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ast-ppc-calculator-wrapper .ast-button-secondary {
    background-color: #6B7280; /* Gray 500 */
}

.ast-ppc-calculator-wrapper .ast-button-secondary:hover {
    background-color: #4B5563; /* Gray 600 */
}

.ast-ppc-calculator-wrapper .ast-button-small {
    padding: 5px 10px;
    font-size: 14px !important;
    margin-right: 5px;
}

.ast-ppc-calculator-wrapper .ast-saved-calculations-area {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--theme-border-color);
}

.ast-ppc-calculator-wrapper .ast-saved-calculations-area h2 {
    font-size: 1.5em !important;
    margin-bottom: 1rem;
    color: var(--theme-primary-color) !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    line-height: normal !important;
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table-container {
    margin-bottom: 1rem;
    overflow-x: auto; /* Allow horizontal scroll on small screens */
}

.ast-ppc-calculator-wrapper .ast-saved-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 14px !important;
}

.ast-ppc-calculator-wrapper .ast-saved-table th,
.ast-ppc-calculator-wrapper .ast-saved-table td {
    border: 1px solid var(--theme-border-color);
    padding: 8px 12px;
    text-align: left;
    vertical-align: middle;
    font-family: inherit !important;
    line-height: normal !important;
}

.ast-ppc-calculator-wrapper .ast-saved-table th {
    background-color: var(--theme-neutral-bg) !important; /* Match results box bg */
    font-weight: 600 !important;
}

.ast-ppc-calculator-wrapper .ast-saved-table td button {
    vertical-align: middle;
}

.ast-ppc-calculator-wrapper .ast-saved-table td button + button {
    margin-left: 5px;
    margin-right: 0;
}

.ast-ppc-calculator-wrapper .ast-saved-table tbody tr:hover {
    background-color: #f1f3f5;
}

.ast-ppc-calculator-wrapper .ast-storage-notice {
    font-size: 0.875rem !important;
    font-style: italic;
    color: #6B7280 !important; /* Gray 500 */
    margin-top: 1rem;
}

.ast-ppc-calculator-wrapper .ast-saved-calculations-empty {
    border: 1px dashed var(--theme-border-color); /* Dashed border to indicate empty state */
    background-color: var(--theme-neutral-bg); /* Light background */
    padding: 2rem;
    text-align: center;
    border-radius: 8px;
    margin-top: 1rem; /* Space above */
}

.ast-ppc-calculator-wrapper .ast-saved-calculations-empty .ast-empty-message {
    font-weight: 500;
    font-size: 1.1em;
    color: #374151; /* Gray 700 */
    margin: 0 0 0.5rem 0; /* Remove default margin */
}

.ast-ppc-calculator-wrapper .ast-saved-calculations-empty .ast-storage-notice {
    font-size: 0.9em;
    color: #6B7280; /* Gray 500 */
    margin: 0; /* Remove default margin */
}

/* --- Bulk Actions (Export/Delete All) --- */
.ast-ppc-calculator-wrapper .ast-bulk-actions-container {
    display: flex; /* Use flex for alignment */
    gap: 1rem; /* Space between buttons */
    margin-top: 1rem; /* Space above the container */
}

.ast-ppc-calculator-wrapper .ast-button-danger {
    background-color: #DC2626 !important; /* Red-600 */
    border-color: #DC2626 !important;
    color: #ffffff !important;
}

.ast-ppc-calculator-wrapper .ast-button-danger:hover {
    background-color: #B91C1C !important; /* Red-700 */
    border-color: #B91C1C !important;
}

/* --- Saved Calculations Table Styling --- */
.ast-ppc-calculator-wrapper #ast-saved-calculations-section {
    background: #ffffff;
    padding: 28px; /* Match main calculator padding */
    border-radius: 10px; /* Match main calculator radius */
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); /* Match main calculator shadow */
    max-width: 1100px; /* Match main calculator max-width */
    margin: 2rem auto 0 auto; /* Add top margin, keep horizontal centering */
}

.ast-ppc-calculator-wrapper #ast-bulk-actions-container {
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    gap: 0.5rem; /* Space between buttons */
    margin-bottom: 1.5rem; /* Space below buttons, above table */
    padding-right: 0; /* Adjust if container padding interferes */
}

.ast-ppc-calculator-wrapper #ast-bulk-actions-container .ast-button {
    padding: 6px 12px; /* Smaller padding */
    font-size: 0.9em;
}

.ast-ppc-calculator-wrapper #ast-bulk-actions-container #ast-delete-all-btn {
    background-color: #dc3545; /* Red */
    color: white;
}

.ast-ppc-calculator-wrapper #ast-bulk-actions-container #ast-delete-all-btn:hover {
    background-color: #c82333; /* Darker Red */
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table {
    width: 100%;
    border-collapse: collapse; /* Ensures borders connect cleanly */
    margin-top: 1rem; /* Add some space above the table */
    border: none; /* Remove any outer table border */
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table th,
.ast-ppc-calculator-wrapper #ast-saved-calculations-table td {
    border: none; /* Remove default cell borders */
    border-bottom: 1px solid var(--theme-border-color); /* Add subtle bottom border */
    padding: 0.75rem 1rem; /* Increase padding */
    text-align: left; /* Left-align text */
    vertical-align: middle; /* Align content vertically */
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table th {
    font-weight: 600; /* Make header text bolder */
    background-color: var(--theme-neutral-bg); /* Light background for header */
    color: var(--theme-primary-color);
}

/* Remove bottom border from the last row's cells */
.ast-ppc-calculator-wrapper #ast-saved-calculations-table tbody tr:last-child td {
    border-bottom: none;
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table tbody tr:hover {
    background-color: var(--theme-neutral-bg); /* Hover effect */
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table td .ast-button {
    margin-right: 0.5rem; /* Space between buttons in Actions */
    margin-bottom: 0; /* Remove default bottom margin if any */
    padding: 0.3rem 0.6rem; /* Slightly smaller padding for in-table buttons */
    font-size: 0.875rem; /* Slightly smaller font size */
}

#ast-saved-calculations-section .ast-load-btn {
    background-color: #007bff !important; /* Primary blue */
    color: white;
}

#ast-saved-calculations-section .ast-load-btn:hover {
    background-color: #0056b3 !important; /* Darker blue */
}

#ast-saved-calculations-section .ast-delete-btn {
    background-color: #dc3545 !important; /* Danger red */
    color: white;
}

#ast-saved-calculations-section .ast-delete-btn:hover {
    background-color: #c82333 !important; /* Darker red */
}

.ast-ppc-calculator-wrapper #ast-saved-calculations-table td .ast-button:last-child {
    margin-right: 0;
}

/* Ensure buttons are centered or aligned as needed in the Actions cell */
#ast-saved-calculations-table td:last-child {
    text-align: center; /* Center buttons in the cell */
}

/* Container styling */
.ast-ppc-calculator-container,
.ast-ppc-calculator-wrapper #ast-saved-calculations-section {

    margin-left: auto; /* Center the section */
    margin-right: auto; /* Center the section */
}

/* Make Save Calculation button slightly smaller */
#ast-save-calculation-btn {
    display: block; /* Ensure it's a block for margin auto */
    max-width: 300px; /* Limit width */
    width: 100%; /* Allow shrinking but respect max-width */
    margin-left: auto;
    margin-right: auto;
    padding: 8px 18px !important; /* Reduced padding, added !important */
    /* Explicitly add styles to override theme defaults for this specific button */
    background-color: var(--theme-primary-color) !important; /* Use plugin's primary color */
    color: #fff !important; /* Ensure white text */
    border: none !important; /* Remove theme border */
    border-radius: 5px !important; /* Ensure consistent radius */
    font-size: 16px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
}

.ast-ppc-calculator-wrapper .ast-button.ast-button-secondary {
    background-color: #6c757d; /* Gray */
    color: white;
}

.ast-ppc-calculator-wrapper .ast-ppc-results-box {
    background-color: var(--theme-results-bg-color);
}

.ast-ppc-calculator-wrapper .ast-ppc-results-box {
    background-color: #F3F4F6 !important; /* Slightly darker neutral bg (Gray 100) */
    border-radius: 10px !important;
    border: 1px solid var(--theme-border-color) !important; /* Add light border back */
    padding: 24px !important; /* Reduced results padding */
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Responsiveness --- */
@media (max-width: 768px) {
 
    /* Remove overall padding on mobile */
    .ast-ppc-calculator-wrapper {
        padding: 0;
    }

    .ast-ppc-calculator {
        flex-direction: column;
    }

    .ast-ppc-column {
        width: 100%;
        margin-bottom: 1rem;
    }

    .ast-ppc-inputs-column {
        order: 1;
    }

    .ast-ppc-results-column {
        order: 2;
    }

    /* Save section below results, stacked internally on mobile */
    .ast-ppc-calculator-wrapper .ast-ppc-save-section {
        order: 3;
        flex-direction: column;
        align-items: stretch;
    }

    #ast-save-calculation-btn {
        margin-top: 1rem;
    }

    /* Adjust bulk actions for mobile */
    .ast-bulk-actions-container {
        flex-direction: column; /* Stack buttons vertically */
        align-items: stretch; /* Make buttons stretch */
        gap: 0.5rem; /* Add space between buttons */
        margin-bottom: 1rem; /* Add space below buttons */
    }

    .ast-bulk-actions-container .ast-button {
        width: 100%; /* Make buttons full width */
        text-align: center;
        margin-right: 0; /* Override any right margin */
        margin-left: 0; /* Override any left margin */
        box-sizing: border-box; /* Include padding/border in width */
    }

    /* Ensure table scrolls on mobile */
    #ast-saved-calculations-table-container {
        overflow-x: auto;
    }

    /* Re-order Saved Calculations section for mobile */
    #ast-saved-calculations-section {
        display: flex;
        flex-direction: column;
    }

    #ast-saved-calculations-section > h3 {
        order: 2; /* Heading below buttons */
        margin-top: 1rem; /* Add space above heading */
    }

    #ast-bulk-actions-container {
        order: 1; /* Buttons at the top */
        padding: 0 1rem; /* Add padding directly to the button container */
        margin: 0; /* Override any unwanted margins (like -40px) */
        margin-bottom: 1rem; /* Add space below buttons */
    }

    #ast-saved-calculations-table-container {
        order: 3; /* Table at the bottom */
        overflow-x: auto;
    }

    /* Center and space Load/Delete buttons in table on mobile */
    .ast-saved-table td:last-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.5rem; /* Space between buttons */
        padding: 0.5rem;
    }

    .ast-saved-table td:last-child .ast-button {
        width: 80%; /* Make buttons slightly narrower than cell */
        min-width: 80px;
        box-sizing: border-box;
    }
}
