/* ROAS Calculator Styles */

/* Define variables (consider moving to a shared location or defining in :root if not already) */
:root {
    --ast-primary-color: #DE3163; /* Example Pink */
    --ast-text-color: #333;
    --ast-label-color: #555;
    --ast-border-color: #ddd;
    --ast-input-bg-color: #fff;
    --ast-focus-ring-color: rgba(222, 49, 99, 0.3);
    --ast-results-bg-color: #F3F4F6; /* Gray 100 */
    --ast-success-color: #28a745;
    --ast-error-color: #dc3545;
    --ast-message-bg-success: #d4edda;
    --ast-message-border-success: #c3e6cb;
    --ast-message-text-success: #155724;
    --ast-message-bg-error: #f8d7da;
    --ast-message-border-error: #f5c6cb;
    --ast-message-text-error: #721c24;
}

.ast-roas-calculator {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    max-width: 700px; /* Consistent max-width */
    margin: 2em auto; /* Top/bottom margin, centered */
    padding: 20px;
    background-color: #fff;
    border: 1px solid var(--ast-border-color);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.ast-roas-calculator h2,
.ast-roas-calculator h3 {
    color: var(--ast-text-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

.ast-roas-calculator .ast-input-group {
    margin-bottom: 1rem;
}

.ast-roas-calculator label {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif; /* Explicitly set for labels */
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600; /* Increased weight */
    color: var(--ast-text-color); /* Darker color */
    font-size: 15px; /* Slightly larger */
}

.ast-roas-calculator input[type="text"] {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ast-text-color);
    background-color: var(--ast-input-bg-color);
    background-clip: padding-box;
    border: 1px solid var(--ast-border-color);
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.ast-roas-calculator input[type="text"]:focus {
    color: var(--ast-text-color);
    background-color: var(--ast-input-bg-color);
    border-color: var(--ast-primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--ast-focus-ring-color);
}

.ast-roas-calculator .ast-results-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: var(--ast-results-bg-color);
    border: 1px solid var(--ast-border-color);
    border-radius: 8px;
}

.ast-roas-calculator .ast-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0; /* Vertical padding only */
    border-bottom: 1px solid #e5e7eb; /* Light separator */
}

.ast-roas-calculator .ast-result-item:last-child {
    border-bottom: none;
}

.ast-roas-calculator .ast-result-label {
    font-size: 15px;
    color: var(--ast-label-color);
}

.ast-roas-calculator .ast-result-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--ast-primary-color);
}

/* Shared Message Styles (matches PPC calc general style) */
.ast-roas-calculator .ast-message {
    padding: 0.75rem 1.25rem;
    margin-top: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem; /* ~6px */
    font-size: 15px;
    line-height: 1.6;
}

.ast-roas-calculator .ast-message-error {
    color: var(--ast-message-text-error);
    background-color: var(--ast-message-bg-error);
    border-color: var(--ast-message-border-error);
}

.ast-roas-calculator .ast-message-success {
    color: var(--ast-message-text-success);
    background-color: var(--ast-message-bg-success);
    border-color: var(--ast-message-border-success);
}

/* --- ROAS Efficiency Bar --- */
.ast-roas-calculator .ast-roas-summary {
    text-align: center;
    font-size: 22px; /* Made larger */
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: var(--ast-text-color);
}

.ast-roas-calculator .ast-roas-ratio-summary {
    text-align: center;
    font-size: 15px; /* Smaller than the main ROAS % */
    font-weight: 400;
    color: var(--ast-label-color); /* Lighter than main text, but not too light */
    margin-top: -1.25rem; /* Pull it up closer to the percentage */
    margin-bottom: 1.5rem; /* Keep space before the bar */
}

.ast-roas-calculator .ast-roas-summary-value {
    font-weight: 700;
    color: var(--ast-primary-color); /* Or a dedicated result color */
}

/* Text color classes for ROAS summary value based on efficiency */
.ast-roas-calculator .ast-roas-summary-value-inefficient {
    color: #dc3545; /* Red - matches bar segment */
}

.ast-roas-calculator .ast-roas-summary-value-moderate {
    color: #ffc107; /* Yellow/Amber - matches bar segment */
}

.ast-roas-calculator .ast-roas-summary-value-optimal {
    color: #20c997; /* Teal/Green - matches bar segment */
}

.ast-roas-calculator .ast-roas-efficiency-bar-container {
    width: 100%;
    margin-bottom: 0.75rem;
}

.ast-roas-calculator .ast-roas-efficiency-bar {
    display: flex;
    height: 20px; /* Bar height */
    border-radius: 10px; /* Rounded bar */
    overflow: hidden; /* To keep segments contained */
    position: relative; /* For absolute positioning of the indicator */
    background-color: #e9ecef; /* Fallback for the bar background if segments don't fill */
}

.ast-roas-calculator .ast-roas-bar-segment {
    height: 100%;
}

/* Define segment widths based on ROAS thresholds (0-1000% range for visual representation) */
/* Inefficient: 0-200% (visually 0-20% of the bar if max is 1000%) */
/* Moderate: 200-400% (visually next 20% of the bar) */
/* Optimal: 400-1000%+ (visually remaining 60% of the bar) */

.ast-roas-calculator .ast-roas-inefficient {
    width: 33.33%; /* Corresponds to 0-200% of a typical 0-600% visual max, or 0-200% of a 0-1000% visual if we cap visually at 1000% */
    background-color: #dc3545; /* Red */
}

.ast-roas-calculator .ast-roas-moderate {
    width: 33.33%; /* Corresponds to 200-400% */
    background-color: #ffc107; /* Yellow/Amber */
}

.ast-roas-calculator .ast-roas-optimal {
    width: 33.34%; /* Corresponds to 400%+ */
    background-color: #20c997; /* Teal/Green (was #28a745, using a more distinct color) */
}

.ast-roas-calculator .ast-roas-indicator {
    position: absolute;
    top: -5px; /* Position slightly above the bar midline */
    left: 0%; /* Will be set by JS, default to start */
    width: 6px; /* Indicator width */
    height: 30px; /* Indicator height (taller than bar) */
    background-color: #343a40; /* Dark gray/black */
    border-radius: 3px; /* Rounded indicator */
    transform: translateX(-50%); /* Center the indicator on its 'left' position */
    transition: left 0.3s ease-out; /* Smooth transition */
    z-index: 2;
}

.ast-roas-calculator .ast-roas-efficiency-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--ast-text-color); /* Darker color for clarity */
    font-weight: 500; /* Slightly bolder for clarity */
    margin-top: 0.6rem; /* Increased to move labels lower */
    padding: 0 5px; /* Add some padding so text isn't flush with edges if bar is full width */
}

.ast-roas-calculator .ast-roas-efficiency-labels span {
    text-align: center;
}

/* Adjust label positioning for a three-segment bar */
.ast-roas-calculator .ast-roas-label-inefficient {
    width: 33.33%;
}

.ast-roas-calculator .ast-roas-label-moderate {
    width: 33.33%;
}

.ast-roas-calculator .ast-roas-label-optimal {
    width: 33.33%;
}

.ast-roas-calculator .ast-currency-selector-group select {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ast-text-color);
    background-color: var(--ast-input-bg-color);
    background-clip: padding-box;
    border: 1px solid var(--ast-border-color);
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
    -webkit-appearance: none; /* Remove default appearance */
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20d%3D%22M5%208l5%205%205-5z%22%20fill%3D%22%23555%22/%3E%3C/svg%3E'); /* Basic dropdown arrow */
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.ast-roas-calculator .ast-currency-selector-group select:focus {
    border-color: var(--ast-primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); /* Match primary color focus */
}

/* --- Headings --- */
/*
.ast-roas-calculator h2,
.ast-roas-calculator h3 {
    color: var(--ast-text-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

/* --- Responsiveness --- */
@media (max-width: 768px) {
    .ast-roas-calculator {
        padding: 15px;
        margin: 1em auto;
    }

    .ast-roas-calculator .ast-results-section {
        padding: 1rem;
    }

    .ast-roas-calculator .ast-result-item {
        flex-direction: column; /* Stack label and value */
        align-items: flex-start; /* Align to start */
        gap: 0.25rem;
    }

    .ast-roas-calculator .ast-result-value {
        font-size: 16px; /* Slightly smaller on mobile */
    }

    .ast-roas-calculator .ast-roas-summary {
        font-size: 20px; /* Adjust for mobile if needed */
    }

    .ast-roas-calculator .ast-roas-ratio-summary {
        font-size: 14px; /* Adjust for mobile */
        margin-top: -1rem;
    }

    .ast-roas-calculator .ast-roas-efficiency-labels {
        font-size: 10px;
    }

    .ast-roas-calculator .ast-roas-indicator {
        width: 4px;
        height: 26px;
        top: -3px;
    }
}

.ast-roas-calculator .ast-roas-profit-summary,
.ast-roas-calculator .ast-roas-profit-margin-summary {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--ast-text-color);
    margin-bottom: 0.75rem;
    position: relative; /* For tooltip positioning */
}

.ast-roas-calculator .ast-roas-profit-summary,
.ast-roas-calculator .ast-roas-profit-margin-summary {
    font-size: 15px;
}

/* --- Tooltip Styles --- */
.ast-tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
}

.ast-tooltip .ast-tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--ast-label-color);
    color: white;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    cursor: help;
    font-weight: bold;
}

.ast-tooltip .ast-tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #333;
    color: #fff;
    text-align: left;
    font-size: 12px;
    font-weight: normal;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 10;
    bottom: 125%; /* Position above the icon */
    left: 50%;
    margin-left: -110px; /* Half of width to center */
    opacity: 0;
    transition: opacity 0.3s;
}

.ast-tooltip .ast-tooltip-text::after { /* Arrow */
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.ast-tooltip:hover .ast-tooltip-text,
.ast-tooltip .ast-tooltip-icon:focus + .ast-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Allow tooltip icon to be focusable for accessibility */
.ast-tooltip .ast-tooltip-icon {
    outline: none; /* Remove default focus outline if you have custom focus style */
}

.ast-tooltip .ast-tooltip-icon:focus {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); /* Example focus style */
}
