/* ============================================
   MOBILE RESPONSIVENESS FIXES
   Compass - Social Media Content Planning
   v2.2 - Safe version that doesn't break desktop
   ============================================ */

/* 
   IMPORTANT: This file only contains MOBILE-SPECIFIC fixes
   inside @media queries. It does NOT override desktop styles.
*/

/* ============================================
   MOBILE HEADER FIXES (768px and below)
   ============================================ */
@media (max-width: 768px) {
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        padding: 0.75rem 0;
    }
    
    .header-content {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .logo {
        font-size: 1.2rem !important;
    }
    
    .logo .powered-by {
        display: none;
    }
    
    .user-info {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .admin-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .admin-controls label {
        font-size: 0.85rem;
    }
    
    .client-selector {
        width: 100% !important;
        font-size: 0.9rem;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    
    .btn i {
        margin-right: 0.3rem;
    }
    
    /* Hide text on small screens, show icons only */
    .header-right .btn span.btn-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-right .btn {
        padding: 0.5rem;
        font-size: 1rem;
    }
    
    .header-right .btn i + span,
    .header-right .btn span:not(:only-child) {
        display: none;
    }
}

/* ============================================
   CALENDAR MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {
    .calendar-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .calendar-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-select {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
    }
    
    .month-nav {
        justify-content: center;
    }
    
    .calendar-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .calendar-day {
        min-height: 80px;
        padding: 0.3rem;
    }
    
    .day-number {
        font-size: 0.85rem;
    }
    
    .calendar-post {
        font-size: 0.6rem;
        padding: 0.25rem;
    }
    
    .post-title {
        font-size: 0.6rem;
    }
    
    .platform-icon {
        font-size: 0.5rem;
    }
}

/* ============================================
   MODAL MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        border-top: 1px solid var(--border-color);
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 0.75rem;
    }
}

/* ============================================
   STRATEGY DETAIL PANEL MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {
    .strategy-detail-panel {
        width: 100%;
        max-width: 100%;
    }
    
    .detail-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }
    
    .detail-content {
        padding: 1rem;
        padding-bottom: 100px; /* Space for bottom actions */
    }
    
    .detail-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        background: white;
        border-top: 1px solid var(--border-color);
        display: flex;
        gap: 0.5rem;
        z-index: 20;
    }
    
    .detail-actions .btn {
        flex: 1;
    }
}

/* ============================================
   STRATEGIES GRID MOBILE
   ============================================ */
@media (max-width: 768px) {
    .strategies-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .strategy-card {
        padding: 1rem;
    }
    
    .strategy-title {
        font-size: 1.1rem;
    }
    
    .strategy-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .strategy-stat-value {
        font-size: 1.2rem !important;
    }
    
    .strategy-actions {
        flex-wrap: wrap;
    }
    
    .strategy-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
    }
}

/* ============================================
   LIST VIEW MOBILE
   ============================================ */
@media (max-width: 768px) {
    .list-view-container {
        padding: 0.5rem;
    }
    
    .list-post {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .list-post-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .list-post-title {
        font-size: 1rem;
    }
    
    .list-post-content {
        font-size: 0.9rem;
    }
    
    .list-post-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .list-post-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }
    
    .list-post-actions .btn {
        flex: 1;
        font-size: 0.8rem;
    }
}

/* ============================================
   TASK ITEMS MOBILE
   ============================================ */
@media (max-width: 768px) {
    .task-item {
        padding: 1rem;
    }
    
    .task-title {
        font-size: 0.95rem;
    }
    
    .task-meta-row {
        flex-wrap: wrap;
    }
    
    .task-item .task-actions {
        flex-direction: column;
    }
    
    .task-item .task-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   IMPORT PAGE MOBILE
   ============================================ */
@media (max-width: 768px) {
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .preview-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .preview-item {
        padding: 0.75rem;
    }
    
    .preview-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .slides-list {
        font-size: 0.8rem;
    }
}

/* ============================================
   FORMS MOBILE - PREVENT iOS ZOOM
   ============================================ */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
    }
}

/* ============================================
   TOUCH-FRIENDLY BUTTONS (mobile only)
   ============================================ */
@media (max-width: 768px) {
    .btn, button {
        min-height: 44px; /* Apple's recommended touch target size */
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Make checkboxes easier to tap */
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
        cursor: pointer;
    }
    
    /* Make radio buttons easier to tap */
    input[type="radio"] {
        width: 20px;
        height: 20px;
        cursor: pointer;
    }
}

/* ============================================
   SAFE AREA INSETS (for notched phones)
   ============================================ */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .main-header {
            padding-top: max(0.75rem, env(safe-area-inset-top));
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
        
        .modal-content {
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
        
        .detail-actions {
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
    }
}

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

/* ============================================
   PRINT STYLES (hide unnecessary elements)
   ============================================ */
@media print {
    .main-header,
    .modal,
    .btn,
    .admin-controls,
    .strategy-detail-panel {
        display: none !important;
    }
    
    body {
        background: white;
    }
}
