/* ================================================
   Mobile-First Responsive Styles for Board Agents
   ================================================ */

/* ==========================================
   Base Mobile Styles (< 768px)
   ========================================== */

@media (max-width: 767px) {
  
  /* ==========================================
     Mobile Navigation & Header
     ========================================== */
  
  /* Mobile header bar */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: #1e1f25;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    height: 56px;
  }
  
  .mobile-header-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    text-align: center;
  }
  
  .mobile-menu-btn,
  .mobile-panel-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: background 0.2s;
  }
  
  .mobile-menu-btn:active,
  .mobile-panel-btn:active {
    background: rgba(255, 255, 255, 0.2);
  }
  
  /* Hide desktop sidebar on mobile */
  .board-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
  }
  
  .board-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
  }
  
  /* Hide right panel on mobile by default */
  .board-right-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 320px !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s ease !important;
    z-index: 1000 !important;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.3) !important;
  }
  
  .board-right-panel.mobile-open {
    transform: translateX(0) !important;
  }
  
  /* Show content when panel is open */
  .board-right-panel .right-panel-content {
    display: flex !important;
  }
  
  /* Hide right panel header on mobile */
  .right-panel-header {
    display: none !important;
  }
  
  /* Overlay for mobile sidebars */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
  }
  
  .mobile-overlay.active {
    display: block;
  }
  
  /* ==========================================
     Board Main Content
     ========================================== */
  
  .board-main {
    margin-top: 56px; /* Height of mobile header */
    padding-bottom: 80px; /* Space for floating input */
  }
  
  .chat-transcript {
    padding: 1rem 1rem 2rem;
  }
  
  /* ==========================================
     Chat Input - Mobile Positioning
     ========================================== */
  
  .chat-input-container {
    left: 0;
    right: 0;
    bottom: 1rem;
    padding: 0 1rem;
  }
  
  .chat-input-wrapper {
    max-width: 100%;
  }
  
  .chat-input-form textarea {
    font-size: 1rem;
    padding: 0.625rem 5.5rem 0.625rem 1rem;
  }
  
  .chat-input-actions {
    right: 0.625rem;
    bottom: 0.625rem;
  }
  
  .chat-input-form button {
    width: 36px;
    height: 36px;
  }
  
  /* ==========================================
     Experience Stream - Mobile Layout
     ========================================== */
  
  .experience-stream {
    padding: 1rem 0.75rem;
    gap: 1rem;
  }
  
  /* Journey Map - Simplified */
  .journey-map {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .journey-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .journey-header h2 {
    font-size: 1.125rem;
  }
  
  .journey-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .journey-track {
    gap: 0.75rem;
    padding-bottom: 0.5rem;
  }
  
  .journey-event {
    min-width: 200px;
    padding: 0.875rem 1rem;
  }
  
  /* Experience Main - Stack Vertically */
  .experience-main {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Agent Carousel */
  .agent-carousel {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .carousel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .carousel-controls {
    width: 100%;
    justify-content: center;
  }
  
  /* Agent Cards */
  .agent-card {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .agent-card__body {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }
  
  .agent-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  /* Brain Center - Move to top */
  .brain-center {
    order: -1;
    padding: 1rem 1.25rem;
    border-radius: 14px;
  }
  
  .brain-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .mini-graph {
    padding: 0.5rem;
    min-height: 100px;
  }
  
  .mini-graph svg {
    height: 100px;
  }
  
  .brain-kpis {
    gap: 0.5rem;
  }
  
  .brain-kpi {
    flex: 1 1 calc(50% - 0.25rem);
    padding: 0.625rem 0.75rem;
  }
  
  /* Storyboard */
  .storyboard {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .storyboard-track {
    gap: 0.75rem;
  }
  
  .storyboard-card {
    min-width: 180px;
    padding: 0.875rem 1rem;
  }
  
  /* ==========================================
     Chat Messages
     ========================================== */
  
  .chat-round {
    max-width: 100%;
  }
  
  .chat-message {
    padding: 1rem;
    border-radius: 12px;
  }
  
  .chat-message__meta {
    font-size: 0.8125rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .chat-content {
    font-size: 0.9375rem;
  }
  
  .chat-content pre {
    padding: 0.75rem;
    font-size: 0.8125rem;
    overflow-x: auto;
  }
  
  /* ==========================================
     Modal Windows - Full Screen
     ========================================== */
  
  .modal-overlay {
    padding: 0;
  }
  
  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }
  
  .modal-content-wide,
  .modal-content-preview,
  .modal-content-small {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .modal-header {
    padding: 1rem 1.25rem;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
  }
  
  .modal-body-split {
    grid-template-columns: 1fr;
  }
  
  .agents-list-panel {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    max-height: 40vh;
    overflow-y: auto;
  }
  
  .agent-detail-panel {
    padding: 1.25rem;
  }
  
  /* ==========================================
     Files Modal
     ========================================== */
  
  .upload-zone {
    padding: 2rem 1rem;
  }
  
  .upload-zone-icon {
    font-size: 2.5rem;
  }
  
  .documents-list {
    gap: 0.625rem;
  }
  
  .document-item {
    padding: 0.875rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .document-actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .document-actions button {
    flex: 1;
  }
  
  /* ==========================================
     Workflow Modals
     ========================================== */
  
  .workflow-cards-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }
  
  .workflow-card {
    padding: 1rem;
  }
  
  .workflow-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .workflow-actions {
    width: 100%;
  }
  
  .workflow-actions button {
    flex: 1;
  }
  
  /* Workflow Constructor */
  .workflow-steps-container {
    gap: 0.875rem;
  }
  
  .workflow-step-editor {
    padding: 1rem;
  }
  
  .workflow-step-agents {
    flex-direction: column;
  }
  
  .workflow-step-add-agent {
    flex-direction: column;
  }
  
  .workflow-agent-select {
    width: 100%;
  }
  
  /* ==========================================
     Personality Selector
     ========================================== */
  
  /* Keep personality selector in top right corner on mobile */
  .personality-selector {
    position: absolute !important;
    top: 1rem !important;
    right: 1rem !important;
    width: 140px !important;
    z-index: 50 !important;
  }
  
  .personalities-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }
  
  .personality-card {
    padding: 1rem;
  }
  
  /* ==========================================
     Right Panel Content
     ========================================== */
  
  .right-panel-content {
    padding: 1rem;
  }
  
  .workflow-status-panel {
    padding: 0.875rem;
  }
  
  .workflow-step-item {
    padding: 0.625rem;
  }
  
  .workflow-step-agents {
    gap: 0.375rem;
  }
  
  /* ==========================================
     Toast Notifications
     ========================================== */
  
  .toast-container {
    top: 70px; /* Below mobile header */
    left: 1rem;
    right: 1rem;
  }
  
  .toast {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  
  /* ==========================================
     Touch Optimizations
     ========================================== */
  
  /* Larger touch targets */
  button,
  .agent-toggle,
  .workflow-tab,
  .editor-tab {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Prevent text selection during touch */
  .board-sidebar,
  .board-right-panel,
  .modal-content {
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Allow text selection in content areas */
  .chat-content,
  .chat-message,
  textarea,
  input {
    -webkit-user-select: text;
    user-select: text;
  }
  
  /* ==========================================
     Typography Adjustments
     ========================================== */
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.125rem; }
  
  /* Reduce spacing on mobile */
  section { padding: 1rem 0; }
  .grid { gap: 1rem; }
}

/* ==========================================
   Tablet Styles (768px - 1024px)
   ========================================== */

@media (min-width: 768px) and (max-width: 1024px) {
  
  /* Sidebar - Narrower on tablets */
  .board-sidebar {
    width: 240px;
  }
  
  .chat-input-container {
    left: 240px;
  }
  
  /* Experience Main - Single column on tablet */
  .experience-main {
    grid-template-columns: 1fr;
  }
  
  .brain-center {
    order: -1;
  }
  
  /* Brain Stats - 2 columns */
  .brain-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Agent cards - 2 columns */
  .agent-card__body {
    grid-template-columns: 1fr;
  }
  
  /* Workflow cards - 2 columns */
  .workflow-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Modal - Not full screen */
  .modal-content {
    width: 95%;
    max-width: 95%;
    height: auto;
    max-height: 90vh;
    border-radius: 12px;
  }
}

/* ==========================================
   Small Mobile (< 375px)
   ========================================== */

@media (max-width: 374px) {
  
  .mobile-header {
    padding: 0.75rem 0.875rem;
  }
  
  .mobile-header-title {
    font-size: 0.9375rem;
  }
  
  .mobile-menu-btn,
  .mobile-panel-btn {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }
  
  .chat-input-form textarea {
    font-size: 0.9375rem;
  }
  
  .journey-event {
    min-width: 180px;
  }
  
  .storyboard-card {
    min-width: 160px;
  }
  
  .toast {
    padding: 0.875rem 1rem;
  }
}

/* ==========================================
   Landscape Mobile
   ========================================== */

@media (max-width: 767px) and (orientation: landscape) {
  
  .mobile-header {
    height: 48px;
    padding: 0.5rem 1rem;
  }
  
  .board-main {
    margin-top: 48px;
  }
  
  .experience-stream {
    padding: 0.75rem 0.5rem;
  }
  
  .journey-map,
  .agent-carousel,
  .brain-center,
  .storyboard {
    padding: 0.75rem;
  }
  
  .chat-transcript {
    padding: 0.75rem 1rem 1.5rem;
  }
}

/* ==========================================
   Accessibility Improvements
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  .board-sidebar,
  .board-right-panel,
  .mobile-overlay {
    transition: none;
  }
  
  .journey-event,
  .agent-card,
  .storyboard-card {
    animation: none;
  }
}

/* ==========================================
   Dark Mode Support (if needed)
   ========================================== */

@media (prefers-color-scheme: dark) {
  /* Add dark mode overrides here if needed */
}
