/* ============================================
   RITVERKTYG (DRAWING TOOL) - MOBIL
   Matchar referens: Ritverktyg-demo.html
   ============================================ */

@media (max-width: 768px) {

  /* ======================================
     1. DRAWINGS LIST PAGE (Mina ritningar)
     ====================================== */

  .drawings-page .container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .drawings-page .container > .d-flex:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 16px 16px 12px !important;
    margin-bottom: 0 !important;
    background: white !important;
    border-bottom: 1px solid #E2E8F0 !important;
  }

  .drawings-page .container > .d-flex:first-child h1 {
    font-size: 24px !important;
    font-weight: 800 !important;
    color: #0F172A !important;
    margin-bottom: 4px !important;
  }

  .drawings-page .container > .d-flex:first-child p {
    font-size: 13px !important;
    color: #64748B !important;
  }

  .drawings-page .container > .d-flex:first-child .btn-primary,
  .drawings-page a[href="/drawing"].btn-primary {
    width: 100% !important;
    margin-top: 12px !important;
    padding: 16px !important;
    background: #00D9A3 !important;
    border-color: #00D9A3 !important;
    border-radius: 14px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    min-height: 54px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
  }

  .drawings-page .row.g-4 {
    margin: 0 !important;
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  .drawings-page .row.g-4 > div[class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .drawings-page .drawing-card {
    border-radius: 16px !important;
    border: 2px solid #E2E8F0 !important;
    overflow: hidden !important;
    box-shadow: none !important;
  }

  .drawings-page .drawing-card:active {
    border-color: #00D9A3 !important;
  }

  .drawings-page .drawing-card .card-img-top,
  .drawings-page .drawing-card .drawing-thumbnail {
    height: 120px !important;
    border-radius: 0 !important;
  }

  .drawings-page .drawing-card .card-body {
    padding: 14px 16px !important;
  }

  .drawings-page .drawing-card .card-title {
    font-size: 15px !important;
    font-weight: 800 !important;
    color: #0F172A !important;
    margin-bottom: 6px !important;
  }

  .drawings-page .drawing-card .badge {
    background: rgba(0, 217, 163, 0.1) !important;
    color: #00A57D !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    padding: 2px 8px !important;
    border-radius: 6px !important;
  }

  .drawings-page {
    background: #F7F9FC !important;
    min-height: 100% !important;
  }

  /* ======================================
     2. DRAWING TOOL — MAIN LAYOUT
     ====================================== */

  .drawing-main {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 70px) !important;
    overflow: hidden !important;
    background: #1a6ba0 !important;
    position: relative !important;
  }

  /* ======================================
     3. DRAWING HEADER (top bar)
     ====================================== */

  .drawing-header {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 8px !important;
    background: white !important;
    border-bottom: 1px solid #E2E8F0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    z-index: 10 !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
  }

  .drawing-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .drawing-back-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-shrink: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    font-size: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #334155 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .drawing-title-input {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0F172A !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    min-width: 0 !important;
    flex: 1 !important;
    height: 32px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .drawing-header-center {
    display: none !important;
  }

  .drawing-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    width: auto !important;
  }

  .drawing-header-actions #clear-btn,
  .drawing-header-actions #export-btn,
  .drawing-header-actions #undo-btn,
  .drawing-header-actions #redo-btn {
    display: none !important;
  }

  .drawing-btn-primary {
    height: 30px !important;
    border-radius: 8px !important;
    padding: 0 14px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #6366F1, #8B5CF6) !important;
    color: white !important;
    border: none !important;
    line-height: 30px !important;
    white-space: nowrap !important;
  }

  .drawing-btn-primary i {
    display: none !important;
  }

  /* Share button: kompakt ikon-knapp */
  .drawing-btn-secondary {
    height: 30px !important;
    width: 30px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    gap: 0 !important;
    justify-content: center !important;
  }

  .drawing-exercise-link,
  .drawing-link-btn,
  .drawing-belongs-to-tag {
    display: none !important;
  }

  /* ======================================
     4. WORKSPACE — FULL SCREEN CANVAS
     ====================================== */

  .drawing-workspace {
    flex: 1 !important;
    display: flex !important;
    position: relative !important;
    overflow: hidden !important;
    background: #1a6ba0 !important;
  }

  /* Hide original sidebars completely */
  .drawing-sidebar {
    display: none !important;
  }

  .drawing-canvas-container {
    display: block !important;
    position: relative !important;
    overflow: visible !important;
    background: #1a6ba0 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #drawing-canvas {
    touch-action: none !important;
  }

  /* ======================================
     5. ZOOM CONTROLS (floating right)
     ====================================== */

  .drawing-zoom-controls {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    bottom: auto !important;
    background: rgba(50, 50, 50, 0.7) !important;
    border-radius: 12px !important;
    padding: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    z-index: 10 !important;
  }

  .drawing-zoom-btn {
    width: 32px !important;
    height: 32px !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .drawing-zoom-display {
    font-size: 12px !important;
    font-weight: 700 !important;
    text-align: center !important;
    color: white !important;
    padding: 4px !important;
  }

  /* ======================================
     6. FAB (Floating Action Button)
     ====================================== */

  .mobile-fab {
    position: fixed !important;
    bottom: 24px !important;
    right: 16px !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #6366F1, #8B5CF6) !important;
    color: white !important;
    font-size: 22px !important;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4) !important;
    z-index: 20 !important;
    border: 3px solid #0F172A !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
  }

  .mobile-fab:active {
    transform: scale(0.92) !important;
  }

  /* ======================================
     7. UNDO / REDO floating buttons
     ====================================== */

  .mobile-fab-undo,
  .mobile-fab-redo {
    position: fixed !important;
    bottom: 32px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: white !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    z-index: 20 !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    color: #334155 !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .mobile-fab-undo { left: 16px !important; }
  .mobile-fab-redo { left: 62px !important; }

  .mobile-fab-undo:active,
  .mobile-fab-redo:active {
    background: #F1F5F9 !important;
    transform: scale(0.92) !important;
  }

  /* ======================================
     8. FAB POPUP (tool/figure/color grid)
     ====================================== */

  .mobile-fab-popup {
    position: fixed !important;
    bottom: 90px !important;
    right: 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: 360px !important;
    background: white !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18) !important;
    padding: 16px !important;
    z-index: 25 !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
    transform: scale(0.8) !important;
    opacity: 0 !important;
    transition: transform 0.2s, opacity 0.2s !important;
    pointer-events: none !important;
  }

  .mobile-fab-popup.open {
    transform: scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* ======================================
     9. POPUP SECTIONS
     ====================================== */

  .mobile-fab-section {
    margin-bottom: 14px !important;
  }

  .mobile-fab-section:last-child {
    margin-bottom: 0 !important;
  }

  .mobile-fab-section-title {
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #64748B !important;
    margin-bottom: 8px !important;
    font-weight: 700 !important;
  }

  .mobile-fab-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Tool & figure buttons in popup */
  .mobile-fab-grid .fab-item {
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
    background: #F7F9FC !important;
    border: 2px solid transparent !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 18px !important;
    color: #334155 !important;
    padding: 0 !important;
    -webkit-tap-highlight-color: transparent !important;
    position: relative !important;
  }

  .mobile-fab-grid .fab-item.active {
    border-color: #00D9A3 !important;
    background: rgba(0, 217, 163, 0.1) !important;
  }

  .mobile-fab-grid .fab-item:active {
    transform: scale(0.92) !important;
  }

  .mobile-fab-grid .fab-item img {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain !important;
  }

  .mobile-fab-grid .fab-item .fab-label {
    font-size: 8px !important;
    font-weight: 600 !important;
    color: #64748B !important;
    margin-top: 2px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  /* Color circles in popup */
  .mobile-fab-grid .fab-color {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: 3px solid transparent !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .mobile-fab-grid .fab-color.active {
    border-color: white !important;
    box-shadow: 0 0 0 2px #00D9A3 !important;
    transform: scale(1.15) !important;
  }

  /* Court type pills in popup */
  .mobile-fab-grid .fab-court {
    flex: 1 !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    border: 2px solid #E2E8F0 !important;
    background: white !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #64748B !important;
    text-align: center !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .mobile-fab-grid .fab-court.active {
    border-color: #00D9A3 !important;
    background: rgba(0, 217, 163, 0.1) !important;
    color: #00A57D !important;
  }

  /* Exercise link in FAB popup */
  .mobile-fab-grid .fab-exercise-link {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 14px !important;
    border-radius: 12px !important;
    border: 1.5px solid #e2e8f0 !important;
    background: white !important;
    font-size: 13px !important;
    color: #475569 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 260px !important;
  }
  .mobile-fab-grid .fab-exercise-link.active {
    border-color: #00D9A3 !important;
    background: rgba(0, 217, 163, 0.08) !important;
    color: #00A57D !important;
  }
  .mobile-fab-grid .fab-exercise-link .fab-label {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .mobile-fab-grid .fab-exercise-unlink {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: 1.5px solid #fecaca !important;
    background: #fff5f5 !important;
    color: #ef4444 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ======================================
     10. FAB BACKDROP (transparent click catcher)
     ====================================== */

  .mobile-fab-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 22 !important;
    background: transparent !important;
  }

  /* ======================================
     ZOOM — move up to avoid FAB collision
     ====================================== */

  .drawing-zoom-controls {
    bottom: 100px !important;
    right: 12px !important;
  }

  /* ======================================
     7. DRAWING MODALS
     ====================================== */

  .drawing-modal {
    z-index: 1070 !important;
  }

  .drawing-modal-content {
    width: calc(100vw - 16px) !important;
    max-height: 85vh !important;
    border-radius: 16px !important;
    margin: auto !important;
  }

  .drawing-modal-body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 16px !important;
  }


  /* ======================================
     9. EMPTY/ERROR STATES
     ====================================== */

  .drawings-page .alert {
    margin: 16px !important;
    border-radius: 14px !important;
  }
}
