/* =============================================
   ROOF SELECTION DESKTOP & TABLET UX ENHANCEMENTS
   Bringing mobile's effective UX to larger screens
   ============================================= */

:root {
  --desktop-primary-blue: #3b82f6;
  --desktop-primary-green: #10b981;
  --desktop-touch-target: 48px;
  --desktop-spacing-lg: 32px;
  --desktop-spacing-md: 24px;
  --desktop-spacing-sm: 16px;
}

/* =============================================
   1. ENHANCED MAP VISIBILITY - LARGER MAP
   Mobile uses fullscreen, desktop uses optimized split
   ============================================= */
@media (min-width: 769px) {
  /* Increase map size by reducing sidebar width */
  .roof-selection-layout {
    display: grid;
    grid-template-columns: 1fr 380px; /* Map takes more space */
    gap: var(--desktop-spacing-md);
    min-height: 600px;
  }

  /* Map takes priority */
  .map-section {
    position: relative;
    min-height: 600px;
  }

  .compact-map-container {
    position: relative;
    height: 100%;
    min-height: 600px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  }

  #roof-map {
    height: 100% !important;
    min-height: 600px !important;
  }
}

/* Larger screens get even more map space */
@media (min-width: 1200px) {
  .roof-selection-layout {
    grid-template-columns: 1fr 420px;
    gap: var(--desktop-spacing-lg);
  }

  .compact-map-container {
    min-height: 680px;
  }

  #roof-map {
    min-height: 680px !important;
  }
}

/* =============================================
   2. CROSSHAIR TARGETING SYSTEM FOR DESKTOP
   Mobile has this, desktop needs it too
   ============================================= */
@media (min-width: 769px) {
  /* Enable crosshair on desktop */
  .map-crosshair {
    display: block !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1000;
  }

  .compact-map-container {
    position: relative;
  }

  /* Add subtle instruction overlay on map */
  .compact-map-container::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: radial-gradient(
      circle at center,
      rgba(59,130,246,0.05) 0%,
      rgba(59,130,246,0.02) 40%,
      transparent 70%
    );
  }

  /* Pulse effect when no roof selected */
  .compact-map-container:not(.roof-selected) .crosshair-pulse {
    animation: crosshair-pulse-desktop 3s ease-in-out infinite;
  }

  @keyframes crosshair-pulse-desktop {
    0%, 100% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 0.5;
    }
    50% {
      transform: translate(-50%, -50%) scale(1.3);
      opacity: 0.8;
    }
  }
}

/* =============================================
   3. ENHANCED FLOATING MAP CONTROLS
   Larger touch targets, better positioning
   ============================================= */
@media (min-width: 769px) {
  .compact-map-controls {
    position: absolute !important;
    bottom: var(--desktop-spacing-md) !important;
    right: var(--desktop-spacing-md) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    z-index: 1001 !important;
  }

  .compact-map-controls .btn {
    width: var(--desktop-touch-target) !important;
    height: var(--desktop-touch-target) !important;
    min-width: var(--desktop-touch-target) !important;
    min-height: var(--desktop-touch-target) !important;
    background: rgba(255,255,255,0.98) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: none !important;
    border-radius: 24px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15),
                0 0 0 1px rgba(0,0,0,0.05) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
  }

  .compact-map-controls .btn i {
    font-size: 18px !important;
    color: #374151 !important;
    margin: 0 !important;
  }

  .compact-map-controls .btn:hover {
    background: white !important;
    transform: scale(1.08) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2),
                0 0 0 1px rgba(0,0,0,0.08) !important;
  }

  .compact-map-controls .btn:active {
    transform: scale(0.96) !important;
  }

  .compact-map-controls .btn:focus-visible {
    outline: 3px solid var(--desktop-primary-blue);
    outline-offset: 2px;
  }
}

/* =============================================
   4. PROMINENT ANALYZE BUTTON (PRIMARY CTA)
   Mobile has FAB, desktop needs equal prominence
   ============================================= */
@media (min-width: 769px) {
  /* Restructure controls sidebar for better CTA visibility */
  .controls-section {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 16px;
    padding: var(--desktop-spacing-md);
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  }

  .controls-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: var(--desktop-spacing-md);
  }

  /* Push action buttons to bottom */
  .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    padding-top: var(--desktop-spacing-md);
    border-top: 1px solid rgba(0,0,0,0.08);
  }

  /* Make analyze button SUPER prominent */
  #analyze-roof-btn {
    position: relative;
    width: 100% !important;
    min-height: 64px !important;
    background: linear-gradient(135deg, var(--desktop-primary-green) 0%, #059669 100%) !important;
    border: none !important;
    border-radius: 16px !important;
    color: white !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    box-shadow: 0 8px 24px rgba(16,185,129,0.35),
                0 0 0 4px rgba(16,185,129,0.1) !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    overflow: hidden;
  }

  /* Animated shine effect */
  #analyze-roof-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255,255,255,0.3),
      transparent
    );
    transition: left 0.5s;
  }

  #analyze-roof-btn:not([disabled]):hover::before {
    left: 100%;
  }

  #analyze-roof-btn:not([disabled]):hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(16,185,129,0.4),
                0 0 0 4px rgba(16,185,129,0.15) !important;
  }

  #analyze-roof-btn:not([disabled]):active {
    transform: translateY(0);
  }

  #analyze-roof-btn i {
    font-size: 22px !important;
  }

  /* Disabled state - keep visible but muted */
  #analyze-roof-btn[disabled] {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    cursor: not-allowed !important;
    opacity: 0.7;
  }

  /* Pulsing animation when ready */
  #analyze-roof-btn:not([disabled]) {
    animation: cta-pulse 2s ease-in-out infinite;
  }

  @keyframes cta-pulse {
    0%, 100% {
      box-shadow: 0 8px 24px rgba(16,185,129,0.35),
                  0 0 0 4px rgba(16,185,129,0.1);
    }
    50% {
      box-shadow: 0 8px 24px rgba(16,185,129,0.5),
                  0 0 0 6px rgba(16,185,129,0.15);
    }
  }

  /* Secondary button styling */
  #manual-entry-btn {
    width: 100%;
    min-height: 48px;
    background: white !important;
    border: 2px solid rgba(0,0,0,0.1) !important;
    border-radius: 12px !important;
    color: #374151 !important;
    font-weight: 600 !important;
    font-size: 15px;
    transition: all 0.2s;
  }

  #manual-entry-btn:hover {
    background: #f9fafb !important;
    border-color: rgba(0,0,0,0.2) !important;
    transform: translateY(-1px);
  }

  #manual-entry-btn:active {
    transform: translateY(0);
  }
}

/* =============================================
   5. ENHANCED INSTRUCTION DESIGN
   Clear, visual, actionable
   ============================================= */
@media (min-width: 769px) {
  .roof-instruction {
    display: flex;
    align-items: flex-start;
    gap: var(--desktop-spacing-sm);
    padding: var(--desktop-spacing-md);
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(59,130,246,0.04));
    border: 2px solid rgba(59,130,246,0.2);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
  }

  /* Animated gradient background */
  .roof-instruction::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
      circle,
      rgba(59,130,246,0.1) 0%,
      transparent 70%
    );
    animation: gradient-rotate 8s linear infinite;
  }

  @keyframes gradient-rotate {
    to {
      transform: rotate(360deg);
    }
  }

  .instruction-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--desktop-primary-blue), #2563eb);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(59,130,246,0.3);
    position: relative;
    z-index: 1;
    animation: icon-bounce 2s ease-in-out infinite;
  }

  @keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
  }

  .instruction-icon i {
    font-size: 26px;
    color: white;
  }

  .instruction-text {
    flex: 1;
    position: relative;
    z-index: 1;
  }

  .instruction-text h6 {
    font-size: 18px;
    font-weight: 800;
    color: #1f2937;
    margin: 0 0 6px 0;
    line-height: 1.3;
    letter-spacing: 0.5px;
  }

  .instruction-text p {
    font-size: 15px;
    color: #4b5563;
    margin: 0;
    line-height: 1.5;
  }
}

/* =============================================
   6. INFO BADGES - MORE VISUAL
   ============================================= */
@media (min-width: 769px) {
  .selection-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
  }

  .info-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s;
  }

  .info-item:hover {
    background: #f9fafb;
    border-color: rgba(0,0,0,0.12);
    transform: translateX(4px);
  }

  .info-item:hover::before {
    opacity: 1;
  }

  .info-item i {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59,130,246,0.1);
    border-radius: 8px;
  }

  .info-item span {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    line-height: 1.4;
  }
}

/* =============================================
   7. HEADER IMPROVEMENTS
   ============================================= */
@media (min-width: 769px) {
  .roof-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--desktop-spacing-md);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    margin-bottom: var(--desktop-spacing-md);
    border: 1px solid rgba(0,0,0,0.06);
  }

  .roof-selection-header h6 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .roof-selection-header h6 i {
    color: var(--desktop-primary-blue);
    font-size: 22px;
  }

  .roof-selection-header small {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
  }

  .roof-selection-header .badge {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--desktop-primary-blue), #2563eb);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(59,130,246,0.25);
  }
}

/* =============================================
   8. VISUAL FEEDBACK ANIMATIONS
   Bring mobile's success feedback to desktop
   ============================================= */
@media (min-width: 769px) {
  /* Success overlay works on desktop too */
  .roof-success-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    display: none;
  }

  .roof-success-overlay.active {
    display: block;
  }

  /* Tutorial overlay for first-time users */
  .roof-tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    animation: fadeIn 0.3s ease-out;
  }

  .roof-tutorial-overlay.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 40px;
  }

  .tutorial-content {
    background: white;
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
    animation: slideUp 0.4s ease-out;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

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

/* =============================================
   9. TOOLTIP HINTS ON HOVER
   Desktop advantage: we have hover states
   ============================================= */
@media (min-width: 769px) and (hover: hover) {
  /* Add helpful tooltips */
  [title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(0,0,0,0.9);
    color: white;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    z-index: 10000;
    pointer-events: none;
    animation: fadeIn 0.2s ease-out;
  }

  [title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.9);
    z-index: 10000;
    pointer-events: none;
  }

  /* Prevent tooltip on buttons that already have visible text */
  .btn:hover::after,
  .btn:hover::before {
    display: none;
  }
}

/* =============================================
   10. LOADING & TRANSITION STATES
   ============================================= */
@media (min-width: 769px) {
  /* Smooth transitions between states */
  .roof-selection-compact {
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  }

  .roof-selection-compact.loading {
    opacity: 0.6;
    pointer-events: none;
  }

  /* Analyzing state */
  .roof-selection-compact.analyzing .controls-section {
    position: relative;
  }

  .roof-selection-compact.analyzing .controls-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .roof-selection-compact.analyzing .controls-section::after {
    content: 'Analisi in corso...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
  }
}

/* =============================================
   11. RESPONSIVE BREAKPOINTS
   ============================================= */

/* Tablet portrait */
@media (min-width: 769px) and (max-width: 1024px) {
  .roof-selection-layout {
    grid-template-columns: 1fr 340px;
    gap: var(--desktop-spacing-sm);
  }

  .controls-section {
    padding: var(--desktop-spacing-sm);
  }

  .controls-content {
    gap: var(--desktop-spacing-sm);
  }

  .roof-instruction {
    padding: var(--desktop-spacing-sm);
  }

  .instruction-text h6 {
    font-size: 16px;
  }

  .instruction-text p {
    font-size: 14px;
  }
}

/* Large desktop */
@media (min-width: 1400px) {
  .roof-selection-layout {
    grid-template-columns: 1fr 460px;
  }

  .compact-map-container {
    min-height: 720px;
  }

  #roof-map {
    min-height: 720px !important;
  }

  #analyze-roof-btn {
    min-height: 72px !important;
    font-size: 20px !important;
  }
}

/* =============================================
   12. ACCESSIBILITY ENHANCEMENTS
   ============================================= */
@media (min-width: 769px) {
  /* Focus states */
  *:focus-visible {
    outline: 3px solid var(--desktop-primary-blue);
    outline-offset: 2px;
  }

  /* Keyboard navigation indicators */
  .compact-map-controls .btn:focus-visible,
  #analyze-roof-btn:focus-visible,
  #manual-entry-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(59,130,246,0.3),
                0 4px 16px rgba(0,0,0,0.15) !important;
  }

  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .roof-instruction {
      border-width: 3px;
    }

    .info-item {
      border-width: 2px;
    }

    #analyze-roof-btn {
      border: 3px solid #047857 !important;
    }
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* =============================================
   13. PRINT STYLES
   ============================================= */
@media print {
  .roof-selection-compact {
    break-inside: avoid;
  }

  .compact-map-controls,
  .action-buttons {
    display: none !important;
  }

  .map-crosshair {
    display: none !important;
  }
}

/* =============================================
   14. DARK MODE SUPPORT (Future-proof)
   ============================================= */
@media (min-width: 769px) and (prefers-color-scheme: dark) {
  .roof-selection-header {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-color: rgba(255,255,255,0.1);
  }

  .roof-selection-header h6 {
    color: #f9fafb;
  }

  .roof-selection-header small {
    color: #d1d5db;
  }

  .controls-section {
    background: #1f2937;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
  }

  .roof-instruction {
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.08));
    border-color: rgba(59,130,246,0.3);
  }

  .instruction-text h6 {
    color: #f9fafb;
  }

  .instruction-text p {
    color: #d1d5db;
  }

  .info-item {
    background: #111827;
    border-color: rgba(255,255,255,0.1);
  }

  .info-item:hover {
    background: #1f2937;
    border-color: rgba(255,255,255,0.15);
  }

  .info-item span {
    color: #e5e7eb;
  }

  #manual-entry-btn {
    background: #111827 !important;
    border-color: rgba(255,255,255,0.2) !important;
    color: #f9fafb !important;
  }

  #manual-entry-btn:hover {
    background: #1f2937 !important;
    border-color: rgba(255,255,255,0.3) !important;
  }
}
