/* Basic styles - Mobile first */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    -webkit-text-size-adjust: 100%; /* Prevent text size adjustment on orientation change */
}

html, body {
    height: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
    /* Hide scrollbars */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Webkit browsers */
body::-webkit-scrollbar {
    display: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 15px;
    position: relative;
    min-height: 100vh;
    /* Allow normal vertical scrolling */
    overflow-y: auto;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #147EFB;
    font-size: 1.5rem;
}

.content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* GeekyAI floating widget styles - Mobile optimized */
.geeky-ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* Floating button - Mobile optimized */
.geeky-toggle-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #147EFB, #0d6efd);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(20, 126, 251, 0.4);
    transition: all 0.3s ease;
    border: none;
    font-size: 24px;
    position: relative;
    z-index: 1001;
    touch-action: manipulation; /* Improve touch responsiveness */
}

.geeky-toggle-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(20, 126, 251, 0.6);
}

/* Chat window - Mobile optimized */
.geeky-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: calc(100vw - 40px);
    max-width: 400px;
    height: 70vh;
    min-height: 400px;
    max-height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Hide scrollbars */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Ensure fixed position during page scroll */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Hide scrollbar for Webkit browsers */
.geeky-chat-window::-webkit-scrollbar {
    display: none;
}

.geeky-chat-window.active {
    display: flex;
    animation: slideUpMobile 0.3s ease;
}

@keyframes slideUpMobile {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) translateZ(0);
    }
}

/* Window header - Mobile optimized */
.geeky-header {
    background: linear-gradient(135deg, #147EFB, #0d6efd);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
    position: relative;
}

.geeky-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.geeky-title i {
    margin-right: 8px;
    font-size: 1.2rem;
}

.geeky-controls {
    display: flex;
    gap: 8px;
}

.geeky-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    touch-action: manipulation;
}

.geeky-control-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
}

/* Chat content area - Mobile optimized */
.geeky-chat-content {
    flex: 1; /* Take remaining space */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Hide scrollbars */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Hide scrollbar for Webkit browsers */
.geeky-chat-content::-webkit-scrollbar {
    display: none;
}

.geeky-iframe-container {
    flex: 1;
    border: none;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
    /* Hide scrollbars */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Prevent scrolling in iframe container */
    overflow: hidden !important;
}

/* Hide scrollbar for Webkit browsers */
.geeky-iframe-container::-webkit-scrollbar {
    display: none;
}

.geeky-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    /* Hide scrollbars */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Prevent iframe from creating scroll */
    overflow: hidden !important;
    pointer-events: auto;
    /* Hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Hide scrollbar for Webkit browsers */
.geeky-iframe-container iframe::-webkit-scrollbar {
    display: none;
}

/* Mobile device specific styles */
@media (max-width: 480px) {
    .geeky-chat-window {
        width: calc(100vw - 30px);
        right: 15px;
        bottom: 80px;
        height: 75vh;
        max-height: none;
    }
    
    .geeky-toggle-button {
        width: 55px;
        height: 55px;
        right: 15px;
        bottom: 15px;
    }
    
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
    }
    
    .content {
        padding: 15px;
    }
}

/* Landscape mode optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .geeky-chat-window {
        height: 85vh;
        min-height: 300px;
    }
}

/* Large phone optimization */
@media (min-width: 481px) and (max-width: 768px) {
    .geeky-chat-window {
        width: 380px;
    }
}

/* Tablet optimization */
@media (min-width: 769px) {
    .geeky-chat-window {
        width: 400px;
        height: 600px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #f8f9fa;
    }
    
    .content {
        background: #2d2d2d;
        color: #f8f9fa;
    }
    
    .geeky-chat-window {
        background: #2d2d2d;
        color: #f8f9fa;
        border: 1px solid #404040;
    }
}

/* Accessibility support */
.geeky-toggle-button:focus,
.geeky-control-btn:focus {
    outline: 2px solid #147EFB;
    outline-offset: 2px;
}

/* Loading state */
.geeky-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.geeky-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #147EFB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Safe area adaptation for iPhone X and above */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .geeky-ai-widget {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    .geeky-chat-window {
        bottom: calc(90px + env(safe-area-inset-bottom));
    }
    
    @media (max-width: 480px) {
        .geeky-chat-window {
            bottom: calc(80px + env(safe-area-inset-bottom));
        }
        
        .geeky-toggle-button {
            bottom: calc(15px + env(safe-area-inset-bottom));
        }
    }
}

/* Overlay - Fix black area issue */
.geeky-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    /* Ensure overlay covers entire page */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.geeky-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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