/* ============================================================================
   Extension UI Styles - Updated with Upgrade Support
   ============================================================================ */

/* Extension Modal */
.extension-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.extension-modal.active {
  display: flex;
}

.extension-modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 1200px;
  height: 90%;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Extension Buttons */
.extension-install,
.extension-uninstall,
.extension-upgrade,
.extension-cleanup {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 0;
  box-sizing: border-box;
}

.extension-install {
  background: #4CAF50 !important;
  color: white !important;
}

.extension-install:hover {
  background: #45a049;
}

.extension-uninstall {
  background: #f44336 !important;
  color: white !important;
}

.extension-uninstall:hover {
  background: #da190b;
}

.extension-upgrade {
  background: #FF9800 !important;
  color: white !important;
  font-weight: 600;
  animation: pulse-orange 2s ease-in-out infinite;
}

.extension-upgrade:hover {
  background: #F57C00;
  animation: none;
}

@keyframes pulse-orange {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 152, 0, 0);
  }
}

.extension-install:disabled,
.extension-uninstall:disabled,
.extension-upgrade:disabled,
.extension-cleanup:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

/* Extension Card */
.extension-box {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  transition: all 0.3s ease;
  height: auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.extension-box:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.extension-box .header {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.extension-box .cover {
  width: 64px;
  height: 64px;
  background: #f5f5f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}

.extension-box .cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.extension-box .detail {
  flex: 1;
  min-width: 0;
}

.extension-box .name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.extension-box .author {
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
}

.extension-box .other {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: #999;
}

.extension-box .version {
  background: #e3f2fd;
  color: #1976d2;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.extension-box .description {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 15px;
  flex: 1;
}

.extension-box .category-tag {
  font-size: 12px;
  color: #1976d2;
  background: #e3f2fd;
  padding: 4px 10px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: inline-block;
}

.extension-box .button {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Status Icons */
.installed-icon {
  color: #4CAF50;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
}

.upgrade-icon {
  color: #FF9800;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  animation: bounce 1s ease-in-out infinite;
}

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

/* Extension List */
.extension-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 20px;
  list-style: none;
  margin: 0;
}

/* Category Sidebar */
.extension-categories {
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
}

.extension-categories ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.extension-categories li {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  font-size: 14px;
  color: #555;
}

.extension-categories li:hover {
  background: #e8eaf6;
  color: #333;
}

.extension-categories li.active {
  background: #e3f2fd;
  border-left-color: #1976d2;
  color: #1976d2;
  font-weight: 500;
}

.extension-categories li.hr {
  height: 1px;
  background: #e0e0e0;
  padding: 0;
  margin: 8px 0;
  cursor: default;
}

.extension-categories li.hr:hover {
  background: #e0e0e0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 24px;
  color: #666;
  margin-bottom: 10px;
}

.empty-state p {
  font-size: 16px;
  color: #999;
}

/* Search Bar */
.extension-search {
  padding: 12px 20px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.3s ease;
}

.extension-search:focus {
  outline: none;
  border-color: #1976d2;
}

/* Modal Header */
.extension-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.extension-modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: #333;
}

.extension-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.extension-modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
  .extension-list {
    grid-template-columns: 1fr;
  }
  
  .extension-modal-content {
    width: 95%;
    height: 95%;
  }
}

/* Loading Spinner */
.extension-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

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

/* Tags */
.extension-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.extension-tag {
  background: #f5f5f5;
  color: #666;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

/* Version Comparison */
.version-upgrade {
  background: #fff3e0;
  color: #f57c00;
  border: 1px solid #ffe0b2;
}

/* Device Compatibility Badge */
.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff5722;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
}
/* Cleanup button colours — sizing comes from the shared rule above */
.extension-cleanup {
  background: #9E9E9E !important;  /* grey — secondary action */
  color: white !important;
  border: none;
}
.extension-cleanup:hover:not(:disabled) { background: #757575 !important; }

/* Force button colours — overrides any global `background: transparent` rules */
button.extension-upgrade { background-color: #FF9800 !important; color: white !important; }
button.extension-cleanup { background-color: turquoise !important; color: white !important; }
button.extension-install { background-color: #4CAF50 !important; color: white !important; }
button.extension-uninstall { background-color: #f44336 !important; color: white !important; }

/* More Info bar — sits at the bottom of each extension card */
.more-info-bar {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #e0e0e0;
}

.extension-moreinfo {
  background: none;
  border: 1px solid #90CAF9;
  border-radius: 4px;
  color: #1976d2;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

.extension-moreinfo:hover {
  background: #e3f2fd;
  color: #0d47a1;
}

/* ── Extension Info Modal ── */
.ext-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.ext-info-dialog {
  background: #fff;
  border-radius: 12px;
  max-width: 620px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.ext-info-header {
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.ext-info-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #1a1a2e;
}

.ext-info-header h2 i {
  color: #4A90E2;
  margin-right: 8px;
}

.ext-info-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #666;
  line-height: 1;
  padding: 0 4px;
}

.ext-info-close:hover {
  color: #333;
}

/* Rich content area — supports HTML: headings, lists, code, etc. */
.ext-info-content {
  padding: 24px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.75;
  color: #333;
}

.ext-info-content h1,
.ext-info-content h2,
.ext-info-content h3,
.ext-info-content h4 {
  margin: 1em 0 0.5em;
  color: #1a1a2e;
  line-height: 1.3;
}

.ext-info-content h1 { font-size: 1.3rem; }
.ext-info-content h2 { font-size: 1.15rem; }
.ext-info-content h3 { font-size: 1.05rem; }
.ext-info-content h4 { font-size: 0.95rem; }

.ext-info-content p {
  margin: 0.5em 0;
}

.ext-info-content ul,
.ext-info-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.ext-info-content li {
  margin: 0.3em 0;
}

.ext-info-content code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.85em;
  color: #d63384;
}

.ext-info-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 14px 18px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.75em 0;
  line-height: 1.5;
}

.ext-info-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.85em;
}

.ext-info-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
  font-size: 0.85em;
}

.ext-info-content th,
.ext-info-content td {
  border: 1px solid #e0e0e0;
  padding: 8px 12px;
  text-align: left;
}

.ext-info-content th {
  background: #f8f9fa;
  font-weight: 600;
}

.ext-info-content a {
  color: #1976d2;
  text-decoration: none;
}

.ext-info-content a:hover {
  text-decoration: underline;
}

.ext-info-content blockquote {
  border-left: 3px solid #90CAF9;
  margin: 0.75em 0;
  padding: 8px 16px;
  background: #f8f9fa;
  color: #555;
}

.ext-info-content hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 1em 0;
}
.pricing-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: capitalize;
}
.pricing-free {
  background: #e8f5e9;
  color: #2e7d32;
}
.pricing-paid {
  background: #fff3e0;
  color: #e65100;
}
