/* ========================================
   15. MOBILE RESPONSIVE
   ======================================== */

/* ========================================
   VERTICAL HEIGHT ADJUSTMENTS (from admin.css)
   ======================================== */
@media screen and (max-height: 800px) {
    .flashfolders-container {
        height: calc(100vh - 120px);
        min-height: 400px;
    }
}

@media screen and (max-height: 600px) {
    .flashfolders-container {
        height: calc(100vh - 80px);
        min-height: 350px;
    }
}

@media screen and (min-height: 1200px) {
    .flashfolders-container {
        height: calc(100vh - 180px);
        max-height: 1200px;
    }
}

/* ========================================
   HORIZONTAL WIDTH BREAKPOINTS
   ======================================== */

/* Tablet and mobile landscape (< 1024px) */
@media screen and (max-width: 1024px) {
    .flashfolders-container {
        height: calc(100vh - 100px);
    }
    
    .flashfolders-sidebar {
        min-width: 200px;
        width: 250px;
    }
    
    .flashfolders-details {
        min-width: 180px;
        width: 220px;
    }
    
    .flashfolders-toolbar {
        flex-wrap: wrap;
    }
    
    .flashfolders-search {
        max-width: 100%;
        order: -1;
        flex-basis: 100%;
        margin-bottom: var(--flashfolders-space-2);
    }
}




/* Mobile landscape and small tablets (< 768px) */
@media screen and (max-width: 768px) {
    .flashfolders-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 100px);
    }
    
    /* ✨ MOBILE: Main content first */
    .flashfolders-main {
        order: 1;
        width: 100%;
        min-width: auto;
        flex: 1;
    }
    
    /* ✨ MOBILE: Sidebar hidden */
    .flashfolders-sidebar {
        display: none !important;
    }
    
    /* Hide resizers on mobile */
    .flashfolders-resizer {
        display: none;
    }
    
    /* ✨ MOBILE: Details hidden (modal instead) */
    .flashfolders-details {
        display: none !important;
    }
    
    .flashfolders-details-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--flashfolders-space-4);
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        animation: flashfoldersFadeIn 0.2s ease-out;
    }
    
    .flashfolders-details-modal-content {
        background: #fff;
        border-radius: var(--flashfolders-radius-lg);
        width: 100%;
        max-width: 500px;
        max-height: 85vh;
        overflow-y: auto;
        box-shadow: var(--flashfolders-shadow-xl);
        animation: flashfoldersSlideUp 0.3s ease-out;
        position: relative;
    }
    
    .flashfolders-details-modal-header {
        position: sticky;
        top: 0;
        background: #fff;
        border-bottom: 1px solid var(--flashfolders-gray-200);
        padding: var(--flashfolders-space-4);
        display: flex;
        justify-content: space-between;
        align-items: center;
        z-index: 10;
    }
    
    .flashfolders-details-modal-close {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--flashfolders-gray-100);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all var(--flashfolders-transition-fast);
    }
    
    .flashfolders-details-modal-close:hover {
        background: var(--flashfolders-error-light);
        color: var(--flashfolders-error);
    }
    
    .flashfolders-details-modal-body {
        padding: var(--flashfolders-space-4);
    }
    
    /* Modal animations */
    @keyframes flashfoldersFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes flashfoldersSlideUp {
        from {
            transform: translateY(50px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Hide resizers on mobile */
    .flashfolders-resizer {
        display: none;
    }
    
    /* Main content takes full space */
    .flashfolders-main {
        width: 100%;
        min-width: auto;
    }
    
    /* Details panel goes below */
    .flashfolders-details {
        width: 100% !important;
        min-width: auto;
        max-width: 100%;
        border-left: none;
        border-top: 1px solid var(--flashfolders-gray-200);
        max-height: 300px;
    }
    
    /* More compact toolbar */
    .flashfolders-toolbar {
        padding: var(--flashfolders-space-2);
        gap: var(--flashfolders-space-2);
    }
    
    /* Smaller toolbar buttons */
    button.flashfolders-button-primary,
    .flashfolders-toolbar .components-button.is-primary,
    .flashfolders-new-folder-button {
        padding: var(--flashfolders-space-2) var(--flashfolders-space-3) !important;
        font-size: 13px;
    }
    
    /* More compact grid */
    .flashfolders-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--flashfolders-space-2);
    }
    
    .flashfolders-grid-item img {
        height: 80px;
    }
    
    .flashfolders-grid-item-name {
        font-size: 11px;
    }
    
    /* List view on mobile */
    .flashfolders-list .flashfolders-grid-item,
    .flashfolders-list .flashfolders-folder-card {
        grid-template-columns: 50px 1fr;
        gap: var(--flashfolders-space-2);
        padding: var(--flashfolders-space-2);
    }
    
    .flashfolders-list .flashfolders-grid-item img {
        width: 50px;
        height: 50px;
    }
    
    /* Hide extra columns in list view */
    .flashfolders-list-header,
    .flashfolders-list .flashfolders-grid-item > div:nth-child(3),
    .flashfolders-list .flashfolders-grid-item > div:nth-child(4) {
        display: none;
    }
    
    /* More compact folder tree */
    .flashfolders-folder-item {
        padding: var(--flashfolders-space-2);
        font-size: 13px;
    }
    
    .flashfolders-folder-children {
        padding-left: var(--flashfolders-space-4);
        margin-left: var(--flashfolders-space-2);
    }
    
    /* Smaller folder actions */
    .flashfolders-folder-action-button {
        min-width: 24px !important;
        min-height: 24px !important;
    }
    
    /* More compact details */
    .flashfolders-details-image {
        margin-bottom: var(--flashfolders-space-2);
    }
    
    .flashfolders-details-info-item {
        padding: var(--flashfolders-space-2) 0;
        font-size: 12px;
    }
}

/* Mobile portrait (< 480px) */
@media screen and (max-width: 480px) {
    /* WordPress admin header */
    .wrap h1 {
        font-size: 20px;
    }
    
    /* Even more compact container */
    .flashfolders-container {
        margin-top: var(--flashfolders-space-3);
        border-radius: var(--flashfolders-radius-md);
    }
    
    /* Even smaller sidebar */
    .flashfolders-sidebar {
        max-height: 150px;
        padding: var(--flashfolders-space-2);
    }
    
    /* Single column toolbar */
    .flashfolders-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .flashfolders-search {
        margin-bottom: var(--flashfolders-space-2);
    }
    
    /* Full width toolbar buttons */
    button.flashfolders-button-primary,
    .flashfolders-toolbar .components-button.is-primary,
    .flashfolders-new-folder-button {
        width: 100%;
        justify-content: center;
    }
    
    /* Side by side view mode buttons */
    .flashfolders-toolbar > div:last-child {
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }
    
    /* 2 column grid on small mobile */
    .flashfolders-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Ultra compact list view */
    .flashfolders-list .flashfolders-grid-item,
    .flashfolders-list .flashfolders-folder-card {
        grid-template-columns: 40px 1fr;
    }
    
    .flashfolders-list .flashfolders-grid-item img {
        width: 40px;
        height: 40px;
    }
    
    .flashfolders-grid-item-name {
        font-size: 10px;
    }
    
    /* More compact folder item */
    .flashfolders-folder-item {
        padding: var(--flashfolders-space-1) var(--flashfolders-space-2);
    }
    
    .flashfolders-folder-item .dashicons-category {
        font-size: 16px;
    }
    
    .flashfolders-folder-count {
        font-size: 10px;
        padding: 1px 6px;
    }
    
    /* Hide drag handle on small mobile */
    .flashfolders-folder-item > span[draggable] {
        display: none;
    }
    
    /* Details panel */
    .flashfolders-details {
        padding: var(--flashfolders-space-2);
        max-height: 250px;
    }
    
    .flashfolders-details-info-item {
        font-size: 11px;
    }
    
    /* Smaller details buttons */
    .flashfolders-details button {
        font-size: 12px;
        padding: var(--flashfolders-space-1) var(--flashfolders-space-2);
    }
    
    /* More compact usage list */
    .flashfolders-usage-item {
        padding: var(--flashfolders-space-2);
        font-size: 11px;
    }
    
    /* Load more button */
    .flashfolders-load-more-button {
        min-width: 150px !important;
        height: 36px !important;
        font-size: 13px !important;
    }
}

/* Landscape mobile optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .flashfolders-container {
        height: calc(100vh - 60px);
    }
    
    .flashfolders-sidebar {
        max-height: 120px;
    }
    
    .flashfolders-details {
        max-height: 200px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase tappable areas */
    .flashfolders-folder-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .flashfolders-grid-item {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(14, 202, 249, 0.2);
    }
    
    /* Remove hover effects on touch */
    .flashfolders-folder-item:hover,
    .flashfolders-grid-item:hover {
        transform: none;
    }
    
    /* Visual feedback on tap */
    .flashfolders-folder-item:active {
        background: var(--flashfolders-primary-100);
    }
    
    .flashfolders-grid-item:active {
        opacity: 0.8;
    }
    
    /* Larger buttons for touch */
    button,
    .flashfolders-folder-action-button {
        min-height: 40px;
        min-width: 40px;
    }
    
    /* Disable drag & drop on touch (too confusing) */
    [draggable="true"] {
        -webkit-user-drag: none;
        -webkit-touch-callout: none;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper icons */
    .dashicons,
    .flashfolders-icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .flashfolders-container,
    .flashfolders-sidebar,
    .flashfolders-main,
    .flashfolders-details,
    .flashfolders-folder-item,
    .flashfolders-grid-item,
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Dark mode support (bonus) */
@media (prefers-color-scheme: dark) {
    /* This is optional, but shows attention to detail */
    .flashfolders-container {
        background: #1a1a1a;
        border-color: #2c2c2c;
    }
    
    .flashfolders-sidebar,
    .flashfolders-main,
    .flashfolders-details {
        background: #0a0a0a;
        color: #e0e0e0;
    }
    
    .flashfolders-toolbar {
        background: #1a1a1a;
        border-color: #2c2c2c;
    }
    
    .flashfolders-grid-item,
    .flashfolders-folder-card {
        background: #1a1a1a;
        border-color: #2c2c2c;
        color: #e0e0e0;
    }
    
    .flashfolders-grid-item:hover {
        background: #2a2a2a;
    }
}

/* ========================================
   BREADCRUMB NAVIGATION
   Add this at the END of responsive.css
   ======================================== */

.flashfolders-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--flashfolders-space-2);
    padding: var(--flashfolders-space-3);
    background: var(--flashfolders-gray-50);
    border: 1px solid var(--flashfolders-gray-200);
    border-radius: var(--flashfolders-radius-md);
    margin-bottom: var(--flashfolders-space-3);
    flex-wrap: wrap;
}

.flashfolders-breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--flashfolders-space-1);
    font-size: 13px;
    color: var(--flashfolders-gray-700);
    flex-shrink: 0; /* Prevent shrinking */
}

.flashfolders-breadcrumb-item button {
    background: transparent;
    border: none;
    padding: var(--flashfolders-space-1) var(--flashfolders-space-2);
    border-radius: var(--flashfolders-radius-sm);
    cursor: pointer;
    color: var(--flashfolders-primary-600);
    font-weight: 500;
    transition: all var(--flashfolders-transition-fast);
    display: flex;
    align-items: center;
    gap: var(--flashfolders-space-1);
    white-space: nowrap; /* Prevent text wrapping */
}

.flashfolders-breadcrumb-item button:hover {
    background: var(--flashfolders-primary-50);
    color: var(--flashfolders-primary-700);
}

.flashfolders-breadcrumb-item.current {
    font-weight: 600;
    color: var(--flashfolders-gray-900);
    display: flex;
    align-items: center;
    gap: var(--flashfolders-space-1);
}

.flashfolders-breadcrumb-item.current span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px; /* Limit current folder length */
}

.flashfolders-breadcrumb-separator {
    color: var(--flashfolders-gray-400);
    font-size: 12px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

@media screen and (max-width: 768px) {
    .flashfolders-breadcrumb {
        padding: var(--flashfolders-space-2);
        gap: var(--flashfolders-space-1);
        margin-bottom: var(--flashfolders-space-2);
    }
    
    .flashfolders-breadcrumb-item {
        font-size: 12px;
    }
    
    .flashfolders-breadcrumb-item button {
        padding: var(--flashfolders-space-1);
        font-size: 12px;
    }
    
    .flashfolders-breadcrumb-item.current span {
        max-width: 120px; /* Even shorter on mobile */
    }
}