/* ═══════════════════════════════════════════════
   ChromeApp – Navegador Estilo Chrome
   Modern UI – Light & Dark Mode
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --topbar-h: 38px;
  --toolbar-h: 52px;

  /* Light theme */
  --bg-topbar:    #dee1e6;
  --bg-toolbar:   #f1f3f4;
  --bg-tab-active:#f1f3f4;
  --bg-tab-hover: #e4e6ea;
  --bg-tab-idle:  #d3d5da;
  --bg-content:   #ffffff;
  --bg-panel:     #ffffff;
  --bg-overlay:   rgba(0,0,0,.35);

  --txt-primary:  #202124;
  --txt-secondary:#5f6368;
  --txt-muted:    #9aa0a6;

  --border-color: #dadce0;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.14);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.18);

  --accent:       #1a73e8;
  --accent-hover: #1557b0;
  --danger:       #d93025;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-tab: 10px;

  --font: 'Inter', 'Google Sans', -apple-system, sans-serif;

  /* panel */
  --panel-w: 340px;
}

/* Dark theme */
body.dark {
  --bg-topbar:    #1e1e2e;
  --bg-toolbar:   #2a2a3c;
  --bg-tab-active:#2a2a3c;
  --bg-tab-hover: #35354a;
  --bg-tab-idle:  #1e1e2e;
  --bg-content:   #181824;
  --bg-panel:     #252535;
  --border-color: #3a3a52;
  --txt-primary:  #e8eaed;
  --txt-secondary:#9aa0a6;
  --txt-muted:    #5f6368;
  --shadow-md:    0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.5);
  --accent:       #8ab4f8;
  --accent-hover: #aecbfa;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-content);
  color: var(--txt-primary);
  overflow: hidden;
  user-select: none;
}

/* ══════════════════════════════════════════════
   BROWSER SHELL
══════════════════════════════════════════════ */
#browser-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ══════════════════════════════════════════════
   TOP BAR (tab strip)
══════════════════════════════════════════════ */
#top-bar {
  display: flex;
  align-items: flex-end;
  background: var(--bg-topbar);
  height: var(--topbar-h);
  padding: 0 4px 0 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 20;
}

#tab-strip {
  display: flex;
  align-items: flex-end;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  gap: 2px;
  height: 100%;
  padding-top: 4px;
}
#tab-strip::-webkit-scrollbar { display: none; }

#tabs-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
}

/* Individual Tab */
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 140px;
  max-width: 220px;
  height: 30px;
  padding: 0 10px 0 12px;
  background: var(--bg-tab-idle);
  border-radius: var(--radius-tab) var(--radius-tab) 0 0;
  cursor: pointer;
  position: relative;
  transition: background .15s;
  flex-shrink: 0;
}
.tab:hover { background: var(--bg-tab-hover); }
.tab.active {
  background: var(--bg-tab-active);
  z-index: 2;
}

.tab-favicon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: var(--txt-secondary);
}
.tab-favicon img { width: 16px; height: 16px; border-radius: 3px; }

.tab-title {
  flex: 1;
  font-size: .78rem;
  font-weight: 500;
  color: var(--txt-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-close {
  width: 18px; height: 18px;
  border: none; background: transparent;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem;
  color: var(--txt-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.tab-close:hover { background: rgba(0,0,0,.15); color: var(--txt-primary); }
body.dark .tab-close:hover { background: rgba(255,255,255,.15); }

/* Loading spinner on tab */
.tab-loading .tab-favicon i {
  animation: spin .8s linear infinite;
}

/* New tab button */
#new-tab-btn {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: var(--txt-secondary);
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: background .15s;
}
#new-tab-btn:hover { background: rgba(0,0,0,.1); }
body.dark #new-tab-btn:hover { background: rgba(255,255,255,.1); }

/* Window controls (decorative) */
#window-controls {
  display: flex; gap: 6px;
  align-items: center;
  padding: 0 8px 4px 8px;
}
.win-btn {
  width: 13px; height: 13px;
  border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter .15s;
}
.win-btn:hover { filter: brightness(.85); }
.win-btn.close-btn  { background: #ff5f57; }
.win-btn.minimize   { background: #ffbd2e; }
.win-btn.maximize   { background: #28c840; }

/* ══════════════════════════════════════════════
   TOOLBAR
══════════════════════════════════════════════ */
#toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: var(--toolbar-h);
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

/* Nav buttons */
#nav-buttons { display: flex; gap: 2px; }

.nav-btn {
  width: 34px; height: 34px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem;
  color: var(--txt-secondary);
  transition: background .15s, color .15s;
}
.nav-btn:hover:not(:disabled) {
  background: rgba(0,0,0,.08);
  color: var(--txt-primary);
}
body.dark .nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.nav-btn:disabled { opacity: .35; cursor: default; }

/* Address bar */
#address-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-content);
  border: 1.5px solid transparent;
  border-radius: 24px;
  padding: 0 10px;
  gap: 8px;
  transition: border-color .2s, box-shadow .2s;
  height: 36px;
}
#address-bar-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,.18);
  background: var(--bg-content);
}

#secure-icon {
  font-size: .75rem;
  color: #34a853;
  flex-shrink: 0;
}

#address-bar {
  flex: 1;
  border: none; outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: .86rem;
  color: var(--txt-primary);
  min-width: 0;
}
#address-bar::placeholder { color: var(--txt-muted); }

#btn-go {
  background: transparent; border: none; cursor: pointer;
  font-size: .78rem; color: var(--txt-secondary);
  padding: 4px; border-radius: 50%;
  transition: background .15s;
}
#btn-go:hover { background: rgba(0,0,0,.08); }

/* Toolbar action buttons */
#toolbar-actions { display: flex; gap: 2px; }

.action-btn {
  width: 34px; height: 34px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem;
  color: var(--txt-secondary);
  transition: background .15s, color .15s;
  position: relative;
}
.action-btn:hover {
  background: rgba(0,0,0,.08);
  color: var(--txt-primary);
}
body.dark .action-btn:hover { background: rgba(255,255,255,.1); }
.action-btn.active { color: #fbbf24; }
.action-btn.active i { font-weight: 900; }

/* ══════════════════════════════════════════════
   CONTENT AREA
══════════════════════════════════════════════ */
#content-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-content);
}

.tab-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: none;
  background: var(--bg-content);
}
.tab-frame.active { display: block; }

/* Overlay for iframes that would steal focus */
.iframe-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  cursor: default;
}

/* ══════════════════════════════════════════════
   NEW TAB PAGE
══════════════════════════════════════════════ */
.newtab-page {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  overflow-y: auto;
  position: relative;
  background: var(--bg-content);
}

.newtab-bg {
  position: fixed; inset: 0; z-index: 0;
  background: linear-gradient(135deg, #f8f9ff 0%, #eef2ff 50%, #f0f4ff 100%);
  pointer-events: none;
}
body.dark .newtab-bg {
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
}

.newtab-body {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 60px 20px 40px;
  gap: 24px;
}

.newtab-logo { animation: fadeInDown .6s ease; }

.newtab-greeting {
  font-size: 2rem;
  font-weight: 300;
  color: var(--txt-primary);
  text-align: center;
  animation: fadeInDown .65s ease;
}

.newtab-search-wrap {
  display: flex; align-items: center;
  width: 100%; max-width: 580px;
  background: var(--bg-content);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  padding: 0 16px;
  gap: 10px;
  height: 52px;
  border: 1.5px solid var(--border-color);
  transition: box-shadow .2s, border-color .2s;
  animation: fadeInUp .7s ease;
}
.newtab-search-wrap:focus-within {
  box-shadow: 0 4px 24px rgba(26,115,232,.2);
  border-color: var(--accent);
}

.newtab-search-input {
  flex: 1; border: none; outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--txt-primary);
}
.newtab-search-input::placeholder { color: var(--txt-muted); }

.newtab-search-btn {
  background: var(--accent); border: none; cursor: pointer;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem;
  transition: background .15s, transform .15s;
}
.newtab-search-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Shortcuts grid */
.newtab-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
  width: 100%; max-width: 640px;
  animation: fadeInUp .75s ease;
}

.shortcut-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.shortcut-item:hover {
  background: rgba(0,0,0,.05);
  transform: translateY(-3px);
}
body.dark .shortcut-item:hover { background: rgba(255,255,255,.06); }

.shortcut-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.shortcut-icon img {
  width: 28px; height: 28px; object-fit: contain;
}

.shortcut-item span {
  font-size: .76rem;
  font-weight: 500;
  color: var(--txt-secondary);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Clock/date */
.newtab-info {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 8px;
  animation: fadeInUp .8s ease;
}

.newtab-time {
  font-size: 3.5rem;
  font-weight: 200;
  color: var(--txt-primary);
  letter-spacing: -2px;
}
.newtab-date {
  font-size: .9rem;
  color: var(--txt-secondary);
  text-transform: capitalize;
}

/* ══════════════════════════════════════════════
   SIDE PANELS (History + Bookmarks)
══════════════════════════════════════════════ */
.side-panel {
  position: absolute;
  top: 0; right: 0;
  width: var(--panel-w);
  height: 100%;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border-color);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.side-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: .95rem;
  color: var(--txt-primary);
  flex-shrink: 0;
}
.panel-header span { display: flex; align-items: center; gap: 8px; }
.panel-header i { color: var(--accent); }

.panel-close {
  background: transparent; border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; color: var(--txt-secondary);
  transition: background .15s;
}
.panel-close:hover { background: rgba(0,0,0,.08); }

.panel-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.panel-search input {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 20px; outline: none;
  background: var(--bg-content);
  color: var(--txt-primary);
  font-family: var(--font);
  font-size: .84rem;
  transition: border-color .2s;
}
.panel-search input:focus { border-color: var(--accent); }

/* History list */
#history-list, #bookmarks-list {
  flex: 1; overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}

#history-list li, #bookmarks-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .12s;
  border-radius: 8px;
  margin: 0 6px 2px;
}
#history-list li:hover, #bookmarks-list li:hover {
  background: rgba(0,0,0,.05);
}
body.dark #history-list li:hover,
body.dark #bookmarks-list li:hover { background: rgba(255,255,255,.06); }

.hist-favicon, .bm-favicon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--txt-secondary); font-size: .75rem;
}
.hist-favicon img, .bm-favicon img { width: 16px; height: 16px; border-radius: 3px; }

.hist-info, .bm-info {
  flex: 1; min-width: 0;
}
.hist-title, .bm-title {
  font-size: .82rem; font-weight: 500;
  color: var(--txt-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-url, .bm-url {
  font-size: .72rem;
  color: var(--txt-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-time {
  font-size: .7rem; color: var(--txt-muted); flex-shrink: 0;
}

.hist-del, .bm-del {
  background: transparent; border: none; cursor: pointer;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; color: var(--txt-muted);
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.hist-del:hover, .bm-del:hover {
  background: rgba(217,48,37,.1);
  color: var(--danger);
}

.panel-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}
.panel-footer button {
  background: transparent; border: 1.5px solid var(--border-color);
  cursor: pointer; border-radius: 20px;
  padding: 7px 16px; font-size: .82rem;
  color: var(--txt-secondary); font-family: var(--font);
  display: flex; align-items: center; gap: 6px;
  transition: border-color .15s, color .15s, background .15s;
}
.panel-footer button:hover {
  border-color: var(--danger); color: var(--danger);
  background: rgba(217,48,37,.06);
}

#no-bookmarks-msg {
  text-align: center;
  color: var(--txt-muted);
  font-size: .88rem;
  padding: 32px 16px;
}

/* ══════════════════════════════════════════════
   DROPDOWN MENU
══════════════════════════════════════════════ */
#dropdown-menu {
  position: absolute;
  top: calc(var(--topbar-h) + var(--toolbar-h) + 4px);
  right: 12px;
  width: 220px;
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  z-index: 100;
  overflow: hidden;
  animation: fadeInScale .18s ease;
}
#dropdown-menu.hidden { display: none; }

#dropdown-menu ul { list-style: none; padding: 6px 0; }
#dropdown-menu li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  font-size: .86rem;
  color: var(--txt-primary);
  cursor: pointer;
  transition: background .12s;
}
#dropdown-menu li:hover { background: rgba(0,0,0,.05); }
body.dark #dropdown-menu li:hover { background: rgba(255,255,255,.06); }
#dropdown-menu li i { width: 16px; color: var(--txt-secondary); }
#dropdown-menu .divider {
  height: 1px; background: var(--border-color);
  padding: 0; margin: 4px 0; cursor: default;
}
#dropdown-menu .divider:hover { background: var(--border-color); }

/* ══════════════════════════════════════════════
   LOADING BAR
══════════════════════════════════════════════ */
#loading-bar {
  position: absolute;
  top: 0; left: 0; height: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transition: width .3s ease;
  z-index: 999;
  display: none;
}

/* Tab loading pulse */
.tab-loading .tab-title {
  opacity: .6;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .6; }
  50%       { opacity: 1; }
}

/* Selected text style */
::selection {
  background: rgba(26,115,232,.25);
}

/* ══════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  pointer-events: none;
}

.toast {
  background: #323232; color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: .84rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: toastIn .3s ease;
  pointer-events: none;
}
.toast.out { animation: toastOut .3s ease forwards; }

/* ══════════════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.18);
  border-radius: 3px;
}
body.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.3); }

/* ══════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════ */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .tab { min-width: 100px; }
  #toolbar { gap: 4px; padding: 0 6px; }
  #nav-buttons { gap: 0; }
  .nav-btn { width: 30px; height: 30px; font-size: .8rem; }
  #address-bar-wrap { height: 32px; }
  #toolbar-actions { gap: 0; }
  .action-btn { width: 30px; height: 30px; }
  .newtab-time { font-size: 2.5rem; }
  .newtab-search-wrap { height: 46px; }
  .side-panel { width: 100%; }
}
