/**
 * 🎨 Modern Plugin Form Styles
 * Enhanced form component with smooth animations
 */

/* ===== 🎯 Form Variables ===== */
:root {
  --form-primary: #0073aa;
  --form-primary-hover: #005a87;
  --form-primary-light: #e6f3ff;
  
  --form-success: #00a32a;
  --form-success-light: #e6f7e6;
  --form-error: #d63638;
  --form-error-light: #ffeaea;
  --form-warning: #dba617;
  --form-warning-light: #fff8e1;
  
  --form-gray-50: #f9fafb;
  --form-gray-100: #f3f4f6;
  --form-gray-200: #e5e7eb;
  --form-gray-300: #d1d5db;
  --form-gray-400: #9ca3af;
  --form-gray-500: #6b7280;
  --form-gray-600: #4b5563;
  --form-gray-700: #374151;
  --form-gray-800: #1f2937;
  --form-gray-900: #111827;
  
  --form-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --form-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --form-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --form-radius-sm: 0.375rem;
  --form-radius-md: 0.5rem;
  --form-radius-lg: 0.75rem;
  --form-radius-xl: 1rem;
  
  --form-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --form-transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 🎨 Plugin Form Container ===== */
.plugin-form {
  background: white;
  border: 1px solid var(--form-gray-200);
  border-radius: var(--form-radius-lg);
  margin-bottom: 1rem;
  transition: var(--form-transition-slow);
  position: relative;
  overflow: hidden;
  
  &:hover {
    border-color: var(--form-primary);
    box-shadow: var(--form-shadow-md);
    transform: translateY(-1px);
  }
  
  &.expanded {
    box-shadow: var(--form-shadow-lg);
    
    .plugin-header {
      background: linear-gradient(135deg, var(--form-primary-light) 0%, white 100%);
      border-bottom: 1px solid var(--form-gray-200);
    }
  }
  
  &.active {
    border-left: 4px solid var(--form-success);
  }
  
  &.inactive {
    border-left: 4px solid var(--form-gray-400);
    opacity: 0.8;
  }
}

/* ===== 📋 Plugin Header ===== */
.plugin-header {
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: var(--form-transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  
  @media (max-width: 640px) {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .plugin-info {
    flex: 1;
    min-width: 0;
    
    .plugin-name-section {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 0.5rem;
      
      @media (max-width: 640px) {
        flex-wrap: wrap;
        gap: 0.5rem;
      }
      
      .plugin-name {
        margin: 0;
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--form-gray-900);
        word-break: break-word;
        
        @media (max-width: 640px) {
          font-size: 1rem;
        }
      }
      
      .status-badge {
        padding: 0.25rem 0.75rem;
        border-radius: var(--form-radius-lg);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        
        &.active {
          background: var(--form-success-light);
          color: var(--form-success);
        }
        
        &.inactive {
          background: var(--form-gray-200);
          color: var(--form-gray-600);
        }
      }
    }
    
    .plugin-meta {
      display: flex;
      align-items: center;
      gap: 1rem;
      
      @media (max-width: 640px) {
        gap: 0.75rem;
      }
      
      .date-added {
        font-size: 0.875rem;
        color: var(--form-gray-500);
      }
      
      .plugin-link {
        display: flex;
        align-items: center;
        color: var(--form-primary);
        text-decoration: none;
        transition: var(--form-transition);
        padding: 0.25rem;
        border-radius: var(--form-radius-sm);
        
        &:hover {
          background: var(--form-primary-light);
          transform: scale(1.1);
        }
        
        svg {
          font-size: 1rem;
        }
      }
    }
  }
  
  .plugin-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    
    @media (max-width: 640px) {
      align-self: flex-end;
    }
    
    button {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 2.5rem;
      height: 2.5rem;
      border: none;
      border-radius: var(--form-radius-md);
      cursor: pointer;
      transition: var(--form-transition);
      
      svg {
        font-size: 1.25rem;
      }
      
      &:hover {
        transform: scale(1.05);
      }
    }
    
    .edit-btn {
      background: var(--form-primary-light);
      color: var(--form-primary);
      
      &:hover {
        background: var(--form-primary);
        color: white;
      }
      
      &.editing {
        background: var(--form-warning-light);
        color: var(--form-warning);
        
        &:hover {
          background: var(--form-warning);
          color: white;
        }
      }
    }
    
    .delete-btn {
      background: var(--form-error-light);
      color: var(--form-error);
      
      &:hover {
        background: var(--form-error);
        color: white;
      }
      

    }
    
    .expand-btn {
      background: var(--form-gray-100);
      color: var(--form-gray-600);
      
      &:hover {
        background: var(--form-gray-200);
        color: var(--form-gray-700);
      }
    }
  }
}

/* ===== 📝 Plugin Content ===== */
.plugin-content {
  padding: 1.5rem;
  border-top: 1px solid var(--form-gray-200);
  background: var(--form-gray-50);
  animation: slideDown 0.3s ease;
  
  @media (max-width: 640px) {
    padding: 1rem;
  }
}

/* ===== ✏️ Edit Section ===== */
.edit-section {
  .edit-form {
    label {
      display: block;
      margin-bottom: 0.5rem;
      font-weight: 600;
      color: var(--form-gray-700);
      font-size: 0.875rem;
    }
    
    .input-group {
      display: flex;
      gap: 0.5rem;
      margin-bottom: 1rem;
      
      @media (max-width: 640px) {
        flex-direction: column;
      }
      
      .plugin-input {
        flex: 1;
        padding: 0.75rem 1rem;
        border: 2px solid var(--form-gray-300);
        border-radius: var(--form-radius-md);
        font-size: 0.875rem;
        font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
        transition: var(--form-transition);
        
        &:focus {
          outline: none;
          border-color: var(--form-primary);
          box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
        }
        
        &.invalid {
          border-color: var(--form-error);
          box-shadow: 0 0 0 3px rgba(214, 54, 56, 0.1);
        }
        
        &::placeholder {
          color: var(--form-gray-400);
          font-family: inherit;
        }
      }
      
      .input-actions {
        display: flex;
        gap: 0.5rem;
        
        @media (max-width: 640px) {
          justify-content: flex-end;
        }
        
        button {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 2.5rem;
          height: 2.5rem;
          border: none;
          border-radius: var(--form-radius-md);
          cursor: pointer;
          transition: var(--form-transition);
          
          &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
          }
          
          svg {
            font-size: 1.25rem;
          }
        }
        
        .save-btn {
          background: var(--form-success);
          color: white;
          
          &:hover:not(:disabled) {
            background: #007a1f;
            transform: scale(1.05);
          }
        }
        
        .cancel-btn {
          background: var(--form-gray-300);
          color: var(--form-gray-700);
          
          &:hover {
            background: var(--form-gray-400);
            transform: scale(1.05);
          }
        }
      }
    }
    
    .validation-error {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem;
      background: var(--form-error-light);
      border: 1px solid var(--form-error);
      border-radius: var(--form-radius-md);
      color: var(--form-error);
      font-size: 0.875rem;
      margin-bottom: 1rem;
      
      svg {
        font-size: 1rem;
        flex-shrink: 0;
      }
    }
    
    .input-help {
      display: flex;
      align-items: flex-start;
      gap: 0.5rem;
      padding: 0.75rem;
      background: var(--form-primary-light);
      border: 1px solid var(--form-primary);
      border-radius: var(--form-radius-md);
      color: var(--form-primary);
      font-size: 0.875rem;
      line-height: 1.4;
      
      svg {
        font-size: 1rem;
        flex-shrink: 0;
        margin-top: 0.125rem;
      }
    }
  }
}

/* ===== 👁️ View Section ===== */
.view-section {
  .plugin-analytics {
    margin-bottom: 2rem;
    
    .analytics-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 1rem;
      
      h4 {
        margin: 0;
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--form-gray-900);
      }
      
      .analytics-actions {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        
        .data-stale {
          font-size: 0.75rem;
          color: var(--form-warning);
          font-weight: 500;
        }
        
        .refresh-btn {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 2rem;
          height: 2rem;
          border: none;
          border-radius: var(--form-radius-md);
          background: var(--form-primary-light);
          color: var(--form-primary);
          cursor: pointer;
          transition: var(--form-transition);
          
          &:hover:not(:disabled) {
            background: var(--form-primary);
            color: white;
            transform: scale(1.05);
          }
          
          &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
          }
          
          svg {
            font-size: 1rem;
            
            &.spinning {
              animation: spin 1s linear infinite;
            }
          }
        }
      }
    }
    
    .loading-state {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.75rem;
      padding: 2rem;
      color: var(--form-gray-600);
      
      svg {
        font-size: 1.5rem;
        animation: spin 1s linear infinite;
      }
    }
    
    .error-state {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.75rem;
      padding: 2rem;
      background: var(--form-error-light);
      border: 1px solid var(--form-error);
      border-radius: var(--form-radius-md);
      color: var(--form-error);
      
      svg {
        font-size: 1.5rem;
      }
      
      .retry-btn {
        padding: 0.5rem 1rem;
        background: var(--form-error);
        color: white;
        border: none;
        border-radius: var(--form-radius-sm);
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 600;
        transition: var(--form-transition);
        
        &:hover {
          background: #b32d2e;
        }
      }
    }
    
    .no-data-state {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.75rem;
      padding: 2rem;
      color: var(--form-gray-500);
      background: var(--form-gray-50);
      border: 1px dashed var(--form-gray-300);
      border-radius: var(--form-radius-md);
      
      svg {
        font-size: 1.5rem;
      }
    }
    
    .analytics-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 1rem;
      
      @media (max-width: 768px) {
        grid-template-columns: 1fr;
      }
      
      .analytics-card {
        background: white;
        border: 1px solid var(--form-gray-200);
        border-radius: var(--form-radius-lg);
        padding: 1rem;
        transition: var(--form-transition);
        
        &:hover {
          border-color: var(--form-primary);
          box-shadow: var(--form-shadow-md);
          transform: translateY(-1px);
        }
        
        &.primary {
          border-color: var(--form-primary);
          background: linear-gradient(135deg, var(--form-primary-light) 0%, white 100%);
          
          .card-icon {
            color: var(--form-primary);
          }
          
          .card-value {
            color: var(--form-primary);
            font-weight: 700;
          }
        }
        
        .card-header {
          display: flex;
          align-items: center;
          gap: 0.5rem;
          margin-bottom: 0.75rem;
          
          .card-icon {
            font-size: 1.25rem;
            color: var(--form-gray-600);
          }
          
          .card-title {
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--form-gray-700);
            flex: 1;
          }
          
          .data-source-badge {
            font-size: 0.625rem;
            font-weight: 700;
            padding: 0.125rem 0.375rem;
            border-radius: var(--form-radius-sm);
            text-transform: uppercase;
            letter-spacing: 0.025em;
            
            &.estimated {
              background: var(--form-warning-light);
              color: var(--form-warning);
              border: 1px solid var(--form-warning);
            }
            
            &.official {
              background: var(--form-success-light);
              color: var(--form-success);
              border: 1px solid var(--form-success);
            }
          }
        }
        
        .card-value {
          font-size: 1.5rem;
          font-weight: 700;
          color: var(--form-gray-900);
          margin-bottom: 0.25rem;
        }
        
        .card-meta {
          font-size: 0.75rem;
          color: var(--form-gray-500);
        }
        
        .card-content {
          .rating-display {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            
            .stars {
              display: flex;
              gap: 0.125rem;
              
              .star {
                font-size: 1rem;
                
                &.filled {
                  color: #fbbf24;
                }
                
                &.half {
                  color: #fbbf24;
                }
                
                &.empty {
                  color: var(--form-gray-300);
                }
              }
            }
            
            .rating-text {
              font-size: 0.875rem;
              color: var(--form-gray-600);
            }
          }
          
          .support-stats {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            
            .support-stat {
              display: flex;
              justify-content: space-between;
              align-items: center;
              
              .stat-label {
                font-size: 0.875rem;
                color: var(--form-gray-600);
              }
              
              .stat-value {
                font-size: 0.875rem;
                font-weight: 600;
                color: var(--form-gray-900);
              }
            }
          }
          
          .no-data {
            font-size: 0.875rem;
            color: var(--form-gray-500);
            font-style: italic;
          }
        }
      }
    }
  }
  
  .plugin-details {
    margin-bottom: 1.5rem;
    
    .detail-row {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 0.75rem 0;
      border-bottom: 1px solid var(--form-gray-200);
      
      @media (max-width: 640px) {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
      }
      
      &:last-child {
        border-bottom: none;
      }
      
      .detail-label {
        font-weight: 600;
        color: var(--form-gray-700);
        min-width: 120px;
        font-size: 0.875rem;
        
        @media (max-width: 640px) {
          min-width: auto;
        }
      }
      
      .detail-value {
        color: var(--form-gray-900);
        font-size: 0.875rem;
        
        &:is(code) {
          background: var(--form-gray-800);
          color: #e6e6e6;
          padding: 0.25rem 0.5rem;
          border-radius: var(--form-radius-sm);
          font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
          font-size: 0.75rem;
        }
      }
      
      .detail-link {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: var(--form-primary);
        text-decoration: none;
        font-size: 0.875rem;
        transition: var(--form-transition);
        
        &:hover {
          text-decoration: underline;
        }
        
        svg {
          font-size: 1rem;
        }
      }
      
      .status-indicator {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        
        .status-dot {
          width: 8px;
          height: 8px;
          border-radius: 50%;
          animation: pulse 2s infinite;
        }
        
        &.active {
          color: var(--form-success);
          
          .status-dot {
            background: var(--form-success);
          }
        }
        
        &.inactive {
          color: var(--form-gray-500);
          
          .status-dot {
            background: var(--form-gray-500);
          }
        }
      }
    }
  }
  
  .plugin-actions-expanded {
    display: flex;
    gap: 0.75rem;
    
    @media (max-width: 640px) {
      flex-direction: column;
    }
    
    .action-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1.5rem;
      border: none;
      border-radius: var(--form-radius-md);
      font-weight: 600;
      font-size: 0.875rem;
      cursor: pointer;
      transition: var(--form-transition);
      
      svg {
        font-size: 1rem;
      }
      
      &:hover {
        transform: translateY(-1px);
        box-shadow: var(--form-shadow-md);
      }
      
      &.edit {
        background: var(--form-primary);
        color: white;
        
        &:hover {
          background: var(--form-primary-hover);
        }
      }
      
      &.view {
        background: var(--form-gray-200);
        color: var(--form-gray-700);
        
        &:hover {
          background: var(--form-gray-300);
        }
      }
      
      &.refresh {
        background: var(--form-primary-light);
        color: var(--form-primary);
        
        &:hover:not(:disabled) {
          background: var(--form-primary);
          color: white;
        }
        
        &:disabled {
          opacity: 0.5;
          cursor: not-allowed;
          transform: none;
        }
      }
    }
  }
}



/* ===== 🎬 Animations ===== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 500px;
  }
}

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===== 📱 Mobile Optimizations ===== */
@media (max-width: 480px) {
  .plugin-form {
    margin-bottom: 0.75rem;
  }
  
  .plugin-header {
    padding: 0.5rem 0.75rem;
    
    .plugin-info .plugin-name-section .plugin-name {
      font-size: 0.875rem;
    }
    
    .plugin-actions button {
      width: 2rem;
      height: 2rem;
      
      svg {
        font-size: 1rem;
      }
    }
  }
  
  .plugin-content {
    padding: 0.75rem;
  }
}

/* ===== 🌙 Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --form-gray-50: #1f2937;
    --form-gray-100: #374151;
    --form-gray-200: #4b5563;
    --form-gray-300: #6b7280;
    --form-gray-900: #f9fafb;
    --form-gray-800: #e5e7eb;
    --form-gray-700: #d1d5db;
  }
}/* =====
 📊 Enhanced Active Installation Styles ===== */
.install-value-container {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.install-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--form-gray-900);
}

.install-range {
  font-size: 0.875rem;
  color: var(--form-gray-600);
  font-weight: 500;
  background: var(--form-gray-100);
  padding: 0.125rem 0.375rem;
  border-radius: var(--form-radius-sm);
}

.install-estimate-indicator {
  font-size: 1.25rem;
  color: var(--form-warning);
  font-weight: 600;
  margin-left: -0.25rem;
}

.install-details {
  font-size: 0.75rem;
  color: var(--form-gray-600);
  margin-bottom: 0.25rem;
  font-style: italic;
}

.install-note {
  font-size: 0.75rem;
  color: var(--form-warning);
  background: var(--form-warning-light);
  padding: 0.25rem 0.5rem;
  border-radius: var(--form-radius-sm);
  border-left: 3px solid var(--form-warning);
}

.install-estimate-note {
  font-size: 0.75rem;
  color: var(--form-gray-500);
  font-style: italic;
}

.install-official-note {
  font-size: 0.75rem;
  color: var(--form-success);
  font-weight: 500;
}

/* ===== 🏷️ Enhanced Data Source Badges ===== */
.data-source-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: var(--form-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  
  &.high {
    background: var(--form-success-light);
    color: var(--form-success);
    border: 1px solid var(--form-success);
  }
  
  &.medium {
    background: var(--form-primary-light);
    color: var(--form-primary);
    border: 1px solid var(--form-primary);
  }
  
  &.low, &.estimated {
    background: var(--form-warning-light);
    color: var(--form-warning);
    border: 1px solid var(--form-warning);
  }
  
  &.official {
    background: var(--form-success-light);
    color: var(--form-success);
    border: 1px solid var(--form-success);
  }
}

/* ===== 📱 Responsive Enhancements ===== */
@media (max-width: 768px) {
  .install-value-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .install-number {
    font-size: 1.25rem;
  }
  
  .install-range {
    font-size: 0.75rem;
  }
}/* ===
== 📊 Original WordPress.org Value Display ===== */
.install-original {
  font-size: 0.75rem;
  color: var(--form-gray-500);
  font-weight: 500;
  background: var(--form-gray-50);
  padding: 0.125rem 0.375rem;
  border-radius: var(--form-radius-sm);
  border: 1px solid var(--form-gray-200);
  margin-left: 0.5rem;
}

/* ===== 📊 Support Stats Improvements ===== */
.support-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.support-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--form-gray-100);
  
  &:last-child {
    border-bottom: none;
  }
}

.stat-label {
  font-size: 0.75rem;
  color: var(--form-gray-600);
  font-weight: 500;
}

.stat-value {
  font-size: 0.875rem;
  color: var(--form-gray-900);
  font-weight: 600;
}

/* ===== 📱 Mobile Responsive Updates ===== */
@media (max-width: 768px) {
  .install-original {
    font-size: 0.625rem;
    margin-left: 0.25rem;
    margin-top: 0.25rem;
    display: block;
  }
  
  .support-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
  }
}