/* Scoped Styles for Loan Calculator Plugin */
.alc-plugin-wrapper {
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --bs-blue: #0d6efd;
    --text-main: #ffffff;
    --text-muted: #94a3b8;

    font-family: 'Outfit', sans-serif;
    background-color: #0f172a;
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-attachment: local;
    /* Changed from fixed for better containment */
    color: var(--text-main);
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.alc-plugin-wrapper *,
.alc-plugin-wrapper *::before,
.alc-plugin-wrapper *::after {
    box-sizing: border-box;
}

.alc-plugin-wrapper .container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.alc-plugin-wrapper header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background: transparent;
    border: none;
}

.alc-plugin-wrapper h1 {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    margin: 0 0 10px 0;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.2;
}

.alc-plugin-wrapper .controls {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    flex-direction: column !important;
    gap: 15px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.alc-plugin-wrapper .control-group {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
}

.alc-plugin-wrapper .control-group.full-width {
    grid-column: auto;
    width: 100%;
}

.alc-plugin-wrapper label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-left: 4px;
    display: block;
    margin-bottom: 2px;
}

.alc-plugin-wrapper select,
.alc-plugin-wrapper input[type="text"],
.alc-plugin-wrapper input[type="number"],
.alc-plugin-wrapper input[type="range"] {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 14px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: auto;
    box-shadow: none;
    line-height: 1.5;
}

.alc-plugin-wrapper select option {
    background: #0f172a;
    color: white;
}

.alc-plugin-wrapper select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

/* Radio Group Styling */
.alc-plugin-wrapper .currency-toggle {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    width: fit-content;
}

.alc-plugin-wrapper .currency-option {
    flex: 1;
    position: relative;
    min-width: 80px;
}

.alc-plugin-wrapper .currency-option input {
    position: absolute;
    opacity: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
    margin: 0;
}

.alc-plugin-wrapper .currency-option label {
    display: block;
    padding: 10px 15px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0;
    color: var(--text-muted);
    text-transform: none;
    font-weight: 700;
    letter-spacing: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    position: relative;
    z-index: 10;
}

/* JS-Class based radio active state */
.alc-plugin-wrapper .currency-option.active label,
.alc-plugin-wrapper .currency-option input:checked+label {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.alc-plugin-wrapper .slider-container {
    position: relative;
    padding-top: 20px;
}

.alc-plugin-wrapper .slider-value {
    position: absolute;
    right: 0;
    top: -10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #818cf8;
    background: rgba(129, 140, 248, 0.1);
    padding: 4px 12px;
    border-radius: 8px;
}

.alc-plugin-wrapper .results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
}

.alc-plugin-wrapper .bank-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.alc-plugin-wrapper .bank-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
}

.alc-plugin-wrapper .bank-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
}

.alc-plugin-wrapper .badge {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: normal;
}

.alc-plugin-wrapper .badge.fixed {
    background: linear-gradient(135deg, #c026d3 0%, #db2777 100%);
    box-shadow: 0 4px 12px rgba(192, 38, 211, 0.2);
}

.alc-plugin-wrapper .badge.variable {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.2);
}

.alc-plugin-wrapper .detail-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alc-plugin-wrapper .bank-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.3;
}

.alc-plugin-wrapper .monthly-payment {
    font-size: 2.8rem;
    font-weight: 800;
    color: #4ade80;
    margin: 10px 0 20px 0;
    letter-spacing: -1.5px;
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
    line-height: 1.2;
}

.alc-plugin-wrapper .detail-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.alc-plugin-wrapper .detail-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f8fafc;
}

.alc-plugin-wrapper .calculate-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    height: 60px;
    font-size: 1.25rem;
    border-radius: 16px;
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.5);
    width: 100%;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.1s;
}

.alc-plugin-wrapper .calculate-btn:hover {
    filter: brightness(110%);
}

.alc-plugin-wrapper .best-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #f59e0b;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 8px 20px;
    border-bottom-left-radius: 20px;
    box-shadow: -4px 4px 10px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 2;
}

.alc-plugin-wrapper .tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
}

.alc-plugin-wrapper .tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.alc-plugin-wrapper .calculate-btn:active {
    transform: scale(0.98);
}

.alc-plugin-wrapper .btn-apply {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    text-align: center;
    border: 1px solid var(--glass-border);
    margin-top: 20px;
    line-height: normal;
}

.alc-plugin-wrapper .btn-apply:hover {
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    border-color: transparent;
    color: white;
}

.alc-plugin-wrapper .exchange-rate-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 15px;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.alc-plugin-wrapper .exchange-rate-badge.hidden {
    display: none;
}

.alc-plugin-wrapper .controls {
    padding: 30px;
}

@media (max-width: 600px) {
    .alc-plugin-wrapper {
        padding: 15px 10px;
    }

    .alc-plugin-wrapper h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }

    .alc-plugin-wrapper header p {
        font-size: 1rem !important;
        padding: 0 10px;
    }

    .alc-plugin-wrapper .controls {
        padding: 20px;
        gap: 20px;
        border-radius: 20px;
    }

    .alc-plugin-wrapper .currency-toggle {
        width: 100%;
    }

    .alc-plugin-wrapper .currency-option label {
        padding: 10px 10px;
        font-size: 0.85rem;
    }

    .alc-plugin-wrapper .slider-value {
        font-size: 0.9rem;
        padding: 2px 8px;
        top: -12px;
    }

    .alc-plugin-wrapper .bank-card {
        padding: 20px;
    }

    .alc-plugin-wrapper .bank-name {
        font-size: 1.3rem;
    }

    .alc-plugin-wrapper .monthly-payment {
        font-size: 2rem;
    }

    .alc-plugin-wrapper .loan-metric-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.alc-plugin-wrapper .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: alc-spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes alc-spin {
    to {
        transform: rotate(360deg);
    }
}

.alc-plugin-wrapper .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 24px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
}

.alc-plugin-wrapper .empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #f8fafc;
}

.alc-plugin-wrapper .empty-state p {
    color: var(--text-muted);
}

.alc-plugin-wrapper .loan-metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.alc-plugin-wrapper .metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alc-plugin-wrapper .metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.alc-plugin-wrapper .metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}

.alc-plugin-wrapper .fee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
}

.alc-plugin-wrapper .fee-row:last-child {
    border-bottom: none;
}

.alc-plugin-wrapper .fee-row span:first-child {
    color: #94a3b8;
    font-weight: 600;
}

.alc-plugin-wrapper .fee-row span:last-child {
    color: #f1f5f9;
    font-weight: 700;
}

/* Toggle Switch Styles */
.alc-plugin-wrapper .toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    padding: 10px 0;
    text-transform: none;
    letter-spacing: normal;
    font-size: 1rem;
}

.alc-plugin-wrapper .switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

#payroll,
.alc-plugin-wrapper .switch input {
    position: fixed !important;
    top: -9999px !important;
    left: -9999px !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.alc-plugin-wrapper .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--glass-border);
}

/* JS-Class based toggle state (More robust) */
.alc-plugin-wrapper .switch.checked .slider {
    background-color: var(--primary) !important;
    border-color: transparent !important;
}

.alc-plugin-wrapper .switch.checked .slider:before {
    transform: translateX(24px) !important;
}

/* Keep legacy selector as backup */
.alc-plugin-wrapper input:checked+.slider {
    background-color: var(--primary);
    border-color: transparent;
}

.alc-plugin-wrapper input:checked+.slider:before {
    transform: translateX(24px);
}

.alc-plugin-wrapper input:checked+.slider {
    background-color: var(--primary);
    border-color: transparent;
}

.alc-plugin-wrapper input:checked+.slider:before {
    transform: translateX(24px);
}

.alc-plugin-wrapper input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}