/* Design System & Variables */
:root {
    --bg-primary: #0a0813;
    --bg-secondary: rgba(18, 14, 33, 0.7);
    --border-color: rgba(138, 92, 246, 0.2);
    --border-glow: rgba(138, 92, 246, 0.15);
    
    --text-primary: #f3f1fe;
    --text-secondary: #a78bfa;
    --text-muted: #6d589d;
    
    --accent-purple: #8b5cf6;
    --accent-blue: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Background Glow Effects */
.glow-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

/* Main Container */
.app-container {
    display: flex;
    max-width: 1400px;
    height: 94vh;
    margin: 3vh auto;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5),
                0 0 20px 2px var(--border-glow);
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: rgba(10, 8, 19, 0.4);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-icon {
    font-size: 24px;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.6));
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(25, 20, 48, 0.3);
    margin-bottom: 24px;
}

.avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 16px;
}

.avatar-glow {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 98px;
    height: 98px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    opacity: 0.8;
    filter: blur(4px);
    animation: rotateGlow 6s linear infinite;
}

.avatar-inner {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: #141125;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.05);
}

.avatar-inner i {
    font-size: 36px;
    color: var(--text-primary);
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.profile-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-family: monospace;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-green);
    letter-spacing: 1px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-green);
}

.pulsing {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}

/* System Stats */
.system-stats {
    flex-grow: 1;
}

.stats-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(138, 92, 246, 0.08);
}

.stat-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label i {
    font-size: 12px;
    opacity: 0.7;
}

.stat-value {
    font-weight: 500;
    font-family: monospace;
}

.text-glow {
    color: var(--text-primary);
    text-shadow: 0 0 6px rgba(167, 139, 250, 0.5);
}

.text-green {
    color: var(--accent-green);
}

.sidebar-actions {
    margin-top: 16px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
}

.btn-secondary {
    background: rgba(138, 92, 246, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(138, 92, 246, 0.2);
    color: var(--text-primary);
    border-color: rgba(138, 92, 246, 0.5);
    box-shadow: 0 0 10px 1px rgba(138, 92, 246, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #9061f9, #8b5cf6);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.5);
}

/* Chat Area Styling */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: rgba(10, 8, 19, 0.15);
}

.chat-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 8, 19, 0.3);
}

.header-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Messages Container */
.messages-container {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Custom Scrollbar */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(138, 92, 246, 0.2);
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 92, 246, 0.4);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-weight: 700;
    flex-shrink: 0;
    font-size: 14px;
    box-shadow: 0 0 10px rgba(138, 92, 246, 0.3);
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sender-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-text {
    padding: 12px 16px;
    border-radius: 0 14px 14px 14px;
    background: rgba(25, 20, 48, 0.4);
    border: 1px solid rgba(138, 92, 246, 0.1);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

/* User Message specific styling */
.message.user-msg {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.user-msg .message-avatar {
    background: linear-gradient(135deg, var(--accent-blue), #0891b2);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.message.user-msg .sender-name {
    align-self: flex-end;
    color: var(--accent-blue);
}

.message.user-msg .message-text {
    border-radius: 14px 0 14px 14px;
    background: rgba(6, 182, 212, 0.08);
    border-color: rgba(6, 182, 212, 0.2);
}

/* System messages */
.message.system-msg {
    max-width: 100%;
    align-self: center;
    margin: 10px 0;
}

.message.system-msg .message-content {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(138, 92, 246, 0.15);
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 12px;
    font-family: monospace;
    color: var(--text-muted);
}

/* Inner action tags in model answers (e.g. *(looks side ways)*) */
.action-tag {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.75;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Chat Input Footer */
.chat-footer {
    padding: 24px;
    background: rgba(10, 8, 19, 0.4);
    border-top: 1px solid var(--border-color);
}

.chat-input-container {
    display: flex;
    gap: 12px;
    background: rgba(25, 20, 48, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    transition: all var(--transition-speed);
}

.chat-input-container:focus-within {
    border-color: rgba(138, 92, 246, 0.6);
    box-shadow: 0 0 14px rgba(138, 92, 246, 0.3);
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 14px;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    padding: 0;
    flex-shrink: 0;
}

/* Animations */
@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 900px) {
    .app-container {
        height: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .brand {
        margin-bottom: 0;
    }
    
    .profile-card {
        flex-direction: row;
        gap: 10px;
        margin-bottom: 0;
        padding: 4px 8px;
        background: transparent;
        border: none;
    }
    
    .avatar-container {
        width: 36px;
        height: 36px;
        margin-bottom: 0;
    }
    
    .avatar-glow {
        width: 42px;
        height: 42px;
        top: -3px;
        left: -3px;
    }
    
    .avatar-inner {
        width: 32px;
        height: 32px;
    }
    
    .profile-name {
        font-size: 15px;
    }
    
    .profile-title,
    .system-stats {
        display: none;
    }
    
    .status-badge {
        padding: 3px 6px;
        font-size: 8px;
    }
    
    .sidebar-actions {
        margin-top: 0;
        width: auto;
    }
    
    .sidebar-actions #btn-reset span {
        display: none;
    }
    
    .sidebar-actions #btn-reset {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .chat-area {
        height: 0;
        flex-grow: 1;
    }
    
    .chat-header {
        display: none;
    }
    
    .messages-container {
        padding: 16px;
        gap: 16px;
    }
    
    .message {
        max-width: 90%;
        gap: 10px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .message-text {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .chat-footer {
        padding: 12px 16px;
        flex-shrink: 0;
    }
    
    .chat-input-container {
        padding: 4px;
    }
    
    #chat-input {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .btn-send {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .brand {
        display: none;
    }
}
