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

:root {
  --bg: #181c24;
  --fg: #e8eaf0;
  --section-bg: #222633;
  --border: #3a3a54;
  --hover: #2a2a42;
  --active: #ffffff;
  --active-bg: #90caf9;

  /* Tabs */
  --tab-bg: #232946;
  --tab-hover-bg: #2d3349;
  --tab-active-bg: #3a4060;
  --tab-border: #4a5568;
  --tab-title: #e8eaf0;
  --tab-title-inactive: #a0aec0;
  --tab-close-hover: #ff6b35;
  --tab-radius: 10px;
  --tab-shadow: 0 4px 16px 0 rgba(40,45,80,0.10);

  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #181c24 0%, #222633 50%, #232946 100%);
  color: var(--fg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs Bar */
#tabs {
  background: var(--section-bg);
  height: 54px;
  position: relative;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0 16px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 4px;
}

#tabs::-webkit-scrollbar {
  display: none;
}

/* Tab Item */
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 26px 11px 14px;
  background: var(--tab-bg);
  border-radius: var(--tab-radius) var(--tab-radius) 0 0;
  cursor: pointer;
  min-width: 140px;
  max-width: 260px;
  height: 42px;
  margin-bottom: 0;
  border: 1.5px solid var(--tab-border);
  border-bottom: 2.5px solid var(--tab-border);
  transition: 
    background var(--transition),
    border var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
  position: relative;
  box-shadow: var(--tab-shadow);
  overflow: hidden;
  color: var(--tab-title-inactive);
  z-index: 1;
  user-select: none;
}

.tab:hover {
  background: var(--tab-hover-bg);
  color: var(--tab-title);
  border-color: var(--active-bg);
  box-shadow: 0 6px 24px rgba(144, 202, 249, 0.14);
}

.tab.active {
  background: var(--tab-active-bg);
  color: var(--tab-title);
  border-color: var(--active-bg);
  z-index: 2;
  margin-bottom: -2.5px;
  box-shadow: 0 9px 28px 0 rgba(144, 202, 249, 0.17);
  transform: translateY(-3px) scale(1.06);
  border-bottom: 2.5px solid var(--tab-active-bg);
}

.tab.dragging {
  opacity: 0.60;
  transform: scale(0.97);
  background: linear-gradient(135deg, #ff6b35, #f7931e);
}

.tab.drag-over::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--active-bg);
  border-radius: 2px;
}

.tab.drag-over-right::after {
  content: '';
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--active-bg);
  border-radius: 2px;
}

.favicon {
  width: 19px;
  height: 19px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--tab-bg);
}

.tab-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  color: inherit;
  letter-spacing: 0.01em;
}

.tab:not(.active) .tab-title {
  color: var(--tab-title-inactive);
}

.close {
  opacity: 0;
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.09);
  transition: 
    opacity var(--transition), 
    background var(--transition), 
    color var(--transition);
  margin-left: 10px;
}

.close i {
  font-size: 18px;
}

.tab:hover .close,
.tab.active .close {
  opacity: 1;
}

.close:hover {
  background: var(--tab-close-hover);
  color: #fff;
}

/* Tab keyboard shortcut bubbles */
.tab-shortcut {
  background: linear-gradient(135deg, #90caf9, #1976d2);
  color: #fff;
  font-size: 0.82em;
  border-radius: 6px;
  padding: 1px 7px;
  margin-right: 7px;
  margin-left: 0;
  font-weight: 600;
  user-select: none;
  box-shadow: 0 2px 5px 0 rgba(0,0,0,0.10);
  opacity: 0.85;
  letter-spacing: 0.01em;
  display: inline-block;
  min-width: 18px;
  text-align: center;
}

/* New Tab Button */
#tabs button,
#new-tab-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 12px;
  box-shadow: none;
  order: 9999;
}

#tabs button:hover,
#new-tab-btn:hover {
  background: var(--hover);
  color: var(--active-bg);
}

#tabs button i {
  font-size: 18px;
}

/* Controls */
#controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--section-bg);
  border-bottom: 2px solid var(--border);
  position: relative;
}

#controls button,
.icon-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--fg);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 1.45em;
}

#controls button:hover,
.icon-btn:hover,
.icon-btn:focus {
  background: var(--hover);
  border-color: var(--active-bg);
  color: var(--active-bg);
  box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.2);
}

#controls button:active {
  transform: scale(0.95);
}

#controls button i,
.icon-btn i {
  font-size: 18px;
  margin: auto;
  display: block;
}

/* Address Bar */
#address {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--fg);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  margin: 0 8px;
}

#address:focus {
  border-color: var(--active-bg);
  box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.2);
}

#address::placeholder {
  color: rgba(232, 234, 240, 0.4);
}

/* Address Bar Wrapper */
.address-bar-wrapper {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Suggestions Dropdown */
#suggestions-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 10000;
  background: var(--section-bg);
  color: var(--fg);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  font-size: 15px;
  overflow-y: auto;
  max-height: 300px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#suggestions-dropdown::-webkit-scrollbar {
  width: 8px;
}

#suggestions-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

#suggestions-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#suggestions-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--active-bg);
}

.suggestion-item {
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.17s;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--active-bg);
  color: #fff;
}

/* Proxy Toggle Custom Style */
#proxy-toggle {
  background: none;
  border: 2px solid var(--border);
  color: inherit;
  font-size: 1.45em;
  padding: 0.3em 0.6em;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
  height: 40px;
  width: 40px;
  margin-left: 2px;
}

#proxy-toggle:focus,
#proxy-toggle:hover {
  background: var(--hover);
  border-color: var(--active-bg);
  color: var(--active-bg);
  box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.2);
}

#proxy-toggle-label {
  display: none;
  position: absolute;
  bottom: -2.2em;
  left: 50%;
  transform: translateX(-50%);
  background: #191a2a;
  color: #fff;
  white-space: nowrap;
  font-size: 0.98em;
  padding: 0.38em 1.1em;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(30,20,90,0.13);
  opacity: 0;
  z-index: 120;
  pointer-events: none;
  transition: opacity 0.16s;
  font-weight: 500;
  letter-spacing: 0.04em;
  user-select: none;
}

#proxy-toggle:hover #proxy-toggle-label,
#proxy-toggle:focus #proxy-toggle-label {
  display: block;
  opacity: 1;
}

#proxy-toggle i {
  margin: auto;
  display: block;
}

/* Settings button */
#settings-btn {
  margin-left: 2px;
}

/* History Dropdown */
#history-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  min-width: 320px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  margin-top: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: var(--active-bg);
  color: #fff;
}

.history-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.history-bx {
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  width: 18px;
  height: 18px;
  margin-right: 9px;
}

.history-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

/* Main Content */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  width: 100vw;
  height: calc(100vh - 70px);
}

#main iframe {
  display: none;
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
}

#main iframe.active {
  display: block;
}

/* Theme Variations */
body[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --section-bg: #f8f9fa;
  --border: #d1d5db;
  --hover: #f3f4f6;
  --active: #ffffff;
  --active-bg: #90caf9;
  --tab-bg: #f8f9fa;
  --tab-hover-bg: #e7e8f6;
  --tab-active-bg: #ffffff;
  --tab-border: #d1d5db;
  --tab-title: #1a1a1a;
  --tab-title-inactive: #63718c;
}

body[data-theme="light"] #address::placeholder {
  color: rgba(26, 26, 26, 0.4);
}

body[data-theme="purple"] {
  --bg: #1a0b2e;
  --fg: #edf2f7;
  --section-bg: #2d1b4e;
  --border: #7c3aed;
  --hover: #3b2463;
  --active: #ffffff;
  --active-bg: #8b5cf6;
  --tab-bg: #2d1b4e;
  --tab-hover-bg: #3b2463;
  --tab-active-bg: #1a0b2e;
  --tab-border: #7c3aed;
  --tab-title: #edf2f7;
  --tab-title-inactive: #c3afe4;
}

body[data-theme="fusion"] {
  --bg: #181c24;
  --fg: #e8eaf0;
  --section-bg: #222633;
  --border: #4a5568;
  --hover: #2d3349;
  --active: #ffffff;
  --active-bg: #90caf9;
  --tab-bg: #232946;
  --tab-hover-bg: #2d3349;
  --tab-active-bg: #3a4060;
  --tab-border: #4a5568;
  --tab-title: #e8eaf0;
  --tab-title-inactive: #a0aec0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #tabs {
    height: 46px;
    padding: 0 6px;
  }
  
  .tab {
    min-width: 88px;
    max-width: 110px;
    padding: 6px 7px;
    font-size: 12px;
    height: 32px;
  }
  
  #tabs button,
  #new-tab-btn {
    width: 32px;
    height: 32px;
    margin-left: 6px;
  }
  
  #controls {
    gap: 6px;
    padding: 8px;
  }
  
  #controls button,
  .icon-btn {
    width: 36px;
    height: 36px;
    padding: 8px;
  }
  
  #address {
    margin: 0 4px;
    padding: 10px 12px;
  }
  
  #main {
    height: calc(100vh - 60px);
  }
}

/* Additional Fusion-specific styles */
.gradient-text {
  background: linear-gradient(135deg, #ff6b35, #f7931e, #ffd600, #90caf9, #1976d2);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease-in-out infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Enhanced glow effects */
.tab.active {
  box-shadow: 
    0 9px 28px 0 rgba(144, 202, 249, 0.17),
    0 0 20px rgba(144, 202, 249, 0.1);
}

#address:focus {
  box-shadow: 
    0 0 0 3px rgba(144, 202, 249, 0.2),
    0 0 15px rgba(144, 202, 249, 0.1);
}

/* Particle effects for special states */
.tab.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #90caf9, transparent);
  animation: loading 2s infinite;
}

@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
