/* ============================================
   ChargeHub - Responsive Stylesheet
   Mobile & Tablet Adaptations
   ============================================ */

/* ============================================
   Extra Large Devices (1400px and up)
   ============================================ */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ============================================
   Large Devices (1200px and down)
   ============================================ */
@media (max-width: 1199.98px) {
    .hero-title {
        font-size: 3rem;
    }

    .hero-stats {
        gap: var(--spacing-lg);
    }

    .map-preview-wrapper {
        height: 500px;
    }

    .nearby-sidebar {
        width: 350px;
    }

    .steps-container {
        gap: var(--spacing-md);
    }
}

/* ============================================
   Medium Devices (991.98px and down)
   ============================================ */
@media (max-width: 991.98px) {
    /* Header */
    .header-search {
        display: none;
    }

    .navbar-collapse {
        background: var(--bg-primary);
        padding: var(--spacing-lg);
        margin-top: var(--spacing-md);
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow-lg);
    }

    .navbar-nav {
        margin-bottom: var(--spacing-md);
    }

    .nav-actions {
        justify-content: center;
        padding-top: var(--spacing-md);
        border-top: 1px solid var(--border-light);
    }

    /* Hero */
    .hero-section {
        min-height: auto;
        padding: calc(var(--header-height) + var(--spacing-2xl)) 0 var(--spacing-2xl);
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: var(--font-size-lg);
    }

    .hero-stats {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .stat-divider {
        width: 60px;
        height: 1px;
    }

    /* Map Preview */
    .map-preview-wrapper {
        flex-direction: column;
        height: auto;
    }

    .map-preview {
        min-height: 350px;
    }

    .nearby-sidebar {
        width: 100%;
        max-height: 400px;
    }

    /* Steps */
    .steps-container {
        flex-direction: column;
        align-items: center;
    }

    .step-connector {
        transform: rotate(90deg);
        padding: var(--spacing-md) 0;
    }

    .step-connector .connector-line {
        width: 40px;
    }

    /* Dashboard */
    .dashboard-stats .row {
        flex-direction: column;
    }

    .dashboard-stats .col-lg-3 {
        width: 50%;
    }
}

/* ============================================
   Small Devices (767.98px and down)
   ============================================ */
@media (max-width: 767.98px) {
    /* Base */
    body {
        font-size: 0.9375rem;
    }

    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
    h4 { font-size: var(--font-size-base); }

    .glass-card {
        padding: var(--spacing-md);
    }

    /* Header */
    .main-header .navbar {
        padding: var(--spacing-sm) 0;
    }

    .navbar-brand {
        font-size: var(--font-size-lg);
    }

    .navbar-brand .brand-icon {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-base);
    }

    .nav-user .user-name {
        display: none;
    }

    /* Hero */
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
    }

    .search-box {
        padding: var(--spacing-md);
    }

    .search-tabs {
        margin-bottom: var(--spacing-md);
    }

    .search-tab {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }

    .search-input-group {
        flex-direction: column;
    }

    .btn-search {
        width: 100%;
    }

    .quick-filters {
        justify-content: center;
    }

    .filter-chip {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    /* Sections */
    .section-title {
        font-size: var(--font-size-xl);
    }

    .features-section,
    .popular-section,
    .how-it-works-section,
    .testimonials-section,
    .cta-section {
        padding: var(--spacing-2xl) 0;
    }

    /* Map */
    .map-preview {
        min-height: 280px;
    }

    /* CTA */
    .cta-card {
        padding: var(--spacing-xl);
    }

    .cta-content h2 {
        font-size: var(--font-size-xl);
    }

    .cta-buttons {
        flex-direction: column;
    }

    .cta-buttons .btn {
        width: 100%;
    }

    /* Footer */
    .footer-top {
        padding: var(--spacing-2xl) 0;
    }

    .footer-bottom-content {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    /* Station Card */
    .station-main {
        flex-direction: column;
    }

    .station-meta {
        gap: var(--spacing-sm);
    }

    /* Search Page */
    .search-sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height-compact);
        bottom: 0;
        width: 100%;
        max-width: 360px;
        z-index: var(--z-fixed);
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        background: var(--bg-primary);
        box-shadow: var(--shadow-xl);
    }

    .search-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle-mobile {
        display: flex;
        position: fixed;
        left: var(--spacing-md);
        bottom: var(--spacing-md);
        z-index: var(--z-fixed);
    }

    .map-container {
        width: 100%;
    }

    /* Dashboard */
    .dashboard-stats .col-lg-3 {
        width: 100%;
    }

    .welcome-card .user-greeting {
        flex-direction: column;
        text-align: center;
    }

    .quick-search {
        margin-top: var(--spacing-lg);
    }

    .quick-search .search-wrapper {
        flex-direction: column;
    }

    .quick-search .btn {
        width: 100%;
        margin-top: var(--spacing-sm);
    }

    /* Favorites */
    .favorites-grid {
        grid-template-columns: 1fr;
    }

    .page-header-section {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .filters-bar {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .filter-options {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    /* Profile */
    .profile-sidebar {
        position: relative;
        margin-bottom: var(--spacing-lg);
    }

    .profile-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: var(--spacing-sm);
    }

    .profile-nav .nav-item {
        white-space: nowrap;
    }

    /* Auth Pages */
    .auth-container {
        flex-direction: column;
        margin-top: 20px !important;
    }

    .auth-branding {
        display: block;
        order: 2;
        padding: var(--spacing-lg);
    }

    .auth-form-panel {
        width: 100%;
        padding: var(--spacing-lg);
        order: 1;
    }

    .auth-page .theme-toggle,
    .auth-form-panel .theme-toggle {
        display: none !important;
    }

    .form-row {
        flex-direction: column;
    }
}

/* ============================================
   Extra Small Devices (575.98px and down)
   ============================================ */
@media (max-width: 575.98px) {
    /* Hero */
    .hero-section {
        padding-top: calc(var(--header-height) + var(--spacing-xl));
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-badge .badge-pill {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .stat-number {
        font-size: var(--font-size-2xl);
    }

    /* Map */
    .map-preview {
        min-height: 220px;
    }

    .nearby-sidebar {
        padding: var(--spacing-md);
    }

    /* Feature Cards */
    .feature-card {
        padding: var(--spacing-lg);
    }

    .feature-icon {
        width: 56px;
        height: 56px;
    }

    /* Steps */
    .step-icon {
        width: 64px;
        height: 64px;
        font-size: var(--font-size-xl);
    }

    .step-number {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-base);
    }

    /* Testimonials */
    .testimonial-card {
        padding: var(--spacing-md);
    }

    .user-avatar {
        width: 44px;
        height: 44px;
    }

    /* Back to Top */
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: var(--spacing-md);
        right: var(--spacing-md);
    }

    /* Buttons */
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .btn-lg {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: var(--font-size-base);
    }

    /* Modal Adjustments */
    .modal-dialog {
        margin: var(--spacing-sm);
    }

    /* Station Details */
    .station-header-card {
        padding: var(--spacing-md);
    }

    .station-title {
        font-size: var(--font-size-xl);
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .rating-summary {
        flex-direction: column;
    }

    /* Review Form */
    .star-rating-input {
        flex-direction: row-reverse;
        justify-content: flex-end;
    }

    /* Filter Sidebar */
    .filter-group {
        margin-bottom: var(--spacing-md);
    }

    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .amenities-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .btn {
        min-height: 44px;
    }

    .nav-link {
        padding: var(--spacing-md);
    }

    .filter-chip {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    /* Remove hover effects that don't work well on touch */
    .btn:hover {
        transform: none;
    }

    .glass-card:hover {
        transform: none;
    }

    .feature-card:hover {
        transform: none;
    }
}

/* ============================================
   Landscape Orientation on Mobile
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding: calc(var(--header-height) + var(--spacing-lg)) 0 var(--spacing-lg);
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-badge {
        margin-bottom: var(--spacing-sm);
    }

    .search-box-wrapper {
        max-width: 100%;
    }

    .hero-stats {
        display: none;
    }

    .scroll-indicator {
        display: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .main-header,
    .main-footer,
    .back-to-top,
    .theme-toggle,
    .btn,
    .search-box,
    .map-container,
    .scroll-indicator {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .glass-card {
        background: white;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .scroll-indicator {
        animation: none;
    }

    .map-markers .marker {
        animation: none;
    }
}

/* ============================================
   Global Overflow & Responsiveness Safeguards
   ============================================ */
html, body {
    max-width: 100%;
    overflow-x: hidden !important;
}

img, iframe, svg, video {
    max-width: 100%;
    height: auto;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Flex & Grid Equal Height Card Safeguards */
.guide-card, .tip-card, .feature-card, .testimonial-card, .connector-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

/* Fluid Heading Scaling */
.hero-title, .page-hero-title {
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    line-height: 1.2;
}

.section-title {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    line-height: 1.3;
}

/* 1441px+ — Large Desktop */
@media (min-width: 1441px) {
    .container {
        max-width: 1380px;
    }
}

/* 1025px–1440px — Laptop / Standard Desktop */
@media (min-width: 1025px) and (max-width: 1440px) {
    .container {
        max-width: 1140px;
    }
}

/* 768px–1024px — Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 720px;
    }
    .footer-links-col {
        margin-bottom: 24px;
    }
    .hero-stats {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
}

/* 481px–767px — Large Mobile / Small Tablet */
@media (min-width: 481px) and (max-width: 767px) {
    .container {
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
    }
    .guide-nav-pills, .tips-nav-pills {
        padding-bottom: 8px;
    }
    .nav-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    .nav-actions .btn {
        width: 100%;
    }
}

/* 320px–480px — Mobile */
@media (max-width: 480px) {
    .container {
        padding-left: 14px;
        padding-right: 14px;
    }
    .hero-subtitle, .page-hero-sub, .section-desc {
        font-size: 0.94rem;
        line-height: 1.55;
    }
    .btn-lg {
        padding: 12px 20px;
        font-size: 0.92rem;
        width: 100%;
    }
    .guide-card, .tip-card, .calc-container, .quiz-container {
        padding: 22px 18px;
        border-radius: 18px;
    }
    .calc-result-value, .score-number {
        font-size: 2.3rem;
    }
    .footer-bottom-links {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
    .stat-item {
        text-align: center;
    }
}

/* Page-Specific Responsive Enhancements */
@media (max-width: 991.98px) {
    /* How It Works Page */
    .big-step, .big-step.reverse {
        flex-direction: column !important;
        gap: 24px !important;
        margin-bottom: 32px !important;
    }
    .step-visual {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .step-visual img {
        height: 240px !important;
    }

    /* Page Hero Banners */
    .page-hero {
        padding: 76px 0 28px 0 !important;
    }

    /* Form Panels & Wizard Cards */
    .add-station-card, .contact-card, .profile-card {
        padding: 22px 18px !important;
    }
}

@media (max-width: 767.98px) {
    /* Universal Section Spacing Normalization */
    section:not(.modal-body):not(.dropdown-menu),
    .section-wrap,
    .page-section {
        padding-top: 28px !important;
        padding-bottom: 24px !important;
    }

    /* Remove excessive section header bottom margins */
    .mb-5:not(.stay-mb-5),
    .my-5:not(.stay-my-5),
    .py-5:not(.stay-py-5) {
        margin-bottom: 18px !important;
    }

    .py-5:not(.stay-py-5) {
        padding-top: 28px !important;
        padding-bottom: 24px !important;
    }

    .section-header-wrap,
    .text-center.mb-5 {
        margin-bottom: 18px !important;
    }

    /* Page Hero Banners */
    .page-hero {
        padding: 68px 0 22px 0 !important;
    }

    .page-hero-title {
        font-size: 1.65rem !important;
        line-height: 1.25 !important;
        margin-bottom: 8px !important;
    }

    .page-hero-sub, .page-hero-desc {
        font-size: 0.88rem !important;
        line-height: 1.5 !important;
        margin-bottom: 12px !important;
    }

    /* Bento and Card grids */
    .bento-grid, .features-grid, .stations-grid, .stations-list-grid {
        gap: 12px !important;
    }

    /* Form panels */
    .auth-card-container, .wizard-card, .settings-card {
        padding: 20px 16px !important;
        border-radius: 16px !important;
    }
}

@media (max-width: 575.98px) {
    .step-visual-overlay {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin-top: -20px !important;
        padding: 14px !important;
    }
    .page-hero-title {
        font-size: 1.48rem !important;
    }
    .step-visual img {
        height: 200px !important;
    }
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

