/* FEZ UI: Terminal Uplink Core Styles */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=JetBrains+Mono:wght@700&display=swap');

:root {
    --fez-stone-950: #0c0a09;
    --fez-stone-900: #1c1917;
    --fez-stone-800: #292524;
    --fez-stone-700: #44403c;
    --fez-yellow-600: #ca8a04;
    --fez-purple-600: #9333ea;
    --fez-emerald-600: #059669;
    --fez-red-600: #dc2626;
    --sidebar-width: 260px;
}

.fez-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fez-stone-500);
}

body {
    background-color: var(--fez-stone-950);
    color: #e7e5e4;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    overflow: hidden;
    height: 100vh;
    display: flex;
}

/* Sidebar Styles */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100; /* Higher z-index for mobile overlap */
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    #sidebar.sidebar-open {
        transform: translateX(0);
    }

    #main-content {
        width: 100vw;
    }
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(68, 64, 60, 0.5);
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid rgba(68, 64, 60, 0.8);
    color: #e7e5e4;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

#conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    padding: 0.75rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #a8a29e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    group: relative;
}

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

.conversation-actions {
    display: none;
    gap: 0.5rem;
}

.conversation-item:hover .conversation-actions, .conversation-item.active .conversation-actions {
    display: flex;
}

.action-btn {
    opacity: 0.5;
    transition: opacity 0.2s;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.action-btn * {
    pointer-events: none;
}

.action-btn:hover {
    opacity: 1;
}

.action-btn.delete:hover {
    color: var(--fez-red-600);
}

/* Portal-style Buttons */
.portal-button {
    font-weight: 800;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
    border: none;
    cursor: pointer;
    width: 100%;
    display: block;
    text-align: center;
}

.portal-button-primary {
    background-color: var(--fez-yellow-600);
    color: white;
    box-shadow: 0 4px 12px rgba(202, 138, 4, 0.3);
}

.portal-button-primary:hover {
    background-color: #eab308; /* yellow-500 */
    transform: translateY(-1px);
}

.portal-button-primary:active {
    transform: translateY(0);
}

/* Portal-style Inputs */
.portal-input-container {
    margin-bottom: 1rem;
    text-align: left;
}

.portal-input-label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fez-stone-500);
    margin-left: 0.25rem;
    margin-bottom: 0.25rem;
}

.portal-input {
    width: 100%;
    background-color: var(--fez-stone-950);
    border: 1px solid var(--fez-stone-800);
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    color: white;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.portal-input:focus {
    border-color: var(--fez-yellow-600);
}

/* Typography Enhancements */
.fez-logo-text {
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -0.05em;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--fez-stone-500);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: rgba(202, 138, 4, 0.1);
    color: var(--fez-yellow-600);
}

/* Admin Table */
tr.admin-row {
    border-bottom: 1px solid var(--fez-stone-900);
    transition: background 0.2s;
}

tr.admin-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.level-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.level-5 { background: var(--fez-purple-600); color: white; }
.level-1 { background: var(--fez-stone-800); color: var(--fez-stone-400); }

.status-badge {
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--fez-red-600);
}

/* Status Indicator Pulse */
.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fez-stone-700);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.status-indicator.active {
    background: var(--fez-emerald-600);
    box-shadow: 0 0 8px var(--fez-emerald-600);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

.conversation-item:hover, .conversation-item.active {
    background: var(--fez-stone-800);
    color: #e7e5e4;
}

/* Main Chat Area */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
}

.message-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    gap: 1.5rem;
}

.message-wrapper.user {
    /* Optional differentiation */
}

.message-wrapper.assistant {
    background: rgba(255, 255, 255, 0.02);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 10px;
    flex-shrink: 0;
}

.avatar.user { background: var(--fez-emerald-600); }
.avatar.assistant { background: var(--fez-purple-600); }

.message-content {
    flex: 1;
    line-height: 1.6;
    font-size: 0.95rem;
}

.message-content p { margin: 0 0 1rem 0; }
.message-content p:last-child { margin-bottom: 0; }

/* Input Area */
.input-container {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.input-box {
    position: relative;
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    align-items: flex-end;
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e7e5e4;
    resize: none;
    max-height: 200px;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

#send-btn {
    background: transparent;
    border: none;
    color: #a8a29e;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: color 0.2s;
}

#send-btn:hover {
    color: var(--fez-yellow-600);
}

#send-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Glass Effects */
.glass-panel {
    background: rgba(28, 25, 23, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(68, 64, 60, 0.5);
}

.glass-panel-heavy {
    background: rgba(12, 10, 9, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(68, 64, 60, 0.6);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--fez-stone-800);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fez-stone-700);
}

/* --- V2.0 ADVANCED AI UI --- */
.thought-process {
    background: var(--fez-stone-900);
    border: 1px solid var(--fez-stone-800);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

.thought-process summary {
    color: var(--fez-stone-500);
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
}

.thought-list {
    margin-top: 0.5rem;
    color: var(--fez-stone-400);
    border-left: 2px solid var(--fez-stone-800);
    padding-left: 0.75rem;
}

.thought-item {
    margin-bottom: 0.4rem;
}

.tool-calls {
    background: rgba(147, 51, 234, 0.1);
    border-left: 3px solid var(--fez-purple-600);
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--fez-purple-400);
}

/* --- TERMINAL UPLINK UI --- */
#terminal-container {
    padding: 10px;
    height: 100%;
    width: 100%;
}

.xterm-viewport::-webkit-scrollbar {
    width: 8px;
}

.xterm-viewport::-webkit-scrollbar-track {
    background: var(--fez-stone-950);
}

.xterm-viewport::-webkit-scrollbar-thumb {
    background: var(--fez-stone-800);
    border-radius: 4px;
}

.xterm-viewport::-webkit-scrollbar-thumb:hover {
    background: var(--fez-stone-700);
}

/* Utilities */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
