/* ========================================
   MOBILE.CSS - Responsive & Mobile Optimierung
   CSS3 Media Queries & Touch-Optimized Styling
   ======================================== */

/* ========================================
   BURGER MENU STYLING
   ======================================== */

.burger-menu {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 2000;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.burger-menu:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.burger-menu:active {
    transform: scale(0.95);
}

.burger-line {
    width: 24px;
    height: 3px;
    background-color: white;
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

/* Burger Menu Animation States */
.burger-menu.active .burger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.burger-menu.active .burger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
}

.burger-menu.active .burger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Mobile Sidebar Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   TABLET LANDSCAPE (1024px - 1280px)
   ======================================== */

@media (max-width: 1280px) and (min-width: 1025px) {
    :root {
        --sidebar-width: 220px;
        --activity-bar-width: 45px;
    }

    .copilot-panel {
        width: 400px;
        max-height: 65vh;
    }

    .context-panel,
    .agent-skills-panel,
    .conversation-starters-panel {
        width: 280px;
    }

    .editor-toolbar {
        padding: 6px 10px;
    }

    .preview-toggle-btn,
    .open-browser-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* ========================================
   TABLET PORTRAIT (768px - 1024px)
   ======================================== */

@media (max-width: 1024px) and (min-width: 769px) {
    :root {
        --sidebar-width: 200px;
        --activity-bar-width: 40px;
    }

    .activity-bar-button {
        height: 45px;
    }

    .file-item,
    .context-item,
    .skill-item {
        padding: 8px 12px;
    }

    .copilot-panel {
        width: 380px;
        max-height: 60vh;
    }

    .context-panel,
    .agent-skills-panel {
        width: 260px;
        max-height: 70vh;
    }

    .conversation-starters-panel {
        width: 360px;
        max-height: 550px;
    }

    .starter-buttons {
        gap: 8px;
    }

    /* Touch-friendly sizing */
    .activity-bar-button,
    .file-item,
    .editor-tab {
        min-height: 44px; /* Apple's recommended touch target */
    }
}

/* ========================================
   MOBILE LANDSCAPE (568px - 768px)
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .status-bar {
        height: 18px;
        font-size: 11px;
    }

    .status-item {
        margin-right: 10px;
    }

    .copilot-panel {
        width: 50%;
        max-height: 80vh;
        right: 0;
        left: auto;
    }

    .mobile-nav {
        padding: 5px 0;
    }

    .mobile-nav-button i {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .mobile-nav-button span {
        font-size: 10px;
    }

    .editor-toolbar {
        padding: 4px 8px;
        gap: 6px;
    }
}

/* ========================================
   MOBILE PORTRAIT (max-width: 768px)
   ======================================== */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --activity-bar-width: 0;
        --status-bar-height: 20px;
    }

    /* Hide activity bar on mobile */
    .activity-bar {
        display: none !important;
    }

    /* Show burger menu */
    .burger-menu {
        display: flex;
    }

    /* Sidebar becomes full-screen slide-in */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-header {
        padding: 15px;
        padding-top: 80px; /* Space for burger menu */
    }

    .sidebar-content {
        height: calc(100vh - 140px);
    }

    /* Editor container full width */
    .editor-container {
        margin-left: 0;
        width: 100%;
    }

    /* Show mobile navigation */
    .mobile-nav {
        display: block;
        height: 65px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    }

    .mobile-nav-buttons {
        padding: 8px 0;
        height: 100%;
    }

    .mobile-nav-button {
        padding: 5px;
        font-size: 11px;
        min-width: 60px;
        gap: 3px;
    }

    .mobile-nav-button i {
        font-size: 22px;
        margin-bottom: 3px;
    }

    .mobile-nav-button:active {
        transform: scale(0.9);
        background: var(--hover-bg);
        border-radius: 8px;
    }

    /* Copilot panel full width on mobile */
    .copilot-panel {
        width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        bottom: 65px; /* Above mobile nav */
    }

    .copilot-header {
        padding: 14px 18px;
    }

    .copilot-header h3 {
        font-size: 16px;
    }

    .copilot-content {
        padding: 15px;
        max-height: calc(70vh - 150px);
    }

    .copilot-input {
        padding: 12px 15px;
    }

    .copilot-input input {
        font-size: 15px; /* Prevent zoom on iOS */
    }

    .copilot-float-btn {
        bottom: 85px; /* Above mobile nav */
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    /* Context panel full width */
    .context-panel {
        width: 100%;
        max-height: 60vh;
        top: auto;
        bottom: 65px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    /* Agent skills panel full width */
    .agent-skills-panel {
        width: 100%;
        max-height: 60vh;
        top: auto;
        bottom: 65px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    /* Conversation starters panel full width */
    .conversation-starters-panel {
        width: 100%;
        max-width: 100%;
        height: 80vh;
        max-height: 80vh;
        top: auto;
        bottom: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .conversation-starters-content {
        padding: 15px;
        max-height: calc(80vh - 80px);
    }

    .starter-category {
        margin-bottom: 15px;
    }

    .starter-buttons {
        gap: 10px;
    }

    .starter-button {
        padding: 14px;
        min-height: 80px;
    }

    .starter-button:active {
        transform: translateY(0) scale(0.97);
    }

    /* Editor tabs optimization */
    .editor-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .editor-tab {
        padding: 10px 14px;
        min-width: 120px;
        font-size: 14px;
    }

    .editor-toolbar {
        padding: 8px 10px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .preview-toggle-btn,
    .open-browser-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Status bar mobile optimization */
    .status-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 8px;
    }

    .status-item {
        margin-right: 12px;
        font-size: 11px;
        white-space: nowrap;
    }

    /* File tree touch optimization */
    .file-item {
        padding: 12px 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .file-icon {
        margin-right: 10px;
        width: 20px;
    }

    /* Message bubbles touch-friendly */
    .message {
        margin-bottom: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .message-content {
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.5;
    }

    /* Code blocks mobile optimization */
    .code-block-container {
        margin: 10px -5px;
    }

    .code-block-header {
        padding: 6px 10px;
        font-size: 11px;
    }

    .copy-code-btn {
        padding: 4px 10px;
        font-size: 10px;
    }

    /* Prevent zoom on input focus (iOS) */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* ========================================
   SMALL MOBILE (max-width: 480px)
   ======================================== */

@media (max-width: 480px) {
    .burger-menu {
        width: 45px;
        height: 45px;
        top: 12px;
        left: 12px;
    }

    .burger-line {
        width: 20px;
        height: 2.5px;
    }

    .sidebar {
        width: 90%;
        max-width: 280px;
    }

    .sidebar-header {
        padding: 12px;
        padding-top: 75px;
        font-size: 14px;
    }

    .mobile-nav {
        height: 60px;
    }

    .mobile-nav-button {
        font-size: 10px;
        min-width: 55px;
    }

    .mobile-nav-button i {
        font-size: 20px;
    }

    .copilot-panel {
        max-height: 75vh;
        bottom: 60px;
    }

    .copilot-header h3 {
        font-size: 15px;
    }

    .copilot-content {
        padding: 12px;
    }

    .copilot-input {
        padding: 10px 12px;
        gap: 8px;
    }

    .copilot-input button {
        padding: 10px 18px;
        font-size: 13px;
    }

    .copilot-float-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
        bottom: 75px;
        right: 15px;
    }

    .context-panel,
    .agent-skills-panel {
        max-height: 55vh;
        bottom: 60px;
    }

    .conversation-starters-panel {
        height: 85vh;
        max-height: 85vh;
    }

    .starter-buttons {
        grid-template-columns: 1fr;
    }

    .starter-button {
        min-height: 70px;
    }

    .editor-tab {
        padding: 8px 12px;
        min-width: 100px;
        font-size: 13px;
    }

    .editor-tab-close {
        width: 14px;
        height: 14px;
        margin-left: 6px;
    }

    .status-bar {
        height: 18px;
        font-size: 10px;
    }

    .status-item {
        margin-right: 8px;
    }

    .file-item {
        padding: 10px 12px;
    }

    .message-content {
        font-size: 13px;
    }
}

/* ========================================
   EXTRA SMALL MOBILE (max-width: 375px)
   ======================================== */

@media (max-width: 375px) {
    .burger-menu {
        width: 42px;
        height: 42px;
        top: 10px;
        left: 10px;
    }

    .burger-line {
        width: 18px;
    }

    .sidebar {
        width: 95%;
    }

    .mobile-nav {
        height: 55px;
    }

    .mobile-nav-button {
        font-size: 9px;
        min-width: 50px;
        padding: 3px;
    }

    .mobile-nav-button i {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .copilot-panel {
        bottom: 55px;
    }

    .copilot-float-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
        bottom: 70px;
        right: 12px;
    }

    .context-panel,
    .agent-skills-panel {
        bottom: 55px;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION SPECIFIC
   ======================================== */

@media (max-width: 896px) and (orientation: landscape) {
    .sidebar {
        width: 60%;
        max-width: 300px;
    }

    .mobile-nav {
        height: 50px;
    }

    .mobile-nav-button i {
        font-size: 16px;
    }

    .copilot-panel {
        max-height: 85vh;
    }

    .conversation-starters-panel {
        height: 90vh;
        max-height: 90vh;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly tap areas */
    .activity-bar-button,
    .file-item,
    .editor-tab,
    .mobile-nav-button,
    .starter-button,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects, add active states */
    .activity-bar-button:hover,
    .file-item:hover,
    .mobile-nav-button:hover,
    .starter-button:hover {
        background-color: var(--hover-bg);
    }

    .activity-bar-button:active,
    .file-item:active,
    .mobile-nav-button:active {
        background-color: var(--active-bg);
        opacity: 0.8;
    }

    /* Better scrolling on touch devices */
    .sidebar-content,
    .copilot-content,
    .context-content,
    .agent-skills-content,
    .conversation-starters-content,
    .editor-tabs,
    .status-bar {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* Prevent text selection on double-tap */
    .mobile-nav-button,
    .activity-bar-button,
    .starter-button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .activity-bar,
    .sidebar,
    .mobile-nav,
    .status-bar,
    .copilot-panel,
    .copilot-float-btn,
    .context-panel,
    .agent-skills-panel,
    .conversation-starters-panel,
    .burger-menu,
    .mobile-overlay,
    .editor-toolbar {
        display: none !important;
    }

    .editor-container {
        width: 100%;
        margin: 0;
    }

    body {
        background: white;
        color: black;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .burger-menu,
    .sidebar,
    .mobile-overlay {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .burger-menu,
    .mobile-nav-button,
    .file-item,
    .editor-tab {
        border: 2px solid currentColor;
    }

    .mobile-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Dark mode preferences */
@media (prefers-color-scheme: dark) {
    .mobile-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

/* ========================================
   CUSTOM SCROLLBAR FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Webkit browsers (Chrome, Safari, Edge) */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    /* Firefox */
    * {
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }
}

/* ========================================
   UTILITY CLASSES FOR MOBILE
   ======================================== */

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* Safe area insets for notched devices (iPhone X+) */
@supports (padding: max(0px)) {
    .mobile-nav {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-top: max(0px, env(safe-area-inset-top));
    }
}
