/**
 * TCO Widget Styles
 * =================
 * 
 * Styling for the embedded TCO calculator widget.
 * Uses CSS custom properties for theme consistency.
 * Mobile-first responsive design.
 */

/* =========================================================================
   CSS CUSTOM PROPERTIES
   ========================================================================= */

.tco-widget {
    --tco-primary: #00d4aa;
    --tco-primary-dark: #00b894;
    --tco-secondary: #6c5ce7;
    --tco-bg: rgba(255, 255, 255, 0.05);
    --tco-bg-hover: rgba(255, 255, 255, 0.08);
    --tco-border: rgba(255, 255, 255, 0.1);
    --tco-text: #ffffff;
    --tco-text-muted: rgba(255, 255, 255, 0.7);
    --tco-build-color: #e74c3c;
    --tco-buy-color: #00d4aa;
    --tco-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --tco-radius: 12px;
    --tco-transition: all 0.3s ease;
}

/* =========================================================================
   WIDGET CONTAINER
   ========================================================================= */

.tco-widget {
    background: var(--tco-bg);
    border: 1px solid var(--tco-border);
    border-radius: var(--tco-radius);
    padding: 1.5rem;
    margin: 2rem 0;
    backdrop-filter: blur(10px);
    box-shadow: var(--tco-shadow);
}

/* =========================================================================
   HEADER
   ========================================================================= */

.tco-widget__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.tco-widget__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--tco-text);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tco-widget__icon {
    font-size: 1.5rem;
}

.tco-widget__subtitle {
    font-size: 0.9rem;
    color: var(--tco-text-muted);
    margin: 0;
}

/* =========================================================================
   CONTROLS
   ========================================================================= */

.tco-widget__controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .tco-widget__controls {
        flex-direction: row;
        align-items: flex-end;
        gap: 2rem;
    }
}

.tco-widget__slider-group {
    flex: 1;
}

.tco-widget__label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--tco-text);
    margin-bottom: 0.5rem;
}

.tco-widget__value {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--tco-primary);
    min-width: 3ch;
    text-align: right;
}

.tco-widget__slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--tco-primary), var(--tco-secondary));
    outline: none;
    cursor: pointer;
}

.tco-widget__slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tco-text);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.tco-widget__slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.tco-widget__slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tco-text);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Toggle Group */
.tco-widget__toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tco-widget__toggle-label {
    font-size: 0.9rem;
    color: var(--tco-text);
}

.tco-widget__toggle {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--tco-border);
}

.tco-widget__toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--tco-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--tco-transition);
}

.tco-widget__toggle-btn:first-child {
    border-right: 1px solid var(--tco-border);
}

.tco-widget__toggle-btn.active {
    background: var(--tco-primary);
    color: #000;
    font-weight: 600;
}

.tco-widget__toggle-btn:hover:not(.active) {
    background: var(--tco-bg-hover);
}

/* =========================================================================
   RESULTS
   ========================================================================= */

.tco-widget__results {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.tco-widget__comparison {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .tco-widget__comparison {
        flex-direction: row;
        align-items: center;
    }
    
    .tco-widget__bar-container {
        flex: 1.5;
    }
    
    .tco-widget__metrics {
        flex: 1;
    }
}

/* Bar Chart */
.tco-widget__bar-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tco-widget__bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tco-widget__bar-label {
    font-size: 0.85rem;
    color: var(--tco-text-muted);
    min-width: 120px;
    text-align: right;
}

@media (max-width: 576px) {
    .tco-widget__bar-label {
        min-width: 80px;
        font-size: 0.75rem;
    }
}

.tco-widget__bar {
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.75rem;
    transition: width 0.5s ease-out;
    min-width: 60px;
}

.tco-widget__bar--build {
    background: linear-gradient(90deg, #c0392b, #e74c3c);
}

.tco-widget__bar--buy {
    background: linear-gradient(90deg, #00b894, #00d4aa);
}

.tco-widget__bar-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--tco-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

/* Metrics */
.tco-widget__metrics {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 576px) and (max-width: 991px) {
    .tco-widget__metrics {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tco-widget__metric {
        flex: 1;
        min-width: 150px;
    }
}

.tco-widget__metric {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.tco-widget__metric-icon {
    font-size: 1.1rem;
}

.tco-widget__metric-label {
    font-size: 0.8rem;
    color: var(--tco-text-muted);
}

.tco-widget__metric-value {
    font-weight: 700;
    color: var(--tco-primary);
    margin-left: auto;
}

.tco-widget__metric--savings .tco-widget__metric-value {
    color: #2ecc71;
}

.tco-widget__metric-roi {
    font-size: 0.8rem;
    color: var(--tco-text-muted);
}

/* =========================================================================
   FOOTER
   ========================================================================= */

.tco-widget__footer {
    text-align: center;
}

.tco-widget__assumptions {
    font-size: 0.75rem;
    color: var(--tco-text-muted);
    margin: 0 0 1rem 0;
    font-style: italic;
}

.tco-widget__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 576px) {
    .tco-widget__actions {
        flex-direction: row;
        justify-content: center;
    }
}

.tco-widget__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--tco-transition);
    cursor: pointer;
}

.tco-widget__btn--primary {
    background: var(--tco-primary);
    color: #000;
}

.tco-widget__btn--primary:hover {
    background: var(--tco-primary-dark);
    transform: translateY(-2px);
}

.tco-widget__btn--secondary {
    background: transparent;
    color: var(--tco-text);
    border: 1px solid var(--tco-border);
}

.tco-widget__btn--secondary:hover {
    background: var(--tco-bg-hover);
    border-color: var(--tco-primary);
}

/* =========================================================================
   LOADING STATE
   ========================================================================= */

.tco-widget--loading .tco-widget__results {
    opacity: 0.6;
    pointer-events: none;
}

.tco-widget--loading .tco-widget__bar {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =========================================================================
   DARK MODE ADJUSTMENTS (if needed)
   ========================================================================= */

@media (prefers-color-scheme: light) {
    .tco-widget {
        --tco-bg: rgba(0, 0, 0, 0.03);
        --tco-bg-hover: rgba(0, 0, 0, 0.06);
        --tco-border: rgba(0, 0, 0, 0.1);
        --tco-text: #1a1a2e;
        --tco-text-muted: rgba(0, 0, 0, 0.6);
    }
    
    .tco-widget__bar-value {
        text-shadow: none;
    }
}

/* Force dark mode for dark background sections */
.bg-dark .tco-widget,
[data-theme="dark"] .tco-widget {
    --tco-bg: rgba(255, 255, 255, 0.05);
    --tco-bg-hover: rgba(255, 255, 255, 0.08);
    --tco-border: rgba(255, 255, 255, 0.1);
    --tco-text: #ffffff;
    --tco-text-muted: rgba(255, 255, 255, 0.7);
}
