/* Aetheria 2.0 System Framework: Universal Interface Widgets & Assets */

/* -- FORM INPUT ELEMENTS -- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.form-group input {
    width: 100%; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-glass);
    border-radius: 12px; padding: 12px 16px; color: var(--text-primary); font-size: 0.95rem; outline: none;
}
.form-group small { display: block; margin-top: 6px; font-size: 0.75rem; color: var(--text-secondary); }

/* 🔢 PREMIUM NUMBER INPUTS (Firefox & Webkit Fix) */
input[type=number] {
    appearance: auto !important;
    -moz-appearance: number-input !important; /* CRITICAL FOR FIREFOX */
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    opacity: 0.8;
    filter: invert(1);
    cursor: pointer;
}

.btn-save {
    width: 100%; background: var(--accent); color: #fff; border: none;
    border-radius: 12px; padding: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
}
.btn-save:hover { box-shadow: 0 0 20px var(--accent-glow); transform: translateY(-2px); }

.select-glass {
    width: 100%; background-color: #131524 !important; border: 1px solid var(--border-glass);
    border-radius: 12px; padding: 12px 16px; color: #ffffff !important; font-size: 0.95rem;
    outline: none; cursor: pointer; appearance: none !important; -webkit-appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23a0a5c0'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='6%209%2012%2015%2018%209'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important; background-position: right 16px center !important; background-size: 16px !important;
}
.select-glass:hover { border-color: var(--accent); background-color: #1a1d30 !important; }
.select-glass option { background-color: #131524 !important; color: #ffffff !important; }

.form-row { display: flex; gap: 16px; }
.form-group.half { flex: 1; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* -- SMART DIRECTIONAL TAB RIBBON -- */
.tabs-scroll-wrapper { position: relative; width: 100%; margin-bottom: 24px; }
.tab-scroll-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(108, 92, 231, 0.8); border: 1px solid rgba(255,255,255,0.2); color: white;
    width: 28px; height: 28px; border-radius: 50%; display: none; align-items: center;
    justify-content: center; cursor: pointer; z-index: 10; font-size: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); backdrop-filter: blur(5px); transition: all 0.2s ease;
}
.tab-scroll-nav:hover { background: var(--accent); transform: translateY(-50%) scale(1.15); }
.nav-left { left: -5px; }
.nav-right { right: -5px; }

.tab-buttons {
    display: flex; border-bottom: 1px solid var(--border-glass); gap: 8px;
    overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.tab-buttons::-webkit-scrollbar { display: none; }
.tab-btn {
    background: transparent; border: none; color: var(--text-secondary);
    padding: 12px 20px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.3s ease;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* -- TOGGLE SWITCHES -- */
.switch-label { display: inline-flex !important; align-items: center; gap: 12px; cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--text-primary); }
.switch-input { display: none; }
.switch-custom { position: relative; width: 44px; height: 24px; background: rgba(255, 255, 255, 0.1); border-radius: 20px; transition: all 0.3s ease; border: 1px solid var(--border-glass); }
.switch-custom::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--text-secondary); top: 3px; left: 4px; transition: all 0.3s ease; }
.switch-input:checked + .switch-custom { background: var(--accent); border-color: var(--accent); }
.switch-input:checked + .switch-custom::after { left: 22px; background: #fff; }

/* -- WHISPER MODEL UTILS -- */
.model-manager-box { margin-top: 24px; background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-glass); border-radius: 16px; padding: 16px; }
.manager-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; }
.model-list { display: flex; flex-direction: column; gap: 12px; }
.model-item { display: flex; justify-content: space-between; align-items: center; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-glass); border-radius: 12px; padding: 12px 16px; }
.model-info-left { display: flex; flex-direction: column; gap: 4px; }
.model-status-box { display: flex; align-items: center; gap: 12px; }
.progress-bar-container { width: 100px; height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; }
.btn-dl, .btn-del { border: none; border-radius: 8px; padding: 6px 12px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
.btn-dl { background: var(--accent); color: #fff; }
.btn-del { background: rgba(214, 48, 49, 0.15); color: #d63031; border: 1px solid rgba(214, 48, 49, 0.25); }
.model-item-downloaded { border-color: rgba(0, 184, 148, 0.25); background: rgba(0, 184, 148, 0.02); }

/* -- BUBBLE UTILS -- */
.audio-btn {
    background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px;
    color: var(--text-primary); font-size: 0.75rem; font-weight: 500; cursor: pointer; padding: 4px 10px;
    display: flex; align-items: center; gap: 6px; transition: all 0.2s ease;
}
.audio-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--accent); }

.icon-only-btn {
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-glass); color: var(--text-primary);
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; cursor: pointer; transition: all 0.2s ease; padding: 0; line-height: 1;
}
.icon-only-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2);    transform: scale(0.98);
}

/* 🛡️ TOOL CONFIRMATION CARD */
.system-confirm-bubble {
    background: transparent !important;
    padding: 0 !important;
    margin: 20px auto !important;
    max-width: 90% !important;
}

.confirm-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: slideInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confirm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--accent);
    font-weight: bold;
    font-size: 1.1rem;
}

.confirm-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.btn-confirm-yes, .btn-confirm-no {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-confirm-yes {
    background: rgba(0, 184, 148, 0.15);
    color: #00b894;
}

.btn-confirm-no {
    background: rgba(214, 48, 49, 0.15);
    color: #ff7675;
}

.btn-confirm-yes:hover { background: #00b894; color: white; }
.btn-confirm-no:hover { background: #d63031; color: white; }

.btn-confirm-yes:disabled, .btn-confirm-no:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

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

/* Absolute select overlays */
.header-icon-btn-wrapper { position: relative; width: 40px; height: 40px; }
.invisible-select-overlay {
    position: absolute !important; top: 0; left: 0; width: 100% !important; height: 100% !important;
    opacity: 0; cursor: pointer; z-index: 5; padding: 0 !important; margin: 0 !important;
}
/* -- PREMIUM AGENT THOUGHT UI (Modern Collapsible Reasoning) -- */
.agent-thought-details {
    margin: 12px 0;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}
.agent-thought-details:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}
.agent-thought-details summary {
    list-style: none; /* Hide standard arrow */
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
    user-select: none;
}
/* Custom CSS Chevron marker */
.agent-thought-details summary::before {
    content: '';
    width: 6px;
    height: 6px;
    border-top: 2px solid rgba(255,255,255,0.5);
    border-right: 2px solid rgba(255,255,255,0.5);
    transform: rotate(45deg); /* Standard point right */
    transition: transform 0.2s ease;
    margin-right: 4px;
}
/* Rotate chevron when open */
.agent-thought-details[open] summary::before {
    transform: rotate(135deg); /* Point down */
}
/* Webkit specific hide */
.agent-thought-details summary::-webkit-details-marker {
    display: none;
}
.agent-thought-content {
    padding: 12px 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    font-family: 'Inter', sans-serif;
    animation: fadeInSlide 0.25s ease-out forwards;
    word-break: break-word;
}
.agent-thought-content pre {
    max-width: 100%;
    overflow-x: auto !important;
    white-space: pre-wrap;
    word-break: break-all;
}
@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
/* -- PREMIUM CUSTOM DROPDOWN (Omni-Dropdown) -- */
.omni-dropdown {
    position: relative;
    user-select: none;
    margin-right: 15px; /* Give some air */
}

.omni-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px; /* Slightly more padding */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.omni-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.omni-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 12px); /* Open upwards by default */
    left: 0;
    min-width: 200px;
    background: rgba(20, 22, 38, 0.9); /* Slightly more opaque for menus */
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    transform-origin: bottom center;
    animation: dropdownPopUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Header style opens DOWNWARDS */
.omni-dropdown.header-style {
    margin-right: 0;
}
.omni-dropdown.header-style .omni-dropdown-menu {
    bottom: auto;
    top: calc(100% + 12px);
    right: 0;
    left: auto;
    transform-origin: top right;
    animation: dropdownPopDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.omni-dropdown-menu.active {
    display: flex;
}

.omni-dropdown-item {
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.omni-dropdown-item:hover {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
    padding-left: 18px;
}

.omni-dropdown-item.active {
    background: var(--accent);
    color: white;
}

@keyframes dropdownPopUp {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes dropdownPopDown {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* -- CHAT TOOLBELT -- */
.chat-toolbelt {
    display: flex;
    gap: 10px;
    padding: 0 15px 10px;
    animation: slideInDown 0.3s ease-out;
}

.toolbelt-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 6px 12px;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbelt-btn:hover {
    background: rgba(108, 92, 231, 0.1);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.toolbelt-select {
    background: rgba(0, 0, 0, 0.3);
    color: var(--accent);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    font-size: 0.8rem;
    padding: 4px 8px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.toolbelt-select:hover {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
}

/* 🈂️ TOOLBELT DROPDOWN SPECIALIZATION */
.omni-dropdown.toolbelt-style {
    min-width: 130px;
    margin: 0;
}

.omni-dropdown.toolbelt-style .omni-dropdown-trigger {
    padding: 5px 12px;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    justify-content: center;
}

.omni-dropdown.toolbelt-style .omni-dropdown-menu {
    bottom: calc(100% + 10px);
    top: auto; /* Pop UP in toolbelt */
    max-height: 300px;
    overflow-y: auto;
}

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -- SIDEBAR FOOTER -- */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-glass);
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-btn {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-footer-btn.pwa-btn {
    background: rgba(108, 92, 231, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar-footer-btn.pwa-btn:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.4);
}

.sidebar-footer-btn.logout-btn {
    background: rgba(255, 100, 100, 0.05);
    border-color: rgba(255, 100, 100, 0.2);
    color: #ff7675;
}

.sidebar-footer-btn.logout-btn:hover {
    background: #ff7675;
    color: white;
    box-shadow: 0 0 15px rgba(255, 118, 117, 0.3);
}

.header-persona-name {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.9;
}

/* -- PWA & MOBILE SAFE AREAS -- */
.chat-input-container {
    padding-bottom: env(safe-area-inset-bottom, 12px) !important;
}

/* 📱 MOBILE OPTIMIZATIONS for Omni-Dropdowns */
@media (max-width: 768px) {
    #intentText, #dropdownActivePersona {
        display: none;
    }
    .header-left {
        flex: 1 !important;
    }
    .header-right {
        flex: 0 0 auto !important;
    }
    #internetStatusWrapper {
        padding: 4px 6px !important;
    }
    .omni-dropdown-trigger {
        padding: 8px 10px;
        min-width: 40px;
        justify-content: center;
    }
    .omni-dropdown {
        margin-right: 8px;
    }
    .omni-dropdown-menu {
        min-width: 180px;
    }
}

/* -- ADMIN CITIZENS DASHBOARD REFINEMENTS -- */
.admin-user-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s ease;
}
.admin-user-row:hover { background: rgba(255,255,255,0.02); }

.admin-td-main, .admin-td-stats, .admin-td-actions { padding: 12px 15px; }

.admin-user-identity { display: flex; flex-direction: column; gap: 4px; }
.name-online-group { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; }
.user-email-text { font-size: 0.75rem; opacity: 0.6; }
.user-storage-text { font-size: 0.65rem; color: var(--accent); font-weight: 700; margin-top: 2px; }

.admin-badge { font-size: 0.55rem; background: var(--accent); padding: 1px 4px; border-radius: 4px; }
.online-pulse-dot { width: 8px; height: 8px; background: #55efc4; border-radius: 50%; box-shadow: 0 0 8px #55efc4; animation: pulse 2s infinite; }

.admin-stats-group { display: flex; flex-direction: column; gap: 8px; }
.stats-counts { font-size: 0.7rem; opacity: 0.5; letter-spacing: 0.3px; }
.limit-setting { 
    display: flex; align-items: center; justify-content: space-between; 
    gap: 10px; font-size: 0.75rem; color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.02); padding: 4px 8px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}
.admin-limit-input { 
    width: 50px; background: rgba(0,0,0,0.3); border: 1px solid var(--border-glass); 
    color: var(--accent); border-radius: 6px; padding: 3px 6px; 
    font-weight: 700; text-align: center; outline: none;
    transition: all 0.2s ease;
}
.admin-limit-input:focus { border-color: var(--accent); box-shadow: 0 0 10px rgba(108, 92, 231, 0.2); }

.status-pill { font-size: 0.6rem; font-weight: 800; padding: 3px 10px; border-radius: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.status-pill.active { background: rgba(85, 239, 196, 0.1); color: #55efc4; }
.status-pill.pending { background: rgba(255, 234, 167, 0.1); color: #ffeaa7; }
.status-pill.banned { background: rgba(255, 118, 117, 0.1); color: #ff7675; }

.admin-btn-group { display: flex; gap: 8px; justify-content: flex-end; }
.admin-action-btn { border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 0.75rem; transition: 0.2s; border: 1px solid transparent; background: rgba(255,255,255,0.05); color: #fff; }
.admin-action-btn:hover { transform: translateY(-1px); }
.verify-btn { border-color: #55efc4; color: #55efc4; background: rgba(85, 239, 196, 0.1); }
.ban-btn { border-color: #ff7675; color: #ff7675; background: rgba(255, 118, 117, 0.1); }
.ban-btn.is-banned { border-color: #55efc4; color: #55efc4; background: rgba(85, 239, 196, 0.1); }
.delete-btn { border-color: #d63031; color: #ff7675; background: rgba(214, 48, 49, 0.1); }

@media (max-width: 600px) {
    #adminUsersTableBody tr { display: flex; flex-direction: column; padding: 15px; border-bottom: 2px solid rgba(255,255,255,0.05); }
    .admin-td-main, .admin-td-stats, .admin-td-actions { padding: 0; }
    .admin-td-stats { margin: 12px 0; }
    .admin-btn-group { justify-content: flex-start; }
}
/* -- WORKSPACE ENHANCEMENTS -- */
.tree-node {
    margin-left: 12px;
    position: relative;
}
.tree-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    gap: 8px;
    justify-content: flex-start; /* FORCE LEFT ALIGN */
    text-align: left;
}
.tree-arrow {
    font-size: 0.6rem;
    width: 12px;
    opacity: 0.5;
    transition: transform 0.2s ease;
    display: inline-block;
}
.tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.tree-item.selected {
    background: rgba(108, 92, 231, 0.15) !important;
    border: 1px solid rgba(108, 92, 231, 0.3);
}
.tree-item-content {
    flex: 1;
    overflow: hidden;
}
.tree-item-btn {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    text-align: left;
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 🛠️ Context Menu Style */
.context-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(20, 22, 38, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    min-width: 160px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: dropdownPopDown 0.2s ease-out;
}
.context-menu-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.context-menu-item:hover {
    background: rgba(108, 92, 231, 0.2);
    color: white;
}
.context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 4px 0;
}

/* Dragging visual */
.tree-item.dragging {
    opacity: 0.5;
    background: var(--accent);
}
.tree-item.drag-over {
    background: rgba(0, 184, 148, 0.1);
    border: 1px dashed #00b894;
}
