/* CSS Variables for design tokens */
:root {
  --bg-color: #070709;
  --panel-bg: rgba(15, 15, 20, 0.85);
  --panel-border: rgba(255, 255, 255, 0.07);
  --text-primary: #ffffff;
  --text-secondary: #a0a0ab;
  --text-muted: #6b6b76;
  
  /* Brand Accent Colors */
  --sti-pink: #ff0055;
  --sti-pink-glow: rgba(255, 0, 85, 0.45);
  --sti-pink-hover: #ff2277;
  --subaru-blue: #0044ff;
  --subaru-blue-glow: rgba(0, 68, 255, 0.3);
  
  /* Status Colors */
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  
  /* Fonts */
  --font-logo: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  /* Subtle high-tech carbon texture pattern */
  background-image: 
    linear-gradient(45deg, #0d0d11 25%, transparent 25%), 
    linear-gradient(-45deg, #0d0d11 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #0d0d11 75%), 
    linear-gradient(-45deg, transparent 75%, #0d0d11 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  padding-top: 70px; /* Space for fixed header */
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #09090b;
}
::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--sti-pink);
  box-shadow: 0 0 8px var(--sti-pink-glow);
}

/* Header Design */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(10, 10, 12, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-logo {
  display: flex;
  align-items: center;
  font-family: var(--font-logo);
}

.logo-myrat {
  font-size: 26px;
  font-weight: 800;
  font-style: italic;
  color: var(--sti-pink);
  text-shadow: 0 0 12px var(--sti-pink-glow);
  letter-spacing: -0.5px;
  margin-right: 4px;
}

.logo-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 1.8s infinite;
}

.status-dot.offline {
  background-color: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

/* Layout container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 60px 20px;
}

/* Banner Styling */
.banner-section {
  width: 100%;
  margin-bottom: 25px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-border);
  position: relative;
}

.banner-wrapper {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Inventory Main Card */
.inventory-card {
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Control Bar (Filters and Search) */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 25px;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
}

.search-group {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 15px;
  color: var(--text-muted);
  font-size: 15px;
}

.search-group input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 15px 12px 42px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition-fast);
}

.search-group input:focus {
  outline: none;
  border-color: var(--sti-pink);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.15);
  background: rgba(0, 0, 0, 0.6);
}

.filter-group {
  gap: 10px;
}

.filter-group label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.filter-group select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 11px 35px 11px 15px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  min-width: 160px;
  transition: var(--transition-fast);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--sti-pink);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.15);
}

.admin-controls {
  margin-left: auto;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--sti-pink);
  color: white;
  box-shadow: 0 4px 15px var(--sti-pink-glow);
}

.btn-primary:hover {
  background: var(--sti-pink-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 0, 85, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
  background: #10c98f;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 15px var(--danger-glow);
}

.btn-danger:hover {
  background: #ff4d4d;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}

/* Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.inventory-table th {
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 16px 20px;
  border-bottom: 2px solid var(--panel-border);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.inventory-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.inventory-table tbody tr {
  transition: var(--transition-fast);
  background: rgba(255, 255, 255, 0.01);
}

.inventory-table tbody tr:hover {
  background: rgba(255, 0, 85, 0.03);
  /* Subaru Blue left glow border for hovered rows */
  box-shadow: inset 4px 0 0 var(--subaru-blue);
}

/* Row styling based on state */
/* Clickable name column for public info */
.clickable-name {
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.clickable-name:hover {
  color: var(--sti-pink);
  text-shadow: 0 0 8px var(--sti-pink-glow);
}

.info-indicator {
  font-size: 11px;
  color: var(--sti-pink);
  opacity: 0.8;
}

.spec-cell {
  color: var(--text-secondary);
  font-family: monospace;
}

.quantity-cell {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.sold-out-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

/* Sold Out Rows 置底变灰 */
.tr-sold-out {
  opacity: 0.45;
  background: rgba(0, 0, 0, 0.25) !important;
}

.tr-sold-out:hover {
  opacity: 0.8;
  background: rgba(255, 0, 85, 0.01) !important;
}

.tr-sold-out .quantity-cell {
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 0;
  color: var(--text-muted);
  gap: 15px;
}

.empty-icon {
  font-size: 40px;
  color: var(--text-muted);
}

/* Modal Overlay & Animations */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: rgba(18, 18, 22, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
  /* Glowing border representing STI/MyRat */
  border-color: rgba(255, 0, 85, 0.3);
  box-shadow: 0 10px 40px rgba(255, 0, 85, 0.15), 0 20px 50px rgba(0, 0, 0, 0.6);
}

.product-form-container {
  max-width: 700px;
}

.info-display-container {
  max-width: 650px;
}

.modal-header {
  padding: 18px 25px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-logo);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  color: var(--sti-pink);
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Form Styles */
.form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 18px;
}

.col-6 { flex: 0 0 calc(50% - 7.5px); }
.col-4 { flex: 0 0 calc(33.333% - 10px); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-group.col-6, .form-group.col-4 {
  margin-bottom: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.required {
  color: var(--sti-pink);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--sti-pink);
  box-shadow: 0 0 8px var(--sti-pink-glow);
}

.form-group textarea {
  resize: vertical;
}

.form-divider {
  font-family: var(--font-logo);
  font-size: 13px;
  font-weight: 700;
  color: var(--sti-pink);
  margin: 25px 0 15px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 0, 85, 0.2);
}

/* Checkbox Toggle Switch */
.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.checkbox-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #27272a;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: var(--sti-pink);
  box-shadow: 0 0 8px var(--sti-pink-glow);
}

.toggle-switch input:focus + .slider {
  box-shadow: 0 0 1px var(--sti-pink);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  margin-top: 10px;
}

.login-tip {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.footer-right {
  display: flex;
  gap: 12px;
}

/* AI Auto Layout Engine Styling */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 15px;
}

.ai-sparkle {
  font-size: 32px;
  color: var(--sti-pink);
  text-shadow: 0 0 15px var(--sti-pink-glow);
  animation: float 2s ease-in-out infinite, color-rotate 6s linear infinite;
}

@keyframes float {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(15deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes color-rotate {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

.ai-loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.ai-loading-bar {
  width: 150px;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.ai-loading-progress {
  width: 30%;
  height: 100%;
  background: var(--sti-pink);
  border-radius: 4px;
  box-shadow: 0 0 8px var(--sti-pink-glow);
  animation: slide-load 1.2s infinite ease-in-out;
}

@keyframes slide-load {
  0% { margin-left: -30%; width: 30%; }
  50% { width: 50%; }
  100% { margin-left: 100%; width: 30%; }
}

.ai-brand {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-logo);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pink-icon {
  color: var(--sti-pink);
  text-shadow: 0 0 6px var(--sti-pink-glow);
}

/* Rendered AI layout styles */
.ai-rendered-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s ease-out;
}

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

/* Watermark indicator for admin items */
.privacy-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--warning);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  align-self: flex-start;
  margin-bottom: 5px;
}

.ai-block-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--sti-pink);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
}

/* Metric Cards Grid */
.ai-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 10px 0;
}

.ai-metric-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  transition: var(--transition-fast);
}

.ai-metric-card:hover {
  border-color: var(--sti-pink);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.1);
}

.ai-metric-value {
  font-family: var(--font-logo);
  font-size: 20px;
  font-weight: 700;
  color: var(--sti-pink);
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.2);
}

.ai-metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Action button link layout */
.ai-links-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.ai-link-button {
  background: rgba(0, 68, 255, 0.1);
  border: 1px solid rgba(0, 68, 255, 0.3);
  color: #88aaff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: var(--transition-fast);
}

.ai-link-button:hover {
  background: rgba(0, 68, 255, 0.25);
  border-color: var(--subaru-blue);
  color: white;
  box-shadow: 0 0 10px var(--subaru-blue-glow);
  transform: translateY(-1px);
}

/* AI Gallery Layout */
.ai-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 10px 0;
}

.ai-gallery-item {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #000;
  aspect-ratio: 4/3;
}

.ai-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-normal);
}

.ai-gallery-item img:hover {
  transform: scale(1.05);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  body {
    padding-top: 60px;
  }
  
  .app-header {
    height: 60px;
    padding: 0 15px;
  }
  
  .logo-myrat {
    font-size: 22px;
  }
  
  .logo-title {
    font-size: 18px;
  }
  
  .system-status {
    padding: 4px 10px;
    font-size: 11px;
  }
  
  .app-container {
    padding: 10px 10px 40px 10px;
  }
  
  .inventory-card {
    padding: 15px;
  }
  
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-group {
    min-width: 100%;
  }
  
  .filter-group {
    justify-content: space-between;
  }
  
  .admin-controls {
    margin-left: 0;
  }
  
  .btn {
    width: 100%;
  }
  
  .inventory-table th, .inventory-table td {
    padding: 12px 14px;
    font-size: 13px;
  }
  
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .col-6, .col-4 {
    flex: 0 0 100%;
  }
  
  .modal-container {
    max-height: 95vh;
  }
}
