/**
 * Mobile styles for Mac Portfolio WordPress Theme
 * iOS Files app inspired interface
 */

/* Mobile-specific styles (max-width: 767px) */
@media (max-width: 767px) {
    /* Hide desktop preview side panel and info panel entirely on mobile */
    #preview-panel,
    .preview-panel,
    .info-panel {
        display: none !important;
    }
    
    /* Give content area full width on mobile */
    .window-content {
        display: block !important;
        width: 100% !important;
    }
    .content-area {
        width: 100% !important;
        padding: 12px 15px 90px;
        background-color: #f2f2f7;
        min-height: 100vh;
    }

    /* When a folder is open, show items as tiles (2-up, iOS Files-style) */
    .folder-content {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px 16px;
        padding: 12px 0;
    }
    .folder-content .file-item,
    .folder-content .folder-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        cursor: pointer;
        height: fit-content;
    }
    .folder-content .folder-item-icon {
        width: 80px;
        height: 80px;
        object-fit: contain;
        margin-bottom: 8px;
    }
    .folder-content .folder-item-name,
    .folder-content span {
        font-size: 13px;
        line-height: 1.2;
        color: #000;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }

    /* iOS-style header */
    .top-bar {
        background-color: #f2f2f7;
        padding: 10px 15px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 44px;
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    .top-bar-title {
        font-size: 17px;
        font-weight: 600;
        text-align: center;
        flex: 1;
    }
    
    .back-button {
        color: #007aff;
        font-size: 17px;
        display: flex;
        align-items: center;
    }
    
    .back-button:before {
        content: "‹";
        font-size: 24px;
        margin-right: 2px;
    }
    
    .options-button {
        color: #007aff;
        font-size: 20px;
    }
    
    /* Search bar */
    .search-bar {
        background-color: rgba(142, 142, 147, 0.12);
        border-radius: 10px;
        margin: 8px 15px 0;
        padding: 8px 15px;
        display: flex;
        align-items: center;
        height: 36px;
    }
    
    .search-bar input {
        background: transparent;
        border: none;
        font-size: 17px;
        width: 100%;
        outline: none;
    }
    
    .search-icon {
        color: #8e8e93;
        margin-right: 8px;
    }
    
    /* Main content area (uses .content-area in index.php) */
    .content-area {
        padding: 12px 15px 90px;
        background-color: #f2f2f7;
        min-height: 100vh;
        margin-top: 56px; /* below top bar */
    }
    
    /* Section headers */
    .section-header {
        font-size: 22px;
        font-weight: 700;
        margin: 20px 0 10px;
        padding-left: 5px;
    }
    
    /* Hide h2 headings in folder view */
    .main-content h2,
    .folder-content h2 {
        display: none;
    }
    
    /* Folder grid */
    .folder-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px 18px; /* tighter vertical spacing */
        grid-auto-rows: 4.5rem; /* ~4-5rem row height */
        padding: 10px 0 90px; /* leave space for bottom tab bar */
    }
    
    /* Folder item */
    .file-item[data-type="folder"] {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 5px;
        transition: all 0.2s ease;
    }
    
    .file-item[data-type="folder"]:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    .file-item[data-type="folder"] img {
        width: 88px;
        height: 56px; /* slightly shorter to free space for title */
        margin-bottom: 4px;
        border-radius: 12px;
        display: block;
        object-fit: contain; /* prevent cropping */
        background: transparent;
        box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    }
    
    .file-item[data-type="folder"] span {
        display: block; /* ensure title shows */
        margin-top: 2px;
        font-size: 14px;
        line-height: 1.2;
        color: #000;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Item count */
    .item-count {
        font-size: 12px;
        color: #8e8e93;
        margin-top: 2px;
    }
    
    /* Bottom tab bar */
    .tab-bar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 60px;
        background: #f8f8f8;
        border-top: 1px solid #e5e5ea;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: space-around;
        padding: 10px 0;
        z-index: 1000;
    }
    
    .tab-item {
        flex: 1;
        text-align: center;
        color: #8e8e93;
    }
    .tab-item .tab-icon {
        margin: 0 auto 2px;
        color: #8e8e93;
    }
    .tab-item .tab-label {
        font-size: 10px;
    }
    .tab-item.active, .tab-item.active .tab-icon {
        color: #007aff;
    }
    
    .tab-icon {
        font-size: 22px;
        margin-bottom: 2px;
    }
    
    /* Mobile preview overlay (iOS Files-style) */
    .mobile-preview {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 60px; /* Leave space for tab bar */
        background: white;
        z-index: 999;
        display: none;
        flex-direction: column;
    }
    .mobile-preview.active {
        display: flex;
    }
    
    /* Keep footer visible during preview */
    .mobile-preview.active ~ .mobile-footer,
    .mobile-preview.active ~ .tab-bar {
        z-index: 1000;
    }
    
    /* Preview header */
    .mobile-preview .preview-header {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 44px;
        background: rgba(255,255,255,0.95);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid #e5e5ea;
        z-index: 1;
        padding: 0 15px;
    }
    .mobile-preview .preview-title {
        font-size: 17px;
        font-weight: 600;
        color: #000;
        text-align: center;
        flex: 1;
    }
    .mobile-preview .preview-done {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        height: auto;
        padding: 0;
        border: none;
        background: transparent;
        color: #007aff;
        font-size: 17px;
        cursor: pointer;
        font-weight: 400;
    }
    
    /* Preview content area */
    .mobile-preview .preview-content {
        flex: 1;
        overflow-y: auto;
        padding: 20px 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        background: white;
    }
    
    /* Image preview */
    .mobile-preview .preview-content img {
        width: 100%;
        height: auto;
        border-radius: 0;
        box-shadow: none;
    }
    
    /* Video preview */
    .mobile-preview .preview-content video {
        width: 100%;
        height: auto;
        border-radius: 0;
        box-shadow: none;
    }
    
    /* Text preview */
    .mobile-preview .preview-text-content {
        width: 100%;
        padding: 0;
        background: white;
        font-size: 17px;
        line-height: 1.5;
        color: #000;
    }
    
    /* Preview action buttons */
    .mobile-preview .preview-actions {
        display: flex;
        gap: 12px;
        margin-top: 20px;
        padding: 0 15px;
    }
    .mobile-preview .preview-action-btn {
        flex: 1;
        padding: 12px;
        border: none;
        border-radius: 10px;
        background: #007aff;
        color: white;
        font-size: 16px;
        font-weight: 500;
        cursor: pointer;
    }
    
    /* File details view */
    .file-details {
        background-color: #fff;
        border-radius: 10px;
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .file-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 20px;
    }
    
    .file-title {
        font-size: 17px;
        font-weight: 600;
    }
    
    .file-action {
        color: #007aff;
        font-size: 17px;
    }
    
    .file-info-row {
        display: flex;
        justify-content: space-between;
        padding: 10px 0;
        border-bottom: 1px solid #e5e5ea;
    }
    
    .file-info-label {
        color: #8e8e93;
    }
    
    .file-info-value {
        color: #000;
        text-align: right;
    }
    
    /* Hide desktop elements */
    .sidebar, 
    .window-controls, 
    .status-bar,
    .desktop-only,
    .main-content h2,
    .folder-content h2 {
        display: none !important;
    }
    
    /* Adjust main window */
    .finder-window {
        width: 100%;
        height: auto;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
    
    .window-content {
        height: auto;
        padding: 0;
    }
    
    /* Adjust preview panel */
    .preview-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 2000;
        padding: 0 0 70px;
        overflow-y: auto;
        display: none;
    }
    
    .preview-panel.active {
        display: block;
    }
    
    /* Preview header */
    .preview-header {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 44px;
        background: rgba(242,242,247,0.9);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid #e5e5ea;
        z-index: 1;
    }
    .preview-title {
        font-size: 17px;
        font-weight: 600;
        color: #000;
        max-width: 60%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .preview-done {
        position: absolute;
        right: 12px;
        top: 8px;
        height: 28px;
        padding: 0 8px;
        border: none;
        background: transparent;
        color: #007aff;
        font-size: 17px;
    }
    .preview-content {
        padding: 12px 15px 24px;
    }
    .mobile-video-wrapper { margin-top: 8px; }
    
    /* ... */
    .folder-item {
        display: flex;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid #e5e5ea;
    }
    
    .folder-item-icon {
        width: 40px;
        height: 40px;
        margin-right: 15px;
    }
    
    .folder-item-details {
        flex: 1;
    }
    
    .folder-item-name {
        font-size: 17px;
        margin-bottom: 2px;
    }
    
    .folder-item-info {
        font-size: 13px;
        color: #8e8e93;
    }
    
    /* Adjust for notch on newer iPhones */
    @supports (padding-top: env(safe-area-inset-top)) {
        .top-bar {
            padding-top: calc(env(safe-area-inset-top) + 10px);
            height: calc(env(safe-area-inset-top) + 44px);
        }
        
        .main-content {
            margin-top: calc(env(safe-area-inset-top) + 60px);
        }
        
        .tab-bar {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
    
    /* BXYZ Credit Overlay - Mobile Only */
    .bxyz-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        background: linear-gradient(180deg, rgba(0, 150, 255, 0.95) 0%, rgba(0, 120, 220, 0.95) 100%);
        border-radius: 0 0 24px 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 100000;
        opacity: 0;
        pointer-events: none;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
    
    .bxyz-content {
        text-align: center;
        color: white;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    }
    
    .bxyz-content p {
        font-size: 24px;
        font-weight: 600;
        margin: 0;
        opacity: 0;
    }
    
    .bxyz-content a {
        color: white;
        text-decoration: none;
        border-bottom: 2px solid white;
        transition: opacity 0.3s ease;
    }
    
    .bxyz-content a:hover {
        opacity: 0.8;
    }
}
