/* OSINT.science Mobile Responsive Styles */

/* Mobile Variables */
:root {
    --mobile-nav-height: 56px;
    --mobile-bottom-nav-height: 60px;
}

/* ============================================
   Mobile Navigation
   ============================================ */

/* Mobile Top Bar */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    padding: 0 var(--space-md);
    align-items: center;
    justify-content: space-between;
}

.mobile-header .logo {
    font-size: var(--font-size-lg);
}

.mobile-menu-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.mobile-menu-btn:active {
    background: var(--bg-hover);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-bottom-nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0;
}

.mobile-nav-items {
    display: flex;
    height: 100%;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    text-decoration: none;
    padding: 8px 4px;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item:active {
    background: var(--bg-hover);
}

.mobile-nav-icon {
    font-size: 20px;
    font-weight: bold;
}

/* Mobile Search Bar */
.mobile-search-bar {
    display: none;
    position: fixed;
    top: var(--mobile-nav-height);
    left: 0;
    right: 0;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 99;
}

.mobile-search-bar .search-input-wrapper {
    margin: 0;
}

.mobile-search-bar input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
}

.mobile-search-bar .search-btn {
    padding: 12px 16px;
}

/* ============================================
   Mobile Overlay Panels
   ============================================ */

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Mobile Panel Close Button - hidden on desktop */
.mobile-panel-close {
    display: none;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet - 1024px and below */
@media (max-width: 1024px) {
    :root {
        --sidebar-left-width: 240px;
        --sidebar-right-width: 220px;
    }

    .toolbar-btn .btn-text {
        display: none;
    }
}

/* Mobile - 768px and below */
@media (max-width: 768px) {
    /* Show mobile elements */
    .mobile-header,
    .mobile-bottom-nav,
    .mobile-search-bar {
        display: flex;
    }

    .mobile-panel-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: 50%;
        color: var(--text-primary);
        font-size: 20px;
        line-height: 1;
        z-index: 10;
        cursor: pointer;
    }

    /* Left Sidebar Mobile Panel */
    .sidebar-left.mobile-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        z-index: 201;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding-top: 60px;
        background: var(--bg-secondary);
    }

    .sidebar-left.mobile-panel.active {
        transform: translateX(0);
    }

    /* Right Sidebar Mobile Panel */
    .sidebar-right.mobile-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        z-index: 201;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding-top: 60px;
        background: var(--bg-secondary);
    }

    .sidebar-right.mobile-panel.active {
        transform: translateX(0);
    }

    /* Hide desktop elements */
    .toolbar {
        display: none;
    }

    .status-bar {
        display: none;
    }

    /* Adjust main layout */
    #app {
        padding-top: calc(var(--mobile-nav-height) + 60px); /* header + search bar */
        padding-bottom: var(--mobile-bottom-nav-height);
    }

    .three-panel-layout {
        height: calc(100vh - var(--mobile-nav-height) - 60px - var(--mobile-bottom-nav-height));
        flex-direction: column;
    }

    /* Hide sidebars on mobile by default */
    .sidebar-left,
    .sidebar-right {
        display: none;
    }

    .sidebar-left.mobile-panel,
    .sidebar-right.mobile-panel {
        display: block;
    }

    /* Results panel full width */
    .results-panel {
        width: 100%;
        height: 100%;
    }

    /* Results header adjustments */
    .results-header {
        flex-direction: column;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
    }

    .results-controls {
        width: 100%;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .control-group {
        flex: 1;
        min-width: 120px;
    }

    .control-group select {
        width: 100%;
    }

    /* Results list adjustments */
    .results-list {
        padding: var(--space-sm);
    }

    /* Result card mobile styles */
    .result-card {
        padding: var(--space-md);
    }

    .result-title {
        font-size: var(--font-size-base);
    }

    .result-snippet {
        font-size: var(--font-size-sm);
        -webkit-line-clamp: 3;
    }

    .result-actions {
        flex-wrap: wrap;
        gap: var(--space-xs);
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: var(--space-md);
    }

    .modal-small {
        width: 95%;
    }

    /* Analysis modes wrap */
    .analysis-modes {
        flex-wrap: wrap;
    }

    .mode-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    /* Export options */
    .export-options {
        grid-template-columns: 1fr;
    }

    /* Category tree mobile */
    .category-panel {
        padding: var(--space-md);
    }

    .tree-node {
        margin-bottom: var(--space-xs);
    }

    .tree-header {
        padding: var(--space-sm);
        min-height: 44px; /* Touch target */
    }

    .tree-child {
        padding: var(--space-sm);
        min-height: 44px;
    }

    /* Quick search panel mobile */
    .quick-search {
        display: none; /* Hidden on mobile, using mobile search bar instead */
    }

    /* Panel titles */
    .panel-title {
        font-size: var(--font-size-base);
    }

    /* Task buttons larger touch targets */
    .task-btn {
        padding: var(--space-md);
        min-height: 44px;
    }

    /* Folder items */
    .folder-item {
        padding: var(--space-md);
        min-height: 44px;
    }

    /* History items */
    .history-item {
        padding: var(--space-md);
        min-height: 44px;
    }

    /* Hide certain desktop elements on mobile */
    .toolbar-center {
        display: none;
    }

    /* Placeholder adjustments */
    .results-placeholder {
        padding: var(--space-xl);
    }

    .placeholder-icon {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .results-placeholder h2 {
        font-size: var(--font-size-lg);
    }
}

/* Small phones - 480px and below */
@media (max-width: 480px) {
    .mobile-header {
        padding: 0 var(--space-sm);
    }

    .logo-text {
        font-size: var(--font-size-base);
    }

    .mobile-search-bar {
        padding: var(--space-xs) var(--space-sm);
    }

    .mobile-nav-item {
        font-size: 9px;
    }

    .mobile-nav-icon {
        font-size: 18px;
    }

    .results-header {
        padding: var(--space-xs) var(--space-sm);
    }

    .control-group {
        min-width: 100px;
    }

    .result-card {
        padding: var(--space-sm);
    }

    .modal-content {
        margin: var(--space-sm);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-md);
    }

    /* Advanced form on small screens */
    .advanced-form {
        gap: var(--space-sm);
    }

    .form-group input,
    .form-group select {
        padding: var(--space-sm);
        font-size: 16px; /* Prevent zoom */
    }
}

/* ============================================
   Touch Optimizations
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .toolbar-btn,
    .task-btn,
    .link-btn,
    .icon-btn,
    .checkbox-label {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .toolbar-btn:hover,
    .task-btn:hover,
    .folder-item:hover,
    .history-item:hover,
    .result-card:hover {
        background: transparent;
    }

    /* Add active states instead */
    .toolbar-btn:active,
    .task-btn:active,
    .folder-item:active,
    .history-item:active {
        background: var(--bg-hover);
    }

    /* Prevent text selection on interactive elements */
    button, .task-btn, .folder-item, .history-item, .mobile-nav-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ============================================
   Landscape Mode Adjustments
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
    .mobile-bottom-nav {
        height: 50px;
    }

    .mobile-nav-item {
        flex-direction: row;
        gap: 8px;
    }

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

    #app {
        padding-bottom: 50px;
    }

    .three-panel-layout {
        height: calc(100vh - var(--mobile-nav-height) - 60px - 50px);
    }

    .sidebar-left.mobile-panel,
    .sidebar-right.mobile-panel {
        width: 50%;
        max-width: 400px;
    }
}

/* ============================================
   Dark Mode Mobile Adjustments
   ============================================ */

@media (max-width: 768px) {
    body.dark-mode .mobile-header,
    body.dark-mode .mobile-bottom-nav,
    body.dark-mode .mobile-search-bar {
        background: var(--bg-secondary);
    }

    body.light-mode .mobile-header,
    body.light-mode .mobile-bottom-nav,
    body.light-mode .mobile-search-bar {
        background: var(--bg-primary);
        border-color: var(--border);
    }
}

/* ============================================
   PWA / Standalone Mode
   ============================================ */

@media (display-mode: standalone) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--mobile-nav-height) + env(safe-area-inset-top));
    }

    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom));
    }

    #app {
        padding-top: calc(var(--mobile-nav-height) + env(safe-area-inset-top) + 60px);
        padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom));
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .mobile-header,
    .mobile-bottom-nav,
    .mobile-search-bar,
    .sidebar-left,
    .sidebar-right,
    .toolbar,
    .status-bar {
        display: none !important;
    }

    #app {
        padding: 0;
    }

    .results-panel {
        width: 100%;
    }

    .result-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
