:root {
    --bg-dark: #0f111a;
    --sidebar-bg: #141724;
    --card-bg: rgba(26, 29, 45, 0.7);
    --accent-purple: #9d50bb;
    --accent-blue: #6e8efb;
    --text-main: #e0e0e0;
    --text-dim: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.1);
    --gradient-main: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
}

.brand {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    margin-bottom: 3rem;
    font-size: 1.5rem;
    font-weight: 700;
    gap: 12px;
}

.logo-box {
    width: 40px;
    height: 40px;
    background: var(--gradient-main);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-menu {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 12px;
    border-left: 3px solid transparent;
}

.nav-item i {
    font-size: 1.2rem;
    width: 20px;
}

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

.nav-item.active {
    color: white;
    background: linear-gradient(90deg, rgba(110, 142, 251, 0.1) 0%, transparent 100%);
    border-left-color: #6e8efb;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.pulse {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(0, 255, 136, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

/* Main Content */
.main-content {
    overflow-y: auto;
    padding: 2rem;
    background: radial-gradient(circle at top right, rgba(110, 142, 251, 0.05), transparent);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-bar h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.server-port {
    font-size: 0.8rem;
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    padding: 4px 12px;
    border-radius: 100px;
    font-weight: 600;
}

.avatar {
    width: 40px;
    height: 40px;
    background: #252839;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
}

/* Dashboard Widgets */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    backdrop-filter: blur(15px);
    transition: transform 0.3s ease, border-color 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(110, 142, 251, 0.4);
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    background: rgba(110, 142, 251, 0.2);
    color: var(--accent-blue);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
}

.metric-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.metric-label span:last-child {
    color: var(--text-dim);
    font-weight: 600;
}

.icon-purple { color: #a777e3; }
.icon-blue { color: #6e8efb; }
.icon-green { color: #00ff88; }
.icon-orange { color: #ff9f43; }

.content-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Activity Feed */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    display: flex;
    gap: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.activity-details p {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.activity-details span {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Tool Generation Card */
.tool-generation-card {
    margin-bottom: 30px;
    background: linear-gradient(145deg, rgba(26, 29, 45, 0.9), rgba(15, 17, 26, 0.9));
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.card-header h3 {
    font-size: 1.3rem;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.gen-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gen-form textarea {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
}

.gen-form textarea:focus {
    border-color: var(--accent-purple);
    outline: none;
}

.btn-primary {
    background: var(--gradient-main);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(110, 142, 251, 0.3);
}

#gen-status {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #00ff88;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,255,136,0.3);
    border-top-color: #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tool Registry View */
/* Utility classes */
.hidden {
    display: none !important;
}

.tool-search {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.tool-search input {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 10px;
    color: white;
    font-family: inherit;
}

.btn-refresh {
    background: var(--gradient-main);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-5px);
    border-color: #6e8efb;
}

.tool-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.tool-type {
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}

.type-internal { background: rgba(110, 142, 251, 0.2); color: #6e8efb; }
.type-generated { background: rgba(0, 255, 136, 0.2); color: #00ff88; }

.tool-card h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.tool-card p {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Terminal Styles */
.terminal {
    background: #000;
    padding: 0;
    font-family: 'Fira Code', monospace;
}

.terminal-header {
    background: #1a1a1a;
    padding: 10px 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.dots { display: flex; gap: 6px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; }
.dots span:nth-child(1) { background: #ff5f56; }
.dots span:nth-child(2) { background: #ffbd2e; }
.dots span:nth-child(3) { background: #27c93f; }

.terminal-body {
    padding: 15px;
    height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

.log-info { color: #00ff88; }
.log-warn { color: #ffbd2e; }
.log-error { color: #ff5f56; }

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dim);
}

.form-group input, .form-group select {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

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

.modal-content {
    width: 550px;
    max-width: 95%;
    background: var(--sidebar-bg);
    padding: 2rem;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-header h3 {
    font-size: 1.4rem;
    color: white;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    position: relative;
    z-index: 2001;
    padding: 10px;
    margin: -10px;
    transition: color 0.2s;
}

.close-modal:hover {
    color: white;
}

#test-args {
    width: 100%;
    height: 150px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    color: white;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-top: 10px;
}

#test-args:focus {
    border-color: var(--accent-blue);
    outline: none;
}

#test-result-box {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#test-result-box pre {
    background: #000;
    padding: 15px;
    border-radius: 8px;
    color: #00ff88;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
    margin-top: 10px;
}

.btn-run-tool {
    margin-top: 15px;
    width: 100%;
    background: rgba(110, 142, 251, 0.1);
    border: 1px solid rgba(110, 142, 251, 0.4);
    color: #6e8efb;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-run-tool:hover {
    background: #6e8efb;
    color: white;
}

.btn-code {
    margin-top: 8px;
    width: 100%;
    background: rgba(167, 119, 227, 0.1);
    border: 1px solid rgba(167, 119, 227, 0.4);
    color: #a777e3;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-code:hover {
    background: #a777e3;
    color: white;
}

/* Code Editor */
.code-editor-card pre {
    background: #0d1117;
    padding: 2rem;
    border-radius: 12px;
    color: #cad1d8;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    border: 1px solid var(--border-color);
}

/* File Helper */
.file-test-helper {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px dashed var(--border-color);
}

.file-input-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.file-input-group input {
    flex: 1;
    font-size: 0.8rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 6px;
    cursor: pointer;
}

.small-text {
    font-size: 0.75rem;
    color: #00ff88;
    margin-top: 8px;
    word-break: break-all;
}

.result-link {
    display: inline-block;
    margin-top: 10px;
    color: #00ff88;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
}

/* API View Styles */
.api-docs-card {
    max-width: 900px;
}

.api-content {
    margin-top: 20px;
}

.api-section {
    padding: 15px 0;
}

.api-endpoint {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

.api-endpoint code {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
    color: #6e8efb;
    font-size: 1.1rem;
    font-weight: 600;
}

.method {
    font-size: 0.75rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    color: white;
}

.method.post { background: #9d50bb; }
.method.get { background: #00ff88; color: #000; }

.api-section p {
    color: var(--text-dim);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.api-section pre {
    background: #000;
    padding: 15px;
    border-radius: 10px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.api-divider {
    height: 1px;
    background: var(--border-color);
    margin: 15px 0;
}

.api-section .small-text {
    margin-top: 5px;
    font-family: monospace;
}

::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}
