/* =============================================================================
   Mingo - responsive.css
   Responsive design, tablet fixes, modals, settings side menu
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Responsive Design
   ----------------------------------------------------------------------------- */

/* Tablet and Small Desktop */
@media (max-width: 1024px) {
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Devices */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    /* Hide desktop tabs, show mobile tabs */
    .tabs {
        display: none;
    }
    
    .mobile-tab-bar {
        display: block;
    }
    
    /* Hide desktop upload zone, show mobile version */
    .upload-zone:not(.upload-zone-mobile) {
        display: none;
    }
    
    /* IMPROVED HEADER LAYOUT */
    .header {
        /* Push header below status bar/notch area on mobile */
        margin-top: env(safe-area-inset-top, 0px);
        padding-top: 20px;
        padding-left: 20px;
        padding-right: 20px;
        padding-bottom: 30px;
        min-height: 100px;
        display: grid;
        grid-template-columns: 50px 1fr 80px;
        align-items: center;
        gap: 12px;
    }

    .user-avatar-compact {
        position: static;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        justify-self: start;
    }

    /* App Logo */
    .app-logo {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: transform 0.2s ease;
    }

    .app-logo img {
        width: 48px;
        height: 48px;
    }

    /* Updated Header Layout */
    .header {
        display: flex;
        align-items: center;
        gap: 16px;
        flex-wrap: nowrap;
    }

    .header-title {
        flex: 1;
        text-align: center;
    }

    .header-title {
        position: static;
        transform: none;
        text-align: center;
        justify-self: center;
    }

    .header-title h1 {
        font-size: 24px;
        margin: 0 0 2px 0;
        line-height: 1.2;
        font-weight: 600;
    }

    .header-title p {
        font-size: 14px;
        margin: 0;
        line-height: 1.2;
    }

    .sign-out-btn {
        position: static;
        padding: 6px 10px;
        font-size: 13px;
        flex-shrink: 0;
        justify-self: end;
    }
    
    /* Prevent horizontal overflow */
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Button and input adjustments */
    .btn, button, input, select, textarea {
        max-width: 100% !important;
        box-sizing: border-box !important;
        font-size: 14px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* SEARCH INPUTS */
    .search-input-wrapper {
        position: relative;
        width: 100%;
    }
    
    .search-input,
    .org-control {
        padding: 14px 16px 14px 44px;
        height: 48px;
        line-height: 1.4;
        font-size: 16px;
        box-sizing: border-box;
        width: 100%;
    }
    
    .search-input::placeholder,
    .org-control::placeholder,
    input::placeholder {
        font-size: 14px;
        opacity: 0.6;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .search-icon {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 2;
        pointer-events: none;
    }
    
    .org-control {
        padding-left: 16px;
        padding-right: 48px;
    }



    .distribution-type {
        font-weight: 500;
        color: var(--text-primary);
        font-size: 16px;
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .distribution-type::before {
        content: '';
        width: 12px;
        height: 12px;
        border-radius: 50%;
        display: inline-block;
        flex-shrink: 0;
    }

    .distribution-count {
        font-weight: 600;
        color: var(--text-primary);
        font-size: 16px;
        background: var(--surface-secondary);
        padding: 4px 8px;
        border-radius: 6px;
        min-width: 32px;
        text-align: center;
        flex-shrink: 0;
        margin-left: 12px;
    }

    .distribution-bar {
        height: 6px;
        background: #e5e7eb;
        border-radius: 3px;
        overflow: hidden;
        width: 100%;
        margin-top: 4px;
    }

    .distribution-fill {
        height: 100%;
        border-radius: 3px;
        transition: width 0.6s ease;
    }

    .distribution-fill.images { 
        background: linear-gradient(90deg, #3b82f6, #1d4ed8); 
    }
    .distribution-fill.videos { 
        background: linear-gradient(90deg, #10b981, #059669); 
    }
    .distribution-fill.documents { 
        background: linear-gradient(90deg, #f59e0b, #d97706); 
    }
    .distribution-fill.other { 
        background: linear-gradient(90deg, #8b5cf6, #7c3aed); 
    }

    .distribution-item:nth-child(1) .distribution-type::before { 
        background: linear-gradient(135deg, #3b82f6, #1d4ed8); 
    }
    .distribution-item:nth-child(2) .distribution-type::before { 
        background: linear-gradient(135deg, #10b981, #059669); 
    }
    .distribution-item:nth-child(3) .distribution-type::before { 
        background: linear-gradient(135deg, #f59e0b, #d97706); 
    }
    .distribution-item:nth-child(4) .distribution-type::before { 
        background: linear-gradient(135deg, #8b5cf6, #7c3aed); 
    }

    /* FIX TEXT ORIENTATION */
    * {
        writing-mode: initial !important;
        text-orientation: initial !important;
    }

    p, span, div, h1, h2, h3, h4, h5, h6, strong, small {
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
        direction: ltr !important;
    }
    
    /* Section spacing */
    .upload-mode-section,
    .organization-controls,
    .organization-section,
    .content-library-section,
    .file-list,
    .activity-section {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Form adjustments */
    .upload-mode-toggle {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .intent-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group-prefix {
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
    
    .input-group input {
        border-left: 1px solid var(--border-color);
        border-top: none;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }
    
    /* Layout adjustments */
    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .folder-selector,
    .search-filter {
        min-width: auto;
    }
    
    .file-card-actions {
        justify-content: center;
    }
    
    /* Stats and analytics */
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Analytics cards - show all 6 in 2-column grid on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    /* Add padding to prevent touching screen edges */
        padding: 0 12px;
        margin-bottom: 20px;
    }

    /* Ensure all stat cards are consistent size and spacing */
    .stat-card,
    .analytics-card {
        padding: 20px 16px;
        margin-bottom: 0;
        min-height: 100px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .distribution-label {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Bulk actions */
    .bulk-actions-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .bulk-actions-buttons {
        justify-content: center;
    }
    
    /* Approval buttons */
    .approval-action-btn {
        font-size: 11px !important;
        padding: 6px 8px !important;
        min-width: 80px !important;
        max-width: 48% !important;
    }
    
    /* Timeline comments adjustments */
    .timeline-comments-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .timeline-comment-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .comment-meta {
        align-items: flex-start;
    }
    
    .comment-meta strong,
    .comment-time {
        text-align: left;
    }
    
    .timeline-timestamp-btn {
        align-self: flex-start;
        width: fit-content;
    }
    
    /* Form row adjustments */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .video-timeline-modal .preview-content {
        width: 95vw;
    }
    
    /* Ensure proper bottom spacing */
    .file-list {
        margin-bottom: 40px;
    }
    
    #fileListContainer {
        padding-bottom: 40px;
    }
    
    .file-card:last-child {
        margin-bottom: 40px;
    }
    
    .files-grid {
        padding-bottom: 40px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .auth-content {
        padding: 1.5rem;
    }
    
    .tab {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

/* Large Desktop */
@media (min-width: 769px) {
    .upload-zone-mobile {
        display: none;
    }
}

/* TABLET AND DESKTOP LIST VIEW FIXES */
@media (min-width: 769px) {
    /* FIX SEARCH ICON ALIGNMENT - ALL DEVICES */
    .search-input-wrapper {
        position: relative;
        display: flex;
        align-items: center;
    }

    .search-input-wrapper .search-input {
        padding-left: 48px;
        height: 48px;
        display: flex;
        align-items: center;
    }

    .search-input-wrapper .search-icon {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 2;
        pointer-events: none;
        color: var(--text-muted);
    }

    /* ENSURE CONSISTENT SEARCH INPUT HEIGHT */
    .search-input,
    .org-control {
        height: 48px;
        display: flex;
        align-items: center;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* FIX MODAL SCROLL POSITION ISSUE */
.modal {
    overflow-y: auto;
    scroll-behavior: auto;
}

.modal-content {
    margin: 40px auto;
    position: relative;
}

/* PREVENT BODY SCROLL JUMP WHEN MODAL OPENS/CLOSES */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    top: 0;
    left: 0;
}

/* -----------------------------------------------------------------------------
   Modal Components
   ----------------------------------------------------------------------------- */

/* FIXED MODAL SYSTEM */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: auto;
    position: relative;
    /* PREVENT MOVEMENT */
    transform: none !important;
    transition: none !important;
    pointer-events: auto;
}

/* PREVENT BODY SCROLL AND POSITION JUMPING */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    left: 0;
    right: 0;
}

/* MOBILE AND LANDSCAPE FIXES */
@media (max-width: 768px) {
    .modal {
        padding: 10px;
        align-items: flex-start;
        padding-top: max(env(safe-area-inset-top, 0px), 20px);
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 20px);
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px);
        margin: 0;
        /* LOCK POSITION ON MOBILE */
        position: static;
        transform: none !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
    }
}

/* LANDSCAPE ORIENTATION FIXES */
@media (orientation: landscape) and (max-height: 600px) {
    .modal {
        align-items: flex-start;
        padding: 10px;
    }

    .modal-content {
        max-height: calc(100vh - 20px);
        margin: 0 auto;
        /* PREVENT ANY MOVEMENT IN LANDSCAPE */
        position: static !important;
        transform: none !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
    }
}

/* MODAL HEADER IMPROVEMENTS */
.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: linear-gradient(135deg, var(--ios-blue) 0%, #1557b0 100%);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    gap: 20px;
    /* PREVENT HEADER FROM MOVING */
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    flex: 1;
    min-width: 0;
    text-align: left;
    /* PREVENT TEXT FROM CAUSING MOVEMENT */
    hyphens: auto;
    -webkit-hyphens: auto;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.8;
    /* PREVENT BUTTON FROM MOVING */
    position: relative;
    z-index: 2;
}

.close-modal:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

/* MODAL BODY AND FOOTER */
.modal-body {
    padding: 20px;
    overflow-x: hidden;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    /* STICK FOOTER TO BOTTOM */
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 1;
}

/* MOBILE MODAL ADJUSTMENTS */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .modal-header {
        padding: 16px;
    }

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

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 16px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* -----------------------------------------------------------------------------
   Brand Share Page Scroll Fix
   ----------------------------------------------------------------------------- */
   
/* Mobile responsive styles for brand.html */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        margin: 0;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .content-section {
        margin: 10px;
        padding: 15px;
    }
    
    /* Make sure text and buttons are appropriately sized */
    body {
        font-size: 16px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* ============================================
   Settings Side Menu Navigation
   ============================================ */

   .settings-container {
    display: flex;
    gap: 0;
    height: calc(100vh - 200px);
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-sidebar {
    width: 250px;
    background: var(--surface-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    overflow-y: auto;
    flex-shrink: 0;
    align-self: stretch;
}

.settings-sidebar-group {
    margin-bottom: 1.5rem;
}

.settings-sidebar-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.settings-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
    white-space: nowrap;
}

.settings-sidebar-item:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

.settings-sidebar-item.active {
    background: var(--surface-color);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.settings-sidebar-item .pro-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 0.5rem;
}

.settings-sidebar-item .lock-icon {
    opacity: 0.5;
    font-size: 0.875rem;
}

.settings-sidebar-item .badge {
    background: var(--danger-color);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.settings-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    padding-bottom: 3rem;
}

.settings-section-content {
    display: none;
}

.settings-section-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-section-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.settings-section-header h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.75rem;
}

.settings-section-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Mobile Responsiveness - DROPDOWN VERSION */
.settings-mobile-selector {
    display: none;
}

@media (max-width: 768px) {
    .settings-container {
        flex-direction: column;
    }
    
    /* Hide desktop sidebar on mobile */
    .settings-sidebar {
        display: none;
    }
    
    /* Show mobile dropdown instead */
    .settings-mobile-selector {
        display: block;
        width: 100%;
        padding: 1rem;
        background: var(--surface-secondary);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .settings-mobile-selector select {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: var(--surface-color);
        color: var(--text-primary);
        font-weight: 500;
    }
    
    .settings-mobile-selector option[data-group] {
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.875rem;
    }
    
    .settings-main {
        max-height: none;
        padding: 1.5rem 1rem;
    }
    
    .settings-section-header h2 {
        font-size: 1.5rem;
    }
}