/**
 * Component CSS - All UI Component Styles
 * Stock Sentry Admin Dashboard
 */

/* Header with branding */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  height: 52px;
  width: auto;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.brand-text .subtitle {
  font-size: 0.75rem;
  color: var(--text-subdued);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.125rem;
}

/* Navigation */
.nav-container {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-subdued);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  transition: all 0.2s;
  font-size: 0.875rem;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav a:hover {
  color: var(--primary);
  background: rgba(0, 128, 96, 0.08);
}

.nav a.active {
  color: var(--primary);
  background: rgba(0, 128, 96, 0.12);
  font-weight: 600;
}

/* Navigation Dropdown Styles */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-subdued);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  transition: all 0.2s;
  font-size: 0.875rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-dropdown-trigger:hover {
  color: var(--primary);
  background: rgba(0, 128, 96, 0.08);
}

.nav-dropdown-trigger.active {
  color: var(--primary);
  background: rgba(0, 128, 96, 0.12);
  font-weight: 600;
}

.nav-dropdown-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.nav-dropdown-trigger.open .nav-dropdown-icon {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
  padding: 0.5rem 0;
}

.nav-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-dropdown-menu a:hover {
  background: rgba(0, 128, 96, 0.08);
  color: var(--primary);
}

.nav-dropdown-menu a.active {
  background: rgba(0, 128, 96, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.nav-dropdown-menu a .nav-icon {
  width: 18px;
  height: 18px;
  color: var(--text-subdued);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-subdued);
}

.theme-toggle:hover {
  background: rgba(0, 128, 96, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Dev Mode Toggle */
.dev-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-subdued);
  position: relative;
}

.dev-mode-toggle:hover {
  background: rgba(0, 128, 96, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.dev-mode-toggle.active {
  background: rgba(251, 188, 5, 0.15);
  border-color: #FFC453;
  color: #FFC453;
}

.dev-mode-toggle.active:hover {
  background: rgba(251, 188, 5, 0.25);
}

.dev-mode-toggle svg {
  width: 20px;
  height: 20px;
}

.dev-mode-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  background: #FFC453;
  border-radius: 50%;
  border: 2px solid var(--surface);
  display: none;
}

.dev-mode-toggle.active .dev-mode-badge {
  display: block;
}

/* User Section */
.user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--border);
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: all 0.2s;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

.user-menu-trigger:hover {
  background: rgba(0, 128, 96, 0.08);
  border-color: var(--border);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.chevron-down {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
  color: var(--text-subdued);
}

.user-menu-trigger.active .chevron-down {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
}

.user-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-header .user-name {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.user-dropdown-header .user-email {
  font-size: 0.75rem;
  color: var(--text-subdued);
}

.user-dropdown-menu {
  padding: 0.5rem 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.user-dropdown-item:hover {
  background: rgba(0, 128, 96, 0.08);
}

.user-dropdown-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-subdued);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

.user-dropdown-item.danger {
  color: var(--danger);
}

.user-dropdown-item.danger:hover {
  background: rgba(215, 44, 13, 0.08);
}

.user-dropdown-item.danger svg {
  color: var(--danger);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  flex: 1;
}

/* Card components */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 4px 15px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  height: 32px;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
  outline: none;
  position: relative;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}

.btn:active {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
}

.btn-secondary:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-sm {
  padding: 0px 7px;
  font-size: 14px;
  height: 24px;
  line-height: 22px;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

th {
  background: var(--background);
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--background);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-open { background: #D1ECF1; color: #0C5460; }
.badge-in-progress { background: #FFF3CD; color: #856404; }
.badge-resolved { background: #D4EDDA; color: #155724; }
.badge-closed { background: #E4E5E7; color: #383D41; }
.badge-critical { background: #F8D7DA; color: #721C24; }
.badge-error { background: #FFF3CD; color: #856404; }
.badge-success { background: #D4EDDA; color: #155724; }
.badge-warning { background: #FFF3CD; color: #856404; }
.badge-urgent { background: #F8D7DA; color: #721C24; }
.badge-high { background: #FFF3CD; color: #856404; }
.badge-normal { background: #D4EDDA; color: #155724; }
.badge-low { background: #E4E5E7; color: #383D41; }
.badge-staging { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.badge-production { background: rgba(16, 185, 129, 0.15); color: #059669; }
.badge-info { background: #D1ECF1; color: #0C5460; }

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  color: var(--text-subdued);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  font-weight: 500;
}

/* Modal Overlay - Ant Design Style */
.modal-mask {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: none;
}

.modal-mask.active {
  display: block;
  animation: antFadeIn 0.2s cubic-bezier(0.2, 0, 0.2, 1);
}

/* Modal Wrapper - Centers Content */
.modal-wrap {
  position: fixed;
  inset: 0;
  overflow: auto;
  outline: 0;
  z-index: 1001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

/* Modal Content Box */
.modal {
  position: relative;
  background: var(--surface);
  border-radius: 8px;
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
  animation: antZoomIn 0.2s cubic-bezier(0.08, 0.82, 0.17, 1);
  display: flex;
  flex-direction: column;
  margin: auto;
  align-self: flex-start;
  pointer-events: auto;
}

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

@keyframes antZoomIn {
  from {
    opacity: 0;
    transform: scale(0.2);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text);
  margin: 0;
  flex: 1;
  word-wrap: break-word;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-subdued);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
  border-radius: 4px;
  margin-left: 8px;
}

.close-btn:hover {
  color: var(--text);
  background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .close-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Modal Body */
.modal-body {
  padding: 24px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5714;
  overflow-y: auto;
  flex: 0 1 auto;
  word-wrap: break-word;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  text-align: right;
  width: 100%;
  box-sizing: border-box;
}

/* Form elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  line-height: 22px;
  height: 32px;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 123, 216, 0.2);
}

.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover {
  border-color: var(--primary);
}

.form-group small {
  display: block;
  font-size: 12px;
  color: var(--text-subdued);
  margin-top: 4px;
}

.form-group textarea {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-subdued);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Filters */
.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filters select:hover {
  border-color: var(--primary);
}

.filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.1);
}

/* Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem;
  margin-top: auto;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-subdued);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--text-subdued);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Environment Selector */
.env-selector {
  position: relative;
  margin-right: 0.75rem;
}

.env-selector-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
  font-family: inherit;
}

.env-selector-trigger:hover {
  border-color: var(--primary);
  background: rgba(0, 128, 96, 0.04);
}

.env-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.env-indicator.env-staging {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.env-indicator.env-production {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.env-label {
  font-weight: 500;
}

.env-selector-trigger .chevron-down {
  width: 14px;
  height: 14px;
  color: var(--text-subdued);
  transition: transform 0.2s;
}

.env-selector-trigger.open .chevron-down {
  transform: rotate(180deg);
}

.env-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
  padding: 0.5rem 0;
}

.env-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.env-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.env-option:hover {
  background: rgba(0, 128, 96, 0.08);
}

.env-option.active {
  background: rgba(0, 128, 96, 0.12);
}

.env-option-content {
  flex: 1;
  min-width: 0;
}

.env-option-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.env-option-url {
  display: block;
  font-size: 0.75rem;
  color: var(--text-subdued);
  margin-top: 0.125rem;
}

.env-option .check-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}

/* Environment Badge (for shops list) */
.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 9999px;
}

.env-badge.badge-staging {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.env-badge.badge-production {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}
