/* Root Variables & Colors */
:root {
  --bg-primary: #08090d;
  --bg-secondary: #11131a;
  --bg-tertiary: #1b1e2b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(138, 43, 226, 0.5);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-purple: #8a2be2;
  --accent-cyan: #00ffff;
  --accent-gradient: linear-gradient(135deg, #8a2be2 0%, #00ffff 100%);
  --danger-color: #ff5f56;
  --warning-color: #ffbd2e;
  --success-color: #27c93f;
  --glass-bg: rgba(17, 19, 26, 0.7);
  --glass-blur: blur(16px);
}

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

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* Main Layout Structure */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Frameless Window Custom Titlebar */
#titlebar {
  -webkit-app-region: drag;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  z-index: 100;
}

/* Window traffic-light buttons */
.window-controls {
  -webkit-app-region: no-drag;
  display: flex;
  gap: 8px;
  align-items: center;
  width: 120px;
}

.win-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s;
}

.win-btn:hover {
  opacity: 0.8;
}

.win-btn.close { background-color: var(--danger-color); }
.win-btn.minimize { background-color: var(--warning-color); }
.win-btn.maximize { background-color: var(--success-color); }

/* Tab Container and Scrollable Bar */
.tab-container {
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  flex-grow: 1;
  max-width: calc(100% - 320px);
  margin-left: 20px;
  height: 100%;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  height: 100%;
  padding: 6px 0;
}

.tabs::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Tab Design */
.tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 32px;
  min-width: 120px;
  max-width: 180px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-tertiary);
  border-color: rgba(138, 43, 226, 0.35);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(138, 43, 226, 0.1);
}

.tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
  margin-right: 8px;
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tab-close:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--danger-color);
}

/* Dynamic Add Tab button */
.icon-btn {
  -webkit-app-region: no-drag;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.add-tab {
  width: 32px;
  height: 32px;
  margin-left: 6px;
  border: 1px dashed var(--border-color);
}

.add-tab:hover {
  border-color: var(--accent-purple);
  box-shadow: 0 0 8px rgba(138, 43, 226, 0.2);
}

/* Header Privacy & Blocker Actions */
.header-actions {
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  gap: 12px;
}

.shield-widget {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.shield-widget.enabled {
  border-color: rgba(39, 201, 63, 0.3);
  color: var(--success-color);
  background-color: rgba(39, 201, 63, 0.05);
}

.shield-widget.enabled .shield-icon {
  animation: pulseGreen 2.5s infinite;
}

.shield-widget.disabled {
  border-color: rgba(255, 95, 86, 0.3);
  color: var(--danger-color);
  background-color: rgba(255, 95, 86, 0.05);
}

.clear-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
}

.clear-btn:hover {
  color: var(--accent-cyan);
  border-color: rgba(0, 255, 255, 0.3);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.15);
}

/* Navigation Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  height: 48px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  gap: 16px;
  z-index: 90;
}

.nav-buttons {
  display: flex;
  gap: 4px;
}

.nav-btn {
  width: 32px;
  height: 32px;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Address Bar Container */
.address-container {
  display: flex;
  align-items: center;
  flex-grow: 1;
  height: 32px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  transition: all 0.3s;
}

.address-container:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.15);
  background-color: rgba(0, 0, 0, 0.4);
}

.security-indicator {
  color: var(--success-color);
  display: flex;
  align-items: center;
}

.security-indicator.insecure {
  color: var(--text-secondary);
}

#url-input {
  flex-grow: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

/* App Content Area */
#content-area {
  flex-grow: 1;
  position: relative;
  background-color: var(--bg-primary);
}

.webview-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}

/* Hide inactive webviews */
.web-view-frame {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
}

.web-view-frame.active {
  display: block;
}

/* Built-in Custom New Tab dashboard */
.new-tab-view {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  background-color: var(--bg-primary);
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.new-tab-view.hidden {
  display: none !important;
}

/* Glowing aesthetic background */
.background-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(138, 43, 226, 0.08) 0%, rgba(0, 255, 255, 0.03) 50%, rgba(0,0,0,0) 70%);
  z-index: 1;
  pointer-events: none;
  filter: blur(40px);
  animation: floatGlow 15s infinite alternate;
}

.dashboard-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 800px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Brand Logo */
.logo-area {
  margin-bottom: 32px;
}

.logo-shield {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px rgba(138, 43, 226, 0.3));
}

.inner-ghost {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent-cyan);
}

.logo-area h1 {
  font-size: 36px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.logo-area .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Dashboard Centered Search Box */
.search-box-container {
  width: 100%;
  max-width: 560px;
  margin-bottom: 48px;
}

.dash-search-wrapper {
  display: flex;
  align-items: center;
  height: 48px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 16px;
  gap: 12px;
  transition: all 0.3s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.dash-search-wrapper:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.dash-search-wrapper:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(138, 43, 226, 0.2);
  background-color: rgba(255, 255, 255, 0.05);
}

.dash-search-wrapper .search-icon {
  color: var(--text-secondary);
}

.dash-search-wrapper:focus-within .search-icon {
  color: var(--accent-cyan);
}

#dash-search-input {
  flex-grow: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
}

/* Grid Cards for Privacy metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  margin-bottom: 48px;
}

.metrics-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
}

.metrics-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.metrics-card.card-glow:hover {
  border-color: rgba(138, 43, 226, 0.3);
  box-shadow: 0 10px 30px rgba(138, 43, 226, 0.08);
}

.metrics-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.metrics-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-secondary);
  position: relative;
}

.status-indicator.active {
  background-color: var(--success-color);
}

.status-indicator.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--success-color);
  animation: pulseRing 1.5s infinite;
}

.metrics-stat {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.metrics-info {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-top: 6px;
}

.metrics-card .card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Speed Dial / Links Grid */
.quick-links {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  width: 100%;
}

.link-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.link-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-cyan);
  transform: scale(1.05);
}

.link-logo {
  font-size: 24px;
  margin-bottom: 8px;
}

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

.link-item:hover .link-label {
  color: var(--text-primary);
}

/* Session wipe broom notification overlay */
.wipe-notification {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(8, 9, 13, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.wipe-notification.show {
  opacity: 1;
  pointer-events: auto;
}

.wipe-notification.show .broom-icon {
  animation: sweepBroom 1.2s infinite ease-in-out;
}

.broom-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.wipe-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

/* CSS Keyframe Animations */
@keyframes floatGlow {
  0% { transform: translate(-50%, -50%) scale(1); }
  100% { transform: translate(-45%, -55%) scale(1.1); }
}

@keyframes pulseGreen {
  0% { filter: drop-shadow(0 0 1px rgba(39, 201, 63, 0.4)); }
  50% { filter: drop-shadow(0 0 6px rgba(39, 201, 63, 0.8)); }
  100% { filter: drop-shadow(0 0 1px rgba(39, 201, 63, 0.4)); }
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes sweepBroom {
  0% { transform: rotate(0deg) translateX(0); }
  25% { transform: rotate(-20deg) translateX(-10px); }
  75% { transform: rotate(20deg) translateX(10px); }
  100% { transform: rotate(0deg) translateX(0); }
}

/* Basic Animations */
.animate-fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.animate-fade-in-delayed {
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.3s forwards;
}

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

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