/* Custom styles for RateWrangler with Tailwind CSS */

/* Prevent horizontal overflow */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

main {
    overflow-x: hidden;
    width: 100%;
}

/* Ensure all direct children of main respect width */
main > * {
    max-width: 100%;
}

.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Range Slider Styling */
input[type="range"].slider-thumb::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    transition: all 0.2s ease;
}

input[type="range"].slider-thumb::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.6);
}

input[type="range"].slider-thumb::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    border: none;
    transition: all 0.2s ease;
}

input[type="range"].slider-thumb::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.6);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.blink-dot {
    animation: blink 1.5s ease-in-out infinite;
}

/* Hero text animations */
.hero-text h1 {
    animation: slideInDown 0.8s ease-out forwards;
}

.hero-text p {
    animation: slideInDown 0.8s ease-out 0.2s forwards;
    opacity: 0;
}

/* Calculator card animation */
.calculator-card {
    animation: fadeIn 1s ease-in 0.5s forwards;
    opacity: 0;
}

/* Featured plan cards - kept for staggered animation */
.plan-card {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

.plan-card:nth-child(1) { animation-delay: 0.8s; }
.plan-card:nth-child(2) { animation-delay: 1.0s; }
.plan-card:nth-child(3) { animation-delay: 1.2s; }

/* Rank cell styling */
.rank-cell {
    text-align: center;
    width: 80px;
}

/* Responsive Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    max-width: 100%;
}

.chart-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Redesigned Results Table with styling */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.results-table thead th {
    padding: 12px 16px;
    text-align: left;
    border: none;
    font-weight: 600;
    color: #374151;
}

.results-table tbody tr {
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    transition: box-shadow 0.2s ease;
}

.results-table tbody tr:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.results-table tbody tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.results-table tbody tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.results-table td {
    padding: 16px;
    vertical-align: top;
}

/* Rank column */
.rank-cell {
    text-align: center;
    width: 60px;
}

.rank-badge {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background-color: #e5e7eb;
    font-weight: 600;
    text-align: center;
}

/* Best deal styling */
.results-table .best-deal {
    background: linear-gradient(135deg, #d1f4e0 0%, #e8f8f0 100%);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2);
    border-top: 3px solid #10b981;
}

.results-table .best-deal .rank-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

/* Column widths */
.results-table td:nth-child(1) { width: 60px; }
.results-table td:nth-child(3) { width: 120px; }
.results-table td:nth-child(4) { width: 150px; }
.results-table td:nth-child(5) { width: 150px; }
.results-table td:nth-child(6) { width: 100px; }

/* Mobile Menu Styling */
.mobile-menu {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(10px);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 40;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

.mobile-menu.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.mobile-menu-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.mobile-menu-item {
    color: white;
    padding: 1rem 1.5rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    text-decoration: none;
}

.mobile-menu-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    padding-left: 2rem;
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item button,
button.mobile-menu-item {
    width: 100%;
    text-align: center;
}

/* Responsive adjustments for inputs and forms */
@media (max-width: 640px) {
    input[type="number"],
    input[type="text"] {
        font-size: 16px !important; /* Prevent zoom on mobile */
        padding: 0.5rem 0.75rem !important; /* Reduce padding on mobile */
    }

    /* Reduce card padding on mobile */
    .calculator-card {
        padding: 1rem !important;
    }

    /* Adjust button text size on mobile */
    button[type="submit"] {
        font-size: 1rem !important;
        padding: 0.75rem 1rem !important;
    }

    /* Make form labels smaller on mobile */
    .calculator-card label {
        font-size: 0.875rem !important;
    }

    /* Reduce spacing for kWh suffix */
    .calculator-card span.inline-flex {
        padding: 0.5rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Fix input + suffix container to prevent overflow */
    .calculator-card .flex {
        width: 100%;
        max-width: 100%;
    }

    .calculator-card .flex input {
        min-width: 0; /* Allow input to shrink */
    }
}

/* Desktop-focused responsive adjustments */
@media (max-width: 768px) {
    .results-table thead {
        display: none;
    }

    .results-table tbody, .results-table tr, .results-table td {
        display: block;
        width: 100%;
    }

    .results-table tr {
        margin-bottom: 1rem;
        border-radius: 10px;
        border: 1px solid #eee;
    }

    .results-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
    }

    .results-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: calc(50% - 2rem);
        text-align: left;
        font-weight: bold;
        white-space: nowrap;
    }

    .results-table .rank-cell {
        display: none;
    }

    .results-table td .badge {
        white-space: normal;
        text-align: left;
        display: block;
    }
}
