/* 
 * Mobile Responsive Styles for Energy Community Simulator
 * Comprehensive mobile-first responsive design
 */

/* ============================================
   MOBILE-FIRST BASE STYLES
   ============================================ */

/* Touch-friendly buttons and inputs */
.btn {
    min-height: 44px; /* iOS recommended touch target */
    min-width: 44px;
    padding: 0.625rem 1.25rem;
}

.btn-sm {
    min-height: 38px;
    padding: 0.5rem 1rem;
}

.btn-lg {
    min-height: 50px;
    padding: 0.875rem 1.5rem;
    font-size: 1.125rem;
}

/* Form inputs */
input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea,
.form-control,
.form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.625rem 0.875rem;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Extra Small Devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    
    /* Page Content */
    .page-content {
        padding: 0.75rem !important;
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 2rem 1rem !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
    }
    
    .hero-section .lead {
        font-size: 1rem !important;
    }
    
    /* Headings */
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.125rem !important; }
    h5 { font-size: 1rem !important; }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Feature Cards */
    .feature-card {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }
    
    .feature-icon {
        font-size: 2rem !important;
    }
    
    /* Households Grid - Single Column */
    .households-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .household-card {
        padding: 1rem;
    }
    
    /* Buttons - Stack vertically */
    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Button groups with spacing */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .action-buttons .btn {
        width: 100%;
        margin: 0 !important;
    }
    
    /* Tables - Horizontal scroll */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    /* Modal - Full screen on mobile */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        overflow-y: auto;
    }
    
    /* Forms - Stack form rows */
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    /* Metric Grid - Stack vertically */
    .metrics-grid,
    .metric-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    /* Navigation - Bottom Actions */
    .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between .btn {
        width: 100%;
    }
    
    /* Charts - Reduce height on mobile */
    .chart-container {
        height: 250px !important;
    }
    
    /* Step Progress - Smaller */
    .step-progress {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Location Info */
    .location-info {
        padding: 0.75rem;
    }
    
    /* Ownership Validation */
    .ownership-validation {
        padding: 0.75rem;
        font-size: 1rem;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    
    .page-content {
        padding: 1rem !important;
    }
    
    /* Households Grid - 2 columns */
    .households-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Buttons can be inline */
    .mb-3 .btn {
        display: inline-block;
        width: auto;
        margin-right: 0.5rem !important;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    
    .page-content {
        padding: 1.5rem !important;
    }
    
    /* Households Grid - 2 columns */
    .households-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   COMPONENT-SPECIFIC MOBILE STYLES
   ============================================ */

/* Navigation Menu - Mobile */
@media (max-width: 767.98px) {
    .navmenu {
        width: 100%;
    }

    .sitenav {
        width: 100%;
    }

    fluent-nav-menu {
        width: 100% !important;
    }

    fluent-nav-link {
        min-height: 48px;
        padding: 0.75rem 1rem !important;
        font-size: 1rem;
    }
}

/* City Tech Map - Mobile */
@media (max-width: 767.98px) {
    .city-tech-map-container {
        border-radius: 0;
        margin: 0 -0.75rem;
    }
    
    .city-tech-map {
        height: 300px !important;
    }
    
    .marker-label {
        font-size: 10px !important;
    }
}

/* PWA Install Prompt - Mobile */
@media (max-width: 575.98px) {
    .pwa-install-prompt {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        width: calc(100% - 20px);
    }
    
    .pwa-install-content {
        padding: 1rem;
        flex-wrap: wrap;
    }
    
    .pwa-install-text {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .pwa-install-text strong {
        font-size: 0.9rem;
    }
    
    .pwa-install-text p {
        font-size: 0.8rem;
    }
    
    .pwa-install-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .pwa-install-actions button {
        flex: 1;
    }
}

/* Household Form - Mobile */
@media (max-width: 767.98px) {
    .household-form .row {
        flex-direction: column;
    }
    
    .household-form .col-md-6,
    .household-form .col-md-4 {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin-bottom: 1rem;
    }
}

/* Metric Cards - Mobile */
@media (max-width: 767.98px) {
    .metric-card {
        padding: 0.75rem;
        text-align: center;
    }
    
    .metric-card .metric-value {
        font-size: 1.5rem;
    }
    
    .metric-card .metric-label {
        font-size: 0.875rem;
    }
}

/* Analysis Page - Mobile */
@media (max-width: 767.98px) {
    .analysis-container .row {
        margin: 0;
    }
    
    .analysis-container .col-md-6,
    .analysis-container .col-md-12 {
        padding: 0;
        margin-bottom: 1rem;
    }
}

/* Investment Review - Mobile */
@media (max-width: 767.98px) {
    .investment-container .card {
        margin-bottom: 1rem;
    }
    
    .investment-summary {
        padding: 1rem;
    }
}

/* ============================================
   TOUCH INTERACTIONS
   ============================================ */

/* Better touch targets */
a, button, .btn, input[type="checkbox"], input[type="radio"] {
    touch-action: manipulation;
}

/* Prevent double-tap zoom on buttons */
button {
    touch-action: manipulation;
}

/* Active state feedback */
@media (hover: none) {
    .btn:active,
    button:active {
        background-color: rgba(0, 0, 0, 0.1);
        transform: scale(0.98);
    }
}

/* ============================================
   SCROLL BEHAVIOR
   ============================================ */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Horizontal scroll for tables */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   ORIENTATION SPECIFIC
   ============================================ */

/* Landscape orientation on mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .city-tech-map {
        height: 250px !important;
    }
    
    .modal-dialog {
        height: auto;
        max-height: 90vh;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
    :focus-visible {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
        transition: outline-offset 0.2s ease;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Mobile-only utilities */
@media (max-width: 767.98px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
        display: block !important;
    }
    
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-stack {
        flex-direction: column !important;
    }
}

/* Desktop-only utilities */
@media (min-width: 768px) {
    .desktop-hidden {
        display: none !important;
    }
}

/* ============================================
   SCROLLBAR STYLING (Mobile Webkit)
   ============================================ */

/* Thin scrollbars on mobile */
@media (max-width: 767.98px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}
