@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Core Colors - Light Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: rgba(59, 130, 246, 0.08);
  --bg-active: rgba(59, 130, 246, 0.12);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.1);
  
  --border-light: #e2e8f0;
  --border-focus: #3b82f6;
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  /* Shadows & Glass */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.4);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

h1, h2, h3, .logo-text {
  font-family: 'Outfit', sans-serif;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

input {
  border: none;
  outline: none;
  font-family: inherit;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* Main Shell */
#browser-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

/* Header / Tabs Area */
header#titlebar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  height: 54px;
}

.titlebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

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

/* Tab Bar */
#tabbar {
  display: flex;
  align-items: flex-end;
  flex: 1;
  height: 100%;
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
#tabbar::-webkit-scrollbar { display: none; }

#tabs-container {
  display: flex;
  gap: 4px;
  height: 38px;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  min-width: 120px;
  max-width: 220px;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: 10px 10px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  border: 1px solid var(--border-light);
  border-bottom: none;
  transition: var(--transition);
  animation: scaleIn 0.3s ease;
}

.tab-item:hover {
  background: var(--bg-secondary);
}

.tab-item.active {
  background: var(--bg-secondary);
  color: var(--accent);
  height: 38px;
  border-color: var(--border-light);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
  z-index: 2;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-secondary);
}

.tab-favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.tab-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0;
}

.tab-item:hover .tab-close { opacity: 1; }
.tab-close:hover { background: rgba(0,0,0,0.05); color: var(--danger); }

.new-tab-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 18px;
  margin-left: 8px;
  margin-bottom: 4px;
}
.new-tab-btn:hover { background: var(--bg-tertiary); color: var(--accent); }

/* Toolbar Area */
#toolbar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  z-index: 5;
}

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

.nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 16px;
}
.nav-btn:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

.addressbar-container {
  flex: 1;
  height: 38px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  border: 1px solid transparent;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.addressbar-container:focus-within {
  background: var(--bg-secondary);
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

/* Search Suggestions Dropdown */
#suggestions-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1000;
  overflow: hidden;
  margin-top: 4px;
}

.suggestion-item {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.suggestion-item:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.suggestion-icon { font-size: 12px; opacity: 0.5; }

.address-icon { color: var(--text-muted); font-size: 14px; }
.address-secure { color: var(--success); font-size: 12px; }

#addressbar {
  flex: 1;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

#progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.toolbar-right {
  display: flex;
  gap: 6px;
}

.toolbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 16px;
  position: relative;
}
.toolbar-icon-btn:hover { background: var(--bg-tertiary); }
.toolbar-icon-btn.active { color: var(--accent); background: var(--accent-soft); }

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

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

.webview-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#newtab-page {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10vh;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#newtab-page.active {
  opacity: 1;
  pointer-events: auto;
}

.newtab-logo {
  text-align: center;
  margin-bottom: 40px;
  animation: slideDown 0.6s ease;
}

.newtab-logo-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

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

.newtab-logo p {
  color: var(--text-muted);
  font-size: 16px;
}

.newtab-search {
  width: 100%;
  max-width: 600px;
  height: 56px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 48px;
  transition: var(--transition);
  animation: slideUp 0.6s ease 0.2s backwards;
}

.newtab-search:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

#newtab-search-input {
  flex: 1;
  font-size: 16px;
}

.newtab-search-btn {
  font-size: 20px;
  color: var(--accent);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  max-width: 500px;
  animation: slideUp 0.6s ease 0.3s backwards;
}

.quick-link-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.quick-link-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-secondary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.quick-link-item:hover { transform: translateY(-5px); }
.quick-link-item:hover .quick-link-icon { border-color: var(--accent); color: var(--accent); shadow: 0 8px 15px rgba(59, 130, 246, 0.2); }
.quick-link-item span { font-size: 12px; font-weight: 500; color: var(--text-secondary); }

/* Search Results Display */
.search-results-overlay {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.5s ease;
}

.search-result-card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.result-heading { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.result-abstract { font-size: 16px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 20px; }
.result-meta { display: flex; align-items: center; gap: 12px; }
.result-source { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 20px; text-decoration: none; }

/* Bookmarks Sidebar */
.bookmark-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.bookmark-item:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
  transform: translateX(4px);
}

.bookmark-icon { font-size: 18px; }
.bookmark-info { flex: 1; overflow: hidden; }
.bookmark-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark-url { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark-del { color: var(--text-muted); padding: 4px; border-radius: 6px; }
.bookmark-del:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Reading Mode */
.reading-mode-overlay {
  position: absolute;
  inset: 0;
  background: #fdf6e3; /* Solarized light */
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 60px 20px;
  display: none;
}

.reading-mode-content {
  max-width: 700px;
  width: 100%;
}

.reading-mode-title { font-family: 'Outfit', sans-serif; font-size: 42px; font-weight: 700; color: #586e75; margin-bottom: 30px; line-height: 1.2; }
.reading-mode-text { font-family: 'Georgia', serif; font-size: 20px; line-height: 1.8; color: #657b83; }
.reading-mode-close { position: fixed; top: 20px; right: 20px; background: white; width: 40px; height: 40px; border-radius: 50%; box-shadow: var(--shadow-md); font-size: 20px; }

/* Downloads */
.download-item {
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  margin-bottom: 12px;
}

.download-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.download-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.download-progress-container { height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.download-progress-bar { height: 100%; background: var(--accent); transition: width 0.3s ease; }
.download-footer { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

/* Sidebar */
#sidebar {
  width: 320px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: absolute;
  right: -320px;
  top: 0;
  bottom: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  box-shadow: -10px 0 30px rgba(0,0,0,0.05);
}

#sidebar.open {
  transform: translateX(-320px);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title { font-weight: 700; font-size: 18px; }
.sidebar-close { font-size: 24px; color: var(--text-muted); }

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-tab {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.sidebar-panel { display: none; }
.sidebar-panel.active { display: block; animation: fadeIn 0.3s ease; }

/* Settings Components */
.settings-section { margin-bottom: 24px; }
.settings-section-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; letter-spacing: 1px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-tertiary);
}

.setting-info { flex: 1; padding-right: 12px; }
.setting-label { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.setting-desc { font-size: 12px; color: var(--text-muted); }

/* Switch Toggle */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-light);
  border-radius: 20px;
  transition: 0.3s;
}
.toggle-slider:before {
  position: absolute; content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: var(--shadow-sm);
}
input:checked + .toggle-slider { background: var(--accent); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

/* VPN Badge */
.vpn-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.vpn-badge.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.2);
}

.vpn-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
}
.vpn-badge.active .vpn-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.5s infinite; }

/* Status Bar */
#statusbar {
  height: 28px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-muted);
}

.statusbar-left, .statusbar-right { display: flex; gap: 16px; align-items: center; }
.status-item { display: flex; align-items: center; gap: 6px; }
.status-indicator { width: 6px; height: 6px; border-radius: 50%; }
.status-indicator.green { background: var(--success); }
.status-indicator.blue { background: var(--accent); }
.status-indicator.purple { background: #8b5cf6; }

/* VPN Panel */
#vpn-panel {
  position: fixed;
  top: 60px;
  right: 170px;
  width: 280px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  padding: 20px;
  z-index: 100;
  display: none;
  animation: slideDown 0.3s ease;
}

#vpn-panel.open { display: block; }

.vpn-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.vpn-panel-title { font-weight: 700; font-size: 14px; }
.vpn-status-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  transition: var(--transition);
}
.vpn-status-circle.connected { background: var(--accent-soft); color: var(--accent); border: 4px solid var(--accent); }
.vpn-status-circle.disconnected { background: var(--bg-tertiary); color: var(--text-muted); border: 4px solid var(--border-light); }

.vpn-status-text { text-align: center; font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.vpn-status-sub { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }

.vpn-toggle-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
}
.vpn-toggle-btn.connect { background: var(--accent); color: white; }
.vpn-toggle-btn.disconnect { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Toast */
.ad-blocked-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: white;
  padding: 10px 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
  border: 1px solid var(--border-light);
}

.ad-blocked-toast.show { transform: translateX(-50%) translateY(0); }

/* Context Menu */
#context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 6px;
  z-index: 1000;
  display: none;
  animation: scaleIn 0.2s ease;
}

.ctx-item {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
}
.ctx-item:hover { background: var(--bg-tertiary); color: var(--accent); }
.ctx-item.danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.ctx-separator { height: 1px; background: var(--border-light); margin: 4px; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .titlebar-logo { min-width: auto; }
  .logo-text, .titlebar-center { display: none; }
  .addressbar-container { margin: 0 8px; }
  #sidebar { width: 100%; right: -100%; }
  #sidebar.open { transform: translateX(-100%); }
  .newtab-search { max-width: 90%; }
}

/* Loading Spinner */
.loading-screen {
  position: fixed;
  inset: 0;
  background: white;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden { opacity: 0; visibility: hidden; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-text { font-weight: 600; font-size: 14px; color: var(--text-muted); letter-spacing: 2px; }
