:root {
    /* Hacker + Anime Color Scheme */
    --bg-primary: #0a0e1a;
    --bg-secondary: #131825;
    --bg-tertiary: #1a1f2e;
    --text-primary: #00ff88;
    --text-secondary: #e0e0e0;
    --text-muted: #8a8a8a;
    --cyan: #00ffff;
    --purple: #bf00ff;
    --pink: #ff00aa;
    --green: #00ff88;
    --yellow: #ffff00;
    --red: #ff0066;
    --border: #2a3441;
    --shadow: rgba(0, 255, 136, 0.1);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #00ff88 0%, #00ffff 100%);
}

/* Light theme */
.light-theme {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: #cbd5e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Share Tech Mono', monospace;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 136, 0.03) 2px,
            rgba(0, 255, 136, 0.03) 4px
        );
    pointer-events: none;
    z-index: 1;
}

/* Header */
.main-header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--green);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1000;
    box-shadow: 0 2px 20px var(--shadow);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-circuits {
    width: 100px;
    height: 30px;
    opacity: 0.8;
}

.circuit-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.zero { color: var(--text-muted); }
.hi { color: var(--cyan); }
.tek { color: var(--text-muted); }

.header-controls {
    display: flex;
    gap: 1rem;
}

.theme-toggle, .menu-toggle {
    background: transparent;
    border: 2px solid var(--green);
    color: var(--green);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.theme-toggle:hover, .menu-toggle:hover {
    background: var(--green);
    color: var(--bg-primary);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

/* App Container */
.app-container {
    display: flex;
    height: calc(100vh - 70px);
    position: relative;
    z-index: 10;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--gradient-2);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-family: 'Orbitron', sans-serif;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.4);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-title {
    color: var(--cyan);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.history-item:hover {
    border-color: var(--cyan);
    background: rgba(0, 255, 255, 0.1);
}

.history-item.active {
    border-color: var(--green);
    background: rgba(0, 255, 136, 0.1);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-btn {
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.sidebar-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--cyan);
    color: var(--cyan);
}

.sidebar-btn.danger:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(255, 0, 102, 0.1);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Model Selector Bar */
.model-selector-bar {
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.model-search-container {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.model-search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.model-search {
    width: 100%;
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.model-search:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.model-selector {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    min-width: 200px;
    cursor: pointer;
    transition: all 0.3s;
}

.model-selector:focus {
    outline: none;
    border-color: var(--cyan);
}

.token-counter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--yellow);
    font-weight: bold;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    position: relative;
}

.cyber-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 255, 136, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 136, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 10s linear infinite;
    opacity: 0.3;
}

@keyframes grid-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: var(--green);
    position: relative;
    text-shadow: 
        2px 2px 0 var(--cyan),
        -2px -2px 0 var(--pink);
    animation: glitch 2s infinite;
}

@keyframes glitch {
    0%, 100% { text-shadow: 2px 2px 0 var(--cyan), -2px -2px 0 var(--pink); }
    25% { text-shadow: -2px 2px 0 var(--pink), 2px -2px 0 var(--cyan); }
    50% { text-shadow: 2px -2px 0 var(--cyan), -2px 2px 0 var(--pink); }
    75% { text-shadow: -2px -2px 0 var(--pink), 2px 2px 0 var(--cyan); }
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 500px;
}

.feature-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--cyan);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 255, 255, 0.2);
}

.feature-card i {
    font-size: 2rem;
    color: var(--purple);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--gradient-1);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--gradient-2);
    color: var(--bg-primary);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.message-role {
    font-weight: bold;
    color: var(--cyan);
}

.message-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.message-text {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    line-height: 1.6;
}

.message.user .message-text {
    background: rgba(191, 0, 255, 0.1);
    border-color: var(--purple);
}

.message.assistant .message-text {
    background: rgba(0, 255, 136, 0.05);
    border-color: var(--green);
}

/* Input Container */
.input-container {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    resize: none;
    min-height: 50px;
    max-height: 150px;
    font-family: inherit;
    transition: all 0.3s;
}

.message-input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.send-btn {
    padding: 1rem 1.5rem;
    background: var(--gradient-2);
    border: none;
    border-radius: 12px;
    color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--cyan);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 255, 255, 0.3);
    animation: modalSlide 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-family: 'Orbitron', sans-serif;
    color: var(--cyan);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--red);
}

.modal-body {
    padding: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    color: var(--green);
    margin-bottom: 1rem;
    font-family: 'Orbitron', sans-serif;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.settings-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--cyan);
}

.api-key-input-container {
    position: relative;
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
}

.toggle-visibility:hover {
    color: var(--cyan);
}

.settings-slider {
    width: 100%;
    margin: 0.5rem 0;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--cyan);
}

.save-settings-btn {
    width: 100%;
    padding: 1rem;
    background: var(--gradient-2);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-family: 'Orbitron', sans-serif;
}

.save-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.4);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.cyber-loader {
    text-align: center;
}

.loader-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    color: var(--cyan);
    margin-bottom: 1rem;
    letter-spacing: 4px;
    animation: pulse 1s infinite;
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loader-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-2);
    animation: load 1.5s infinite;
}

@keyframes load {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 70px;
        height: calc(100vh - 70px);
        z-index: 999;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .model-selector-bar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .model-search-container {
        max-width: 100%;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .glitch {
        font-size: 2rem;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
    
    .logo-circuits {
        display: none;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--cyan);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--green);
}

/* Print Styles */
@media print {
    .sidebar,
    .model-selector-bar,
    .input-container,
    .main-header {
        display: none;
    }
    
    .messages-container {
        padding: 1rem;
        background: white;
        color: black;
    }
}
