/* ═══════════════════════════════════════════════════════════════════════
   NanoVerse Internal Browser — Advanced Overlay Browser Styles
   Futuristic, minimal, professional browser UI
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Body lock ─────────────────────────────────────────────────── */
.ib-body-lock {
    overflow: hidden !important;
}

/* ── Overlay container ─────────────────────────────────────────── */
#ib-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    /* Respect activity bar: offset left by bar width + gap */
    left: calc(var(--ab-width, 56px) + var(--ab-gap, 18px));
    z-index: 1050; /* Below activity bar (z-index: 1100) */
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s cubic-bezier(.4,0,.2,1), visibility .3s;
}
#ib-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Backdrop ──────────────────────────────────────────────────── */
.ib-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.65);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* ── Browser window ────────────────────────────────────────────── */
.ib-browser {
    position: relative;
    width: 96%;
    height: 96%;
    max-width: none;
    display: flex;
    flex-direction: column;
    background: #0e0e12;
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255,255,255,.06),
        0 32px 80px rgba(0,0,0,.6),
        0 0 120px rgba(100,100,255,.04);
    transform: scale(.97) translateY(12px);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
}
#ib-overlay.active .ib-browser {
    transform: scale(1) translateY(0);
}
.ib-browser.fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
}

/* ── Progress bar ──────────────────────────────────────────────── */
.ib-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, #6366f1, #818cf8, #a5b4fc);
    z-index: 100;
    border-radius: 0 2px 2px 0;
    transition: width .2s;
}
.ib-progress-bar.loading {
    animation: ib-progress 2s ease-in-out infinite;
}
@keyframes ib-progress {
    0%   { width: 0; }
    30%  { width: 55%; }
    60%  { width: 80%; }
    100% { width: 95%; }
}

/* ── Tab strip ─────────────────────────────────────────────────── */
.ib-tab-strip {
    display: flex;
    align-items: center;
    height: 42px;
    min-height: 42px;
    background: #111116;
    padding: 0 8px;
    gap: 2px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    -webkit-app-region: drag;
    -webkit-user-select: none;
    user-select: none;
}
.ib-tab-list {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: none;
    -webkit-app-region: no-drag;
}
.ib-tab-list::-webkit-scrollbar { display: none; }

.ib-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    min-width: 120px;
    max-width: 220px;
    height: 32px;
    background: rgba(255,255,255,.03);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    position: relative;
    flex-shrink: 0;
}
.ib-tab:hover {
    background: rgba(255,255,255,.07);
}
.ib-tab.active {
    background: #1a1a22;
    box-shadow: inset 0 1px 0 rgba(99,102,241,.4);
}
.ib-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: #1a1a22;
}

.ib-tab-favicon, .ib-tab-favicon-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}
.ib-tab-favicon-icon {
    font-size: 11px;
    color: #666;
}

.ib-tab-title {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ib-tab.active .ib-tab-title {
    color: #e5e7eb;
}

.ib-tab-close {
    background: none;
    border: none;
    color: transparent;
    font-size: 10px;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ib-tab:hover .ib-tab-close {
    color: #6b7280;
}
.ib-tab-close:hover {
    color: #f87171 !important;
    background: rgba(248,113,113,.12);
}

.ib-new-tab-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all .15s;
    flex-shrink: 0;
    -webkit-app-region: no-drag;
}
.ib-new-tab-btn:hover {
    color: #e5e7eb;
    background: rgba(255,255,255,.07);
}

.ib-tab-strip-spacer { flex: 1; }

.ib-tab-strip > .ib-btn-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all .15s;
    -webkit-app-region: no-drag;
}
.ib-tab-strip > .ib-btn-close:hover {
    color: #f87171;
    background: rgba(248,113,113,.1);
}

/* ── Toolbar ───────────────────────────────────────────────────── */
.ib-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #14141a;
    border-bottom: 1px solid rgba(255,255,255,.04);
    position: relative;
}

.ib-tool-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ib-tool-btn:hover:not(:disabled) {
    color: #e5e7eb;
    background: rgba(255,255,255,.07);
}
.ib-tool-btn:disabled {
    opacity: .3;
    cursor: default;
}
.ib-tool-btn.active {
    color: #818cf8;
    background: rgba(129,140,248,.1);
}

.ib-nav-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* ── Address bar ───────────────────────────────────────────────── */
.ib-address-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a1a22;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 10px;
    padding: 5px 12px;
    min-width: 0;
    transition: border-color .2s, box-shadow .2s;
}
.ib-address-bar:focus-within {
    border-color: rgba(99,102,241,.5);
    box-shadow: 0 0 0 3px rgba(99,102,241,.08);
}

.ib-ssl-icon {
    font-size: 12px;
    color: #6b7280;
    flex-shrink: 0;
}
.ib-ssl-icon.secure { color: #34d399; }
.ib-ssl-icon.insecure { color: #f87171; }

.ib-address-favicon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

.ib-address-input {
    flex: 1;
    background: none;
    border: none;
    color: #d1d5db;
    font-size: 13px;
    font-family: -apple-system, 'SF Mono', 'Cascadia Code', 'Segoe UI', monospace;
    outline: none;
    min-width: 0;
}
.ib-address-input::placeholder { color: #4b5563; }
.ib-address-input::selection { background: rgba(99,102,241,.3); }

.ib-addr-action {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    padding: 2px;
    transition: color .15s;
    flex-shrink: 0;
}
.ib-addr-action:hover { color: #fbbf24; }
.ib-addr-action i.bookmarked { color: #fbbf24; }

.ib-actions-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.ib-zoom-label {
    font-size: 11px;
    color: #6b7280;
    min-width: 32px;
    text-align: center;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    -webkit-user-select: none;
    user-select: none;
}

.ib-separator {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,.08);
    margin: 0 4px;
}

/* ── Menu dropdown ─────────────────────────────────────────────── */
.ib-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 10px;
    background: #1a1a22;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 6px 0;
    min-width: 200px;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,.5);
    z-index: 200;
}
.ib-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: #d1d5db;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background .12s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ib-menu-item:hover {
    background: rgba(99,102,241,.1);
    color: #e5e7eb;
}
.ib-menu-item i { width: 16px; text-align: center; color: #6b7280; font-size: 12px; }
.ib-menu-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 4px 12px;
}

/* ── Find bar ──────────────────────────────────────────────────── */
.ib-find-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #18181f;
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.ib-find-icon { color: #6b7280; font-size: 12px; }
.ib-find-input {
    flex: 1;
    background: #1a1a22;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 6px;
    padding: 4px 10px;
    color: #d1d5db;
    font-size: 13px;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ib-find-input:focus {
    border-color: rgba(99,102,241,.5);
}
.ib-find-count { color: #6b7280; font-size: 11px; }

/* ── Body (viewport + sidebar) ─────────────────────────────────── */
.ib-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ── Viewport ──────────────────────────────────────────────────── */
.ib-viewport {
    flex: 1;
    position: relative;
    background: #fff;
    overflow: hidden;
}

.ib-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    visibility: hidden;
    z-index: 0;
    background: #fff;
}
.ib-frame.active {
    display: block;
    visibility: visible;
    z-index: 1;
}

/* Webview specific */
webview.ib-frame {
    display: none;
    visibility: hidden;
}
webview.ib-frame.active {
    display: block;
    visibility: visible;
    z-index: 1;
}

/* Loading shimmer */
.ib-loading-shimmer {
    position: absolute;
    inset: 0;
    background: #0e0e12;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 40px;
    gap: 20px;
}
.ib-shimmer-bar {
    height: 18px;
    border-radius: 8px;
    background: linear-gradient(90deg, #1a1a22 25%, #22222e 50%, #1a1a22 75%);
    background-size: 200% 100%;
    animation: ib-shimmer 1.5s ease-in-out infinite;
}
.ib-shimmer-bar.short { width: 60%; }
.ib-shimmer-bar.medium { width: 80%; }
@keyframes ib-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.ib-sidebar {
    width: 0;
    background: #111116;
    border-left: 1px solid rgba(255,255,255,.04);
    overflow: hidden;
    transition: width .3s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}
.ib-sidebar.open {
    width: 300px;
}

.ib-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    flex-shrink: 0;
}
.ib-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ib-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}
.ib-sidebar-list::-webkit-scrollbar { width: 4px; }
.ib-sidebar-list::-webkit-scrollbar-track { background: transparent; }
.ib-sidebar-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.ib-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid rgba(255,255,255,.02);
}
.ib-sidebar-item:hover {
    background: rgba(99,102,241,.08);
}

.ib-sidebar-favicon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
}

.ib-sidebar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}

.ib-sidebar-title-text {
    font-size: 12px;
    color: #d1d5db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ib-sidebar-domain {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}

/* ── Status bar ────────────────────────────────────────────────── */
.ib-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 14px;
    background: #111116;
    border-top: 1px solid rgba(255,255,255,.04);
    min-height: 24px;
}

.ib-status-text {
    font-size: 11px;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}

.ib-status-zoom {
    font-size: 11px;
    color: #4b5563;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .ib-browser {
        width: 98vw;
        height: 96vh;
        border-radius: 12px;
    }
    .ib-sidebar.open { width: 260px; }
    .ib-zoom-label,
    .ib-btn-zoom-in,
    .ib-btn-zoom-out,
    .ib-btn-zoom-reset { display: none; }
}

@media (max-width: 768px) {
    /* On mobile, activity bar moves to bottom — overlay fills screen */
    #ib-overlay {
        left: 0;
    }
    .ib-browser {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .ib-sidebar.open { width: 100%; position: absolute; right: 0; top: 0; bottom: 0; z-index: 50; }
    .ib-actions-group .ib-separator,
    .ib-btn-fullscreen { display: none; }
    .ib-tab { min-width: 80px; max-width: 140px; }
}

@media (max-width: 480px) {
    .ib-toolbar { gap: 3px; padding: 5px 6px; }
    .ib-tool-btn { padding: 5px 6px; font-size: 12px; }
    .ib-address-bar { padding: 4px 8px; }
    .ib-address-input { font-size: 12px; }
    .ib-btn-share,
    .ib-btn-find { display: none; }
}
