/* GAIM Simulator - Futuristic Dark Theme with Neon Accents */

/* Import futuristic fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600;700&display=swap');

/* CSS Custom Properties for Neon Theme */
:root {
    --neon-blue: #00d4ff;
    --neon-cyan: #00ffff;
    --neon-purple: #bf00ff;
    --neon-pink: #ff006e;
    --dark-bg: #0a0a0f;
    --dark-surface: #1a1a2e;
    --dark-elevated: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #b8c5d6;
    --text-muted: #7a8394;
    --glow-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    --glow-shadow-hover: 0 0 30px rgba(0, 212, 255, 0.5);
}

/* Base styles */
body {
    font-family: 'Exo 2', sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #0f0f23 50%, var(--dark-bg) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Futuristic background particles effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(191, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(0, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Futuristic Navigation Styles */
.navbar,
.gaim-navbar {
    display: block !important;
    background: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-elevated) 100%) !important;
    border-bottom: 2px solid var(--neon-blue);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(20px);
    min-height: 60px;
    position: relative;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
}

.navbar-brand {
    font-family: 'Orbitron', monospace !important;
    font-weight: 700 !important;
    color: var(--neon-cyan) !important;
    text-shadow: 0 0 10px var(--neon-cyan);
}

.nav-link {
    color: var(--text-secondary) !important;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--neon-blue) !important;
    text-shadow: 0 0 8px var(--neon-blue);
}

/* Futuristic Cards */
.card {
    background: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-elevated) 100%) !important;
    border: 1px solid rgba(0, 212, 255, 0.3) !important;
    border-radius: 15px !important;
    box-shadow: var(--glow-shadow) !important;
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
    transition: left 0.8s ease;
}

.card:hover::before {
    left: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--glow-shadow-hover);
    border-color: var(--neon-blue);
}

.card-header {
    background: linear-gradient(135deg, var(--dark-elevated) 0%, rgba(0, 212, 255, 0.1) 100%) !important;
    border-bottom: 1px solid var(--neon-blue) !important;
    color: var(--text-primary) !important;
    font-family: 'Orbitron', monospace;
    font-weight: 600;
}

.card-body {
    color: var(--text-secondary) !important;
}

/* Neon Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-cyan) 100%) !important;
    border: none !important;
    color: var(--dark-bg) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
    background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-blue) 100%) !important;
}

.btn-secondary {
    background: transparent !important;
    border: 2px solid var(--neon-purple) !important;
    color: var(--neon-purple) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--neon-purple) !important;
    color: var(--dark-bg) !important;
    box-shadow: 0 0 20px rgba(191, 0, 255, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #00ff88 0%, #00d4ff 100%) !important;
    border: none !important;
    color: var(--dark-bg) !important;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--neon-pink) 0%, #ff3366 100%) !important;
    border: none !important;
    color: white !important;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.4);
}

/* Viewport fix for all devices */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* Futuristic Forms and Inputs */
.form-control {
    background: rgba(26, 26, 46, 0.8) !important;
    border: 2px solid rgba(0, 212, 255, 0.3) !important;
    border-radius: 10px !important;
    color: var(--text-primary) !important;
    padding: 12px 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.form-control:focus {
    background: rgba(26, 26, 46, 1) !important;
    border-color: var(--neon-blue) !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3) !important;
    color: var(--text-primary) !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-label {
    color: var(--text-secondary) !important;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

/* Futuristic Tables */
.table {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--glow-shadow);
}

.table thead th {
    background: linear-gradient(135deg, var(--dark-elevated) 0%, rgba(0, 212, 255, 0.1) 100%) !important;
    border: none !important;
    color: var(--neon-cyan) !important;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 15px;
    position: relative;
}

.table tbody tr {
    background: rgba(26, 26, 46, 0.6) !important;
    transition: all 0.3s ease;
    border: none !important;
}

.table tbody tr:hover {
    background: rgba(0, 212, 255, 0.1) !important;
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(0, 212, 255, 0.2);
}

.table td {
    border: none !important;
    padding: 12px 15px;
    vertical-align: middle;
}

/* Progress Bars with Neon Effect */
.progress {
    background: rgba(26, 26, 46, 0.8) !important;
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.progress-bar {
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan)) !important;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Badge Enhancements */
.badge {
    font-family: 'Orbitron', monospace !important;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.badge.bg-primary {
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-cyan)) !important;
    color: var(--dark-bg) !important;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.badge.bg-success {
    background: linear-gradient(135deg, #00ff88, #00d4ff) !important;
    color: var(--dark-bg) !important;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.badge.bg-danger {
    background: linear-gradient(135deg, var(--neon-pink), #ff3366) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.4);
}

.badge.bg-warning {
    background: linear-gradient(135deg, #ffaa00, #ff6600) !important;
    color: var(--dark-bg) !important;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.4);
}

/* Dashboard Icons Enhancement */
.dashboard-icon {
    filter: drop-shadow(0 0 10px var(--neon-blue));
    transition: all 0.3s ease;
}

.dashboard-icon:hover {
    filter: drop-shadow(0 0 20px var(--neon-cyan));
    transform: scale(1.1) rotate(5deg);
}

/* Loading Animation */
.loading-spinner {
    border: 3px solid rgba(0, 212, 255, 0.3);
    border-top: 3px solid var(--neon-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Mobile Optimization */
@media (max-width: 767px) {
    /* Chart optimizations */
    .chart-container {
        height: 300px !important;
        margin-bottom: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Historic Performance section optimizations */
    .historic-performance-container {
        padding: 0 !important;
        margin-bottom: 20px;
    }
    
    .simulation-runs-badge {
        font-size: 12px !important;
        padding: 4px 8px !important;
        margin: 5px !important;
        position: absolute;
        top: 0;
        right: 0;
    }
    
    .historic-performance-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        text-align: center;
    }
    
    /* Touch-friendly form elements */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    input, select, textarea, .form-control, .btn {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 0.5rem !important; 
        height: auto;
        touch-action: manipulation;
        -webkit-appearance: none; /* Fixes border radius issues on iOS */
        border-radius: 8px; /* Larger, more touch-friendly corners */
    }
    
    /* Improve tap targets */
    .nav-link, button, .btn, a {
        min-height: 44px; /* Apple's recommended minimum tap target size */
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    
    /* Smaller paddings for cards */
    .card-body {
        padding: 0.75rem;
    }
    
    .card-header {
        padding: 0.75rem;
    }
    
    /* Optimize containers */
    .container {
        padding-left: 10px;
        padding-right: 10px;
        max-width: 100%;
        width: 100%;
    }
    
    /* Fix table layouts */
    .table-responsive {
        margin-bottom: 0;
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        display: block;
        width: 100%;
    }
    
    .table {
        font-size: 0.85rem;
        width: 100%;
        table-layout: fixed;
    }
    
    .table td, .table th {
        padding: 0.4rem;
        word-break: break-word;
    }
    
    /* Make alerts more compact */
    .alert {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* Optimize typography */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
}

/* Futuristic Headers and Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Orbitron', monospace;
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

h1 {
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-cyan));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    letter-spacing: 2px;
}

/* Dashboard Grid Enhancements */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.dashboard-card {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    transition: all 0.4s ease;
}

.dashboard-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(0, 212, 255, 0.03),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.dashboard-card:hover::after {
    opacity: 1;
    transform: rotate(45deg) translate(50%, 50%);
}

/* Scoreboard Enhancements */
.scoreboard-entry {
    background: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-elevated) 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    padding: 20px;
    margin: 10px 0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.scoreboard-entry:hover {
    transform: translateX(10px);
    border-color: var(--neon-cyan);
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.2);
}

.scoreboard-rank {
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: 2rem;
    color: var(--neon-blue);
    text-shadow: 0 0 15px var(--neon-blue);
}

/* Chart Container Enhancements */
.chart-container {
    background: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-elevated) 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 20px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: var(--glow-shadow);
    position: relative;
    overflow: hidden;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan), var(--neon-purple));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Alert Enhancements */
.alert {
    border: none !important;
    border-radius: 15px !important;
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.alert-success {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.2) 0%, rgba(0, 212, 255, 0.1) 100%) !important;
    border-left: 4px solid #00ff88 !important;
    color: #00ff88 !important;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.2) 0%, rgba(255, 51, 102, 0.1) 100%) !important;
    border-left: 4px solid var(--neon-pink) !important;
    color: var(--neon-pink) !important;
}

.alert-warning {
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.2) 0%, rgba(255, 102, 0, 0.1) 100%) !important;
    border-left: 4px solid #ffaa00 !important;
    color: #ffaa00 !important;
}

.alert-info {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(0, 255, 255, 0.1) 100%) !important;
    border-left: 4px solid var(--neon-cyan) !important;
    color: var(--neon-cyan) !important;
}

/* Vulnerability Assessment Special Styling */
.vulnerability-card {
    background: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-elevated) 100%);
    border: 2px solid;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.vulnerability-low {
    border-color: #00ff88;
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.3);
}

.vulnerability-medium {
    border-color: #ffaa00;
    box-shadow: 0 0 25px rgba(255, 170, 0, 0.3);
}

.vulnerability-high {
    border-color: var(--neon-pink);
    box-shadow: 0 0 25px rgba(255, 0, 110, 0.3);
}

/* Floating Elements */
.floating-element {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* Pulsing Elements */
.pulse-element {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
    
    h3 {
        font-size: 1.2rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
    
    h5 {
        font-size: 1rem;
    }
    
    p {
        font-size: 0.95rem;
    }
    
    /* Button optimizations */
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.95rem;
        margin: 0.25rem 0;
        white-space: normal;
        height: auto;
    }
    
    /* Fix spacing issues */
    .row {
        margin-left: -5px;
        margin-right: -5px;
    }
    
    .col, [class*="col-"] {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    /* Optimize modals */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.25rem;
    }
    
    /* Optimize footer */
    .footer {
        padding: 10px 0;
    }
    
    /* Fix navigation */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .navbar-brand img {
        height: 30px !important;
    }
    
    /* Fix scrolling */
    .table-responsive, .chart-container {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Safari-specific fixes */
    @supports (-webkit-touch-callout: none) {
        /* iOS devices */
        .chart-container {
            -webkit-overflow-scrolling: touch;
            overflow-x: scroll;
        }
        
        input[type="submit"],
        input[type="button"] {
            -webkit-appearance: none;
        }
    }
    
    /* Android-specific fixes */
    @supports not (-webkit-touch-callout: none) {
        /* Non-iOS devices */
        select.form-control {
            background-image: none;
        }
    }
    
    /* Make needs selection more mobile-friendly */
    .needs-selection {
        display: flex;
        flex-wrap: wrap;
    }
    
    .needs-selection .form-check {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure charts are responsive */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Journey Progress Styles */
.journey-progress ol {
    counter-reset: li-counter;
    list-style-type: none;
    padding-left: 0;
}

.journey-progress li {
    position: relative;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border-left: 5px solid #dee2e6;
}

.journey-progress li:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.journey-progress li.bg-success {
    border-left-color: #28a745;
}

.journey-progress li.bg-warning {
    border-left-color: #ffc107;
}

.journey-progress li.next-step {
    border-left-color: #007bff;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(0, 123, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

.next-step-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #007bff;
    animation: pulse 2s infinite;
}

.next-step-label {
    position: absolute;
    top: 0.5rem;
    right: 2rem;
    font-size: 0.7rem;
    font-weight: bold;
    color: #007bff;
    background-color: rgba(255,255,255,0.9);
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(0, 123, 255, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

.journey-progress li.in-progress {
    animation: progress-highlight 2s infinite;
}

@keyframes progress-highlight {
    0% { background-color: rgba(255, 193, 7, 0.1); }
    50% { background-color: rgba(255, 193, 7, 0.3); }
    100% { background-color: rgba(255, 193, 7, 0.1); }
}

/* Achievement Badge Styles */
.achievement-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.achievement-badge.gold {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: 2px solid #FFD700;
}

.achievement-badge.silver {
    background: linear-gradient(45deg, #C0C0C0, #A9A9A9);
    border: 2px solid #C0C0C0;
}

.achievement-badge.show {
    opacity: 1;
    transform: scale(1);
}

/* Contextual Help Styles */
.contextual-help {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.contextual-help i {
    width: 20px;
    height: 20px;
    background-color: #17a2b8;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
}

.help-tooltip {
    position: absolute;
    right: 25px;
    top: 0;
    width: 250px;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.75rem;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    font-size: 0.8rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 20;
}

.contextual-help:hover .help-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Performance Score Heading Styling */
.performance-title h5 {
    color: #1a1a1a;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 1px;
}

/* ============================================
   COMPREHENSIVE MOBILE RESPONSIVE STYLES
   ============================================ */

/* Mobile-first base adjustments */
@media (max-width: 991px) {
    /* Tablet and below - adjust grid layouts */
    .col-md-8, .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    /* Remove border on stacked columns */
    [style*="border-left"] {
        border-left: none !important;
        border-top: 1px solid rgba(255,255,255,0.2) !important;
        padding-left: 0 !important;
        padding-top: 1rem !important;
        margin-top: 1rem;
    }
    
    /* Chart containers responsive */
    .enhanced-chart-container,
    .chart-canvas-wrapper {
        height: auto !important;
        min-height: 250px;
    }
    
    canvas {
        max-height: 300px;
    }
}

@media (max-width: 767px) {
    /* Mobile phones */
    
    /* Typography scaling */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.3rem !important; }
    h3 { font-size: 1.15rem !important; }
    h4 { font-size: 1.1rem !important; }
    h5 { font-size: 1rem !important; }
    h6 { font-size: 0.9rem !important; }
    
    .display-3 {
        font-size: 2.5rem !important;
    }
    
    .display-4 {
        font-size: 2rem !important;
    }
    
    /* Navbar mobile adjustments */
    .navbar-brand {
        font-size: 1rem !important;
    }
    
    .navbar-brand img {
        height: 30px !important;
    }
    
    .navbar-toggler {
        padding: 0.5rem;
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Card layouts for mobile */
    .card {
        margin-bottom: 1rem;
        border-radius: 10px !important;
    }
    
    .card-header {
        padding: 0.75rem !important;
        font-size: 0.9rem;
    }
    
    .card-header h5,
    .card-header .h5 {
        font-size: 0.95rem !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    /* Form elements mobile-friendly */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
        padding: 12px !important;
        min-height: 48px;
        border-radius: 8px !important;
    }
    
    /* Buttons mobile-optimized */
    .btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 48px;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group .btn,
    .btn-group-vertical .btn {
        width: auto;
    }
    
    /* Row adjustments */
    .row {
        margin-left: -8px;
        margin-right: -8px;
    }
    
    .row > [class*="col-"] {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    /* Proposition summary mobile */
    .proposition-summary .row {
        flex-direction: column;
    }
    
    .proposition-summary .col-md-8,
    .proposition-summary .col-md-4 {
        border-left: none !important;
        padding-left: 0 !important;
        text-align: center;
    }
    
    /* Avatar images on mobile */
    img[src*="avatars"] {
        height: 60px !important;
        margin-bottom: 0.25rem;
    }
    
    /* Flex containers stack on mobile */
    .d-flex.flex-wrap {
        justify-content: center;
    }
    
    /* Alerts mobile styling */
    .alert {
        padding: 0.75rem !important;
        font-size: 0.85rem;
    }
    
    .alert h6 {
        font-size: 0.9rem !important;
    }
    
    /* Tables responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    /* Modals mobile full-width */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* News ticker mobile */
    .finextra-ticker-wrapper,
    .fca-ticker-wrapper {
        font-size: 0.75rem;
    }
    
    .ticker-label {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.7rem !important;
    }
    
    /* Compliance review specific */
    .compliance-score-display {
        text-align: center;
    }
    
    .compliance-score-display .display-3 {
        font-size: 3rem !important;
    }
    
    /* Score breakdown mobile */
    .score-breakdown .badge {
        display: block;
        margin-bottom: 0.25rem;
    }
    
    /* Market insights mobile */
    .market-insights-card .row > div {
        margin-bottom: 0.5rem;
    }
    
    /* Progress bars mobile */
    .progress {
        height: 1.5rem;
    }
    
    /* Chatbot mobile */
    .chatbot-container,
    .compliance-chatbot {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        max-width: 100% !important;
        height: 60vh !important;
        border-radius: 15px 15px 0 0 !important;
        z-index: 1050;
    }
    
    .chat-messages {
        max-height: 40vh !important;
    }
    
    /* Consumer Duty Evaluation mobile */
    .consumer-duty-panel {
        max-height: 70vh !important;
        overflow-y: auto;
    }
    
    /* Key Performance Metrics mobile grid */
    .key-metrics-grid,
    .metrics-container {
        display: flex;
        flex-wrap: wrap;
    }
    
    .key-metrics-grid > div,
    .metrics-container > div {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 0.5rem;
    }
    
    /* Loading overlay mobile */
    #submission-loading-overlay .progress {
        width: 90% !important;
        max-width: 300px;
    }
    
    #submission-loading-overlay h2 {
        font-size: 1.25rem !important;
    }
    
    #submission-loading-overlay p {
        font-size: 0.85rem !important;
    }
    
    /* Hide less important elements on mobile */
    .d-mobile-none {
        display: none !important;
    }
    
    /* Stack horizontal lists vertically */
    ul.list-inline {
        display: flex;
        flex-direction: column;
    }
    
    /* Reduce icon sizes */
    .fas, .fab, .far, .bi {
        font-size: 0.9em;
    }
    
    /* How this page works section mobile */
    .how-it-works .col-md-4 {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .how-it-works .col-md-4:last-child {
        border-bottom: none;
    }
}

/* Extra small screens (< 480px) */
@media (max-width: 480px) {
    /* Even more compact for very small phones */
    
    .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    .card-body {
        padding: 0.5rem !important;
    }
    
    h1 { font-size: 1.25rem !important; }
    h2 { font-size: 1.15rem !important; }
    h3 { font-size: 1rem !important; }
    
    .display-3 {
        font-size: 2rem !important;
    }
    
    /* Full-width buttons */
    .btn {
        display: block;
        width: 100%;
    }
    
    /* Single column for metrics */
    .key-metrics-grid > div,
    .metrics-container > div {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Avatar images smaller */
    img[src*="avatars"] {
        height: 50px !important;
    }
    
    /* Chart even smaller */
    canvas {
        max-height: 200px !important;
    }
    
    /* Navbar compact */
    .navbar {
        padding: 0.4rem 0.5rem !important;
    }
}

/* Landscape orientation fixes */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .chatbot-container,
    .compliance-chatbot {
        height: 80vh !important;
    }
    
    .chat-messages {
        max-height: 50vh !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    .nav-link,
    .dropdown-item,
    .list-group-item {
        padding: 12px 16px !important;
        min-height: 48px;
    }
    
    /* Prevent text selection on buttons */
    .btn {
        user-select: none;
        -webkit-user-select: none;
    }
}