/* Mobile-First Responsive Design for Coaching Pages */

/* Mobile Base Styles - Chat focused layout */
@media (max-width: 768px) {
    
    /* Mobile navbar adjustments */
    .navbar {
        padding: 0.5rem 1rem !important;
        min-height: 56px;
    }
    
    .navbar-brand {
        font-size: 1.2rem !important;
    }
    
    .coach-nav-tabs {
        display: none !important; /* Hide desktop nav tabs on mobile */
    }
    
    .navbar .btn-outline-light {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Main container adjustments */
    .main-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }
    
    /* Hide sidebars on mobile by default - chat is primary focus */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        height: 100vh;
        background: white;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        border-right: 1px solid #e5e7eb;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .pipeline-panel {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        height: 100vh;
        background: white;
        z-index: 1000;
        transition: right 0.3s ease;
        overflow-y: auto;
        border-left: 1px solid #e5e7eb;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    }
    
    .pipeline-panel.show {
        right: 0;
    }
    
    /* Mobile overlay when sidebars are open */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .mobile-overlay.show {
        display: block;
    }
    
    /* Main content area - chat focused */
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100vh;
        border: none !important;
        margin: 0;
        padding: 0;
    }
    
    /* Mobile header with navigation */
    .content-header {
        background: white;
        border-bottom: 1px solid #e5e7eb;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 60px;
        flex-shrink: 0;
    }
    
    .content-title {
        font-size: 1.1rem !important;
        font-weight: 600;
        margin: 0;
        color: #1f2937;
    }
    
    .content-subtitle {
        display: none; /* Hide subtitle on mobile to save space */
    }
    
    /* Mobile navigation buttons */
    .mobile-nav-buttons {
        display: flex;
        gap: 0.5rem;
    }
    
    .mobile-nav-btn {
        background: white;
        border: 1px solid #8B5CF6;
        color: #8B5CF6;
        padding: 0.5rem;
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        min-width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-nav-btn:hover {
        background: #8B5CF6;
        color: white;
    }
    
    .mobile-nav-btn i {
        font-size: 1rem;
    }
    
    /* Hide desktop toggle button */
    #togglePanelBtn {
        display: none !important;
    }
    
    /* Chat container - full height */
    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        background: white;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        height: calc(100vh - 60px); /* Subtract header height */
    }
    
    /* Chat messages area */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        background: #f9fafb;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Chat input optimizations */
    .chat-input {
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 0.75rem 1rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
        flex-shrink: 0;
    }
    
    .chat-input .input-group {
        border-radius: 25px;
        border: 1px solid #d1d5db;
        background: white;
        overflow: hidden;
    }
    
    .chat-input .form-control {
        border: none;
        background: transparent;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        flex: 1;
    }
    
    .chat-input .form-control:focus {
        box-shadow: none;
        border: none;
        outline: none;
    }
    
    .chat-input .input-group-text {
        background: transparent;
        border: none;
        padding: 0.5rem 0.75rem;
    }
    
    .chat-input .btn {
        background: #8B5CF6;
        color: white;
        border: none;
        padding: 0.75rem 1rem;
        border-radius: 0;
    }
    
    /* Message bubbles optimization for mobile */
    .message {
        margin-bottom: 1rem;
        max-width: 100%;
    }
    
    .message.user .message-content {
        background: #8B5CF6;
        color: white;
        margin-left: 20%;
        border-radius: 18px 18px 4px 18px;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    .message.assistant .message-content {
        background: white;
        color: #374151;
        margin-right: 20%;
        border-radius: 18px 18px 18px 4px;
        padding: 0.75rem 1rem;
        border: 1px solid #e5e7eb;
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* File preview mobile optimization */
    .file-preview {
        background: #f3f4f6;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        margin-top: 0.5rem;
        padding: 0.75rem;
    }
    
    .file-preview-header {
        display: flex;
        justify-content: between;
        align-items: center;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        font-weight: 500;
        color: #6b7280;
    }
    
    /* Complete session button mobile styling */
    .complete-session-container {
        padding: 1rem;
        background: white;
        border-top: 1px solid #e5e7eb;
    }
    
    .complete-session-container .btn {
        border-radius: 12px;
        padding: 1rem;
        font-weight: 600;
        font-size: 1rem;
    }
    
    /* Sidebar content mobile optimization */
    .sidebar-header {
        padding: 1.5rem 1rem 1rem;
        background: #8B5CF6;
        color: white;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .sidebar-title {
        font-size: 1.25rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }
    
    .sidebar-subtitle {
        font-size: 0.875rem;
        opacity: 0.9;
        margin: 0;
    }
    
    .sidebar-section {
        padding: 1rem;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .section-header {
        font-size: 0.75rem;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.75rem;
    }
    
    /* Goal cards mobile styling */
    .goal-card {
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .goal-label {
        font-size: 0.875rem;
        color: #6b7280;
        margin-bottom: 0.25rem;
    }
    
    .goal-value {
        font-size: 1.125rem;
        font-weight: 600;
        color: #1f2937;
        margin-bottom: 0.5rem;
    }
    
    /* Action buttons mobile styling */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-btn {
        background: white;
        border: 1px solid #d1d5db;
        color: #374151;
        padding: 0.875rem 1rem;
        border-radius: 8px;
        font-size: 0.875rem;
        font-weight: 500;
        text-align: left;
        display: flex;
        align-items: center;
        transition: all 0.2s;
        cursor: pointer;
        width: 100%;
    }
    
    .action-btn:hover {
        background: #8B5CF6;
        color: white;
        border-color: #8B5CF6;
    }
    
    .action-btn i {
        color: #8B5CF6;
        transition: color 0.2s;
    }
    
    .action-btn:hover i {
        color: white;
    }
    
    /* Workflow items mobile styling */
    .workflow-item {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 0.75rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .workflow-item:hover {
        border-color: #8B5CF6;
        box-shadow: 0 2px 4px rgba(139, 92, 246, 0.1);
    }
    
    .workflow-item.completed {
        background: #f0fdf4;
        border-color: #22c55e;
    }
    
    .workflow-item.locked {
        background: #f9fafb;
        border-color: #d1d5db;
        opacity: 0.6;
        cursor: not-allowed;
    }
    
    .workflow-icon {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    .workflow-item.completed .workflow-icon {
        background: #22c55e;
        color: white;
    }
    
    .workflow-item.locked .workflow-icon {
        background: #9ca3af;
        color: white;
    }
    
    .workflow-content {
        flex: 1;
    }
    
    .workflow-title {
        font-weight: 600;
        color: #1f2937;
        font-size: 0.95rem;
        margin-bottom: 0.25rem;
    }
    
    .workflow-description {
        font-size: 0.8rem;
        color: #6b7280;
    }
    
    .workflow-btn {
        background: #8B5CF6;
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 6px;
        font-size: 0.8rem;
        font-weight: 500;
        flex-shrink: 0;
    }
    
    .workflow-btn.completed {
        background: #22c55e;
    }
    
    .workflow-btn.locked {
        background: #9ca3af;
        cursor: not-allowed;
    }
    
    /* Pipeline panel mobile optimization */
    .pipeline-header {
        padding: 1rem;
        background: white;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .pipeline-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .pipeline-stat-card {
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.75rem;
        text-align: center;
    }
    
    .stat-label {
        font-size: 0.75rem;
        color: #6b7280;
        margin-bottom: 0.25rem;
    }
    
    .stat-value {
        font-size: 1rem;
        font-weight: 600;
        color: #1f2937;
    }
    
    .pipeline-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
        background: #f3f4f6;
        padding: 0.25rem;
        border-radius: 8px;
    }
    
    .pipeline-nav-item {
        background: transparent;
        border: none;
        color: #6b7280;
        padding: 0.5rem 0.25rem;
        border-radius: 6px;
        font-size: 0.75rem;
        font-weight: 500;
        transition: all 0.2s;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        cursor: pointer;
    }
    
    .pipeline-nav-item.active {
        background: white;
        color: #8B5CF6;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .pipeline-nav-item i {
        font-size: 0.875rem;
    }
    
    /* Pipeline content mobile styling */
    .pipeline-content {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        background: #f9fafb;
    }
    
    /* Loading spinner */
    .loading-spinner {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        color: #6b7280;
        font-size: 0.875rem;
        gap: 0.5rem;
    }
    
    /* Safe area adjustments for iOS */
    @supports (padding: max(0px)) {
        .chat-input {
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        }
        
        .sidebar {
            padding-top: max(0px, env(safe-area-inset-top));
        }
        
        .pipeline-panel {
            padding-top: max(0px, env(safe-area-inset-top));
        }
    }
}

/* Tablet portrait adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 300px;
        position: relative;
        left: 0;
    }
    
    .pipeline-panel {
        width: 300px;
        position: relative;
        right: 0;
    }
    
    .main-content {
        flex: 1;
        min-width: 0;
    }
}

/* Ensure mobile viewport settings */
@viewport {
    width: device-width;
    initial-scale: 1;
}