@import "/./src/assets/scss/variables.scss";
@import "/./src/assets/scss/mixins.scss";
@import "/./src/assets/scss/breakpoints.scss";

// ===========================
// POPUP CONTAINER
// ===========================

.mobile-detail-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.popup-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.popup-container {
  position: relative;
  width: 100%;
  max-width: 100vw;
  max-height: 90vh;
  background: white;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  
  @include respond-to('md') {
    max-width: 500px;
    max-height: 80vh;
    border-radius: 20px;
    margin: 2rem;
  }
}

// ===========================
// DRAG HANDLE
// ===========================

.drag-handle {
  padding: 0.75rem;
  display: flex;
  justify-content: center;
  cursor: grab;
  
  &:active {
    cursor: grabbing;
  }
  
  .handle-bar {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    transition: background-color 0.2s ease;
    
    &:hover {
      background: #94a3b8;
    }
  }
}

// ===========================
// HEADER
// ===========================

.popup-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
  }
  
  .header-content {
    position: relative;
    z-index: 1;
  }
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  
  .header-title {
    flex: 1;
    margin-right: 1rem;
    
    .title {
      font-size: 1.5rem;
      font-weight: 700;
      margin: 0 0 0.5rem 0;
      line-height: 1.2;
      
      @include respond-below('sm') {
        font-size: 1.25rem;
      }
    }
    
    .subtitle {
      font-size: 0.875rem;
      opacity: 0.9;
      margin: 0;
      line-height: 1.4;
    }
  }
  
  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    
    .actions-toggle,
    .close-btn {
      color: white;
      background: rgba(255, 255, 255, 0.1);
      backdrop-filter: blur(10px);
      transition: all 0.2s ease;
      
      &:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.05);
      }
      
      &.active {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.1);
      }
    }
  }
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  
  .status-badge,
  .priority-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    
    .mat-icon {
      font-size: 0.875rem;
      width: 0.875rem;
      height: 0.875rem;
    }
  }
  
  .assignee-info,
  .due-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    opacity: 0.9;
    
    .mat-icon {
      font-size: 0.875rem;
      width: 0.875rem;
      height: 0.875rem;
    }
  }
}

.header-tags {
  .mat-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .tag-chip {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
  }
}

.actions-menu {
  position: absolute;
  top: 100%;
  right: 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 10;
  min-width: 200px;
  
  .action-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    color: #374151;
    border-radius: 0;
    
    &:hover {
      background: #f9fafb;
    }
    
    .mat-icon {
      margin-right: 0.5rem;
    }
  }
}

// ===========================
// CONTENT
// ===========================

.popup-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  -webkit-overflow-scrolling: touch;
  
  @include respond-below('sm') {
    padding: 1rem;
  }
}

.description-section {
  margin-bottom: 2rem;
  
  .section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
    
    .mat-icon {
      color: #6b7280;
    }
  }
  
  .description-text {
    color: #6b7280;
    line-height: 1.6;
    margin: 0;
    font-size: 0.875rem;
  }
}

// ===========================
// SECTIONS
// ===========================

.sections-container {
  .section-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    
    .tab-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1rem;
      border-radius: 12px;
      background: #f8fafc;
      color: #64748b;
      border: 1px solid #e2e8f0;
      transition: all 0.2s ease;
      white-space: nowrap;
      flex-shrink: 0;
      
      &:hover {
        background: #f1f5f9;
        border-color: #cbd5e1;
      }
      
      &.active {
        background: #3b82f6;
        color: white;
        border-color: #3b82f6;
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
      }
      
      .mat-icon {
        font-size: 1rem;
        width: 1rem;
        height: 1rem;
      }
    }
  }
}

.detail-section {
  margin-bottom: 2rem;
  
  &.hidden {
    display: none;
  }
  
  .section-header {
    margin-bottom: 1.5rem;
    
    &.clickable {
      cursor: pointer;
      padding: 0.75rem;
      border-radius: 8px;
      transition: background-color 0.2s ease;
      
      &:hover {
        background: #f8fafc;
      }
    }
    
    .section-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      
      h3 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 1.125rem;
        font-weight: 600;
        color: #374151;
        margin: 0;
        
        .mat-icon {
          color: #6b7280;
        }
      }
    }
    
    .collapse-icon {
      color: #6b7280;
      transition: transform 0.2s ease;
      
      &.collapsed {
        transform: rotate(-90deg);
      }
    }
  }
}

.section-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s ease;
  
  &.editable {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  .field-content {
    .field-header {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.75rem;
      
      .field-icon {
        color: #6b7280;
        font-size: 1rem;
        width: 1rem;
        height: 1rem;
      }
      
      .field-label {
        font-weight: 600;
        color: #374151;
        font-size: 0.875rem;
      }
      
      .required-indicator {
        color: #ef4444;
        font-weight: 700;
      }
    }
    
    .field-value {
      .read-value {
        font-size: 0.875rem;
        color: #6b7280;
        line-height: 1.5;
        
        .field-type-currency {
          font-weight: 600;
          color: #059669;
        }
        
        .field-type-status {
          display: inline-block;
          padding: 0.25rem 0.75rem;
          border-radius: 12px;
          background: #e2e8f0;
          color: #475569;
          font-weight: 600;
          font-size: 0.75rem;
          text-transform: uppercase;
        }
        
        .field-type-link {
          color: #3b82f6;
          text-decoration: underline;
          cursor: pointer;
          
          &:hover {
            color: #1d4ed8;
          }
        }
      }
      
      .edit-value {
        .field-input {
          width: 100%;
          
          .mat-form-field-wrapper {
            padding-bottom: 0;
          }
        }
      }
    }
  }
}

// ===========================
// FOOTER
// ===========================

.popup-footer {
  padding: 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 1rem;
  
  @include respond-below('sm') {
    padding: 1rem;
  }
  
  &.edit-footer {
    justify-content: space-between;
    
    .cancel-btn {
      color: #6b7280;
      
      &:hover {
        background: #f1f5f9;
      }
    }
    
    .save-btn {
      min-width: 120px;
    }
  }
  
  &.loading-footer {
    flex-direction: column;
    gap: 0.75rem;
    
    .loading-text {
      font-size: 0.875rem;
      color: #6b7280;
      text-align: center;
    }
  }
  
  .edit-btn {
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
    
    .mat-icon {
      margin-right: 0.5rem;
    }
  }
}

// ===========================
// RESPONSIVE ADJUSTMENTS
// ===========================

@include respond-below('sm') {
  .popup-container {
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
  }
  
  .popup-header {
    padding: 1rem;
    
    .header-main {
      .header-title {
        .title {
          font-size: 1.125rem;
        }
        
        .subtitle {
          font-size: 0.8125rem;
        }
      }
    }
    
    .header-meta {
      gap: 0.5rem;
      
      .status-badge,
      .priority-badge,
      .assignee-info,
      .due-date {
        font-size: 0.6875rem;
      }
    }
  }
  
  .field-item {
    padding: 0.75rem;
    
    .field-content {
      .field-header {
        .field-label {
          font-size: 0.8125rem;
        }
      }
      
      .field-value {
        .read-value {
          font-size: 0.8125rem;
        }
      }
    }
  }
}

// ===========================
// ANIMATIONS
// ===========================

@keyframes slideUpIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDownOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

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

// ===========================
// TOUCH IMPROVEMENTS
// ===========================

@media (hover: none) and (pointer: coarse) {
  .field-item {
    &:active {
      transform: scale(0.98);
    }
  }
  
  .tab-btn {
    &:active {
      transform: scale(0.95);
    }
  }
  
  .action-btn {
    &:active {
      background: #f3f4f6;
    }
  }
  
  .popup-footer {
    .edit-btn,
    .save-btn {
      &:active {
        transform: scale(0.98);
      }
    }
  }
}

// ===========================
// SCROLLBAR STYLING
// ===========================

.popup-content {
  &::-webkit-scrollbar {
    width: 8px;
  }
  
  &::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
  }
  
  &::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    
    &:hover {
      background: #94a3b8;
    }
  }
}

.section-tabs {
  &::-webkit-scrollbar {
    height: 4px;
  }
  
  &::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
  }
  
  &::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
  }
} 