:root {
    --primary: #00AA00;
    --primary-glow: rgba(0, 170, 0, 0.4);
    --primary-dim: rgba(0, 170, 0, 0.05);
    --bg-dark: #050505;
    --bg-card: #0c0c0c;
    --bg-sidebar: #080808;
    --bg-header: rgba(5, 5, 5, 0.9);
    --text-white: #FFFFFF;
    --text-gray: #A1A1AA;
    --border: rgba(0, 170, 0, 0.2);
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body.dashboard-body {
    background: var(--bg-dark);
    color: var(--text-white);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 280px 1fr;
    grid-template-rows: 80px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* --- Header --- */
.dashboard-header {
    grid-area: header;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
}

.logo-area {
    display: flex;
    flex-direction: column;
}

.logo-glow {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.system-status {
    font-size: 0.7rem;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot.online {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--primary);
}

.search-container {
    flex: 0 1 500px;
    position: relative;
}

.search-container i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
}

.search-container input {
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    padding: 12px 45px 12px 20px;
    border-radius: 50px;
    color: white;
    outline: none;
    transition: var(--transition);
}

.search-container input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-dim);
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.usage-meter {
    background: rgba(255,255,255,0.05);
    padding: 10px 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.usage-meter span {
    font-size: 0.8rem;
    font-weight: 700;
}

.usage-meter .progress-bar {
    width: 100%;
    height: 4px;
    background: #222;
    border-radius: 2px;
    overflow: hidden;
}

.usage-meter #usageProgress {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
}

.plan-tag {
    color: var(--primary);
    font-size: 0.6rem !important;
}

/* --- Sidebar --- */
.dashboard-sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    padding: 30px 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.nav-item {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-gray);
    padding: 15px 20px;
    text-align: right;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
}

.nav-item i {
    width: 20px;
    color: var(--primary);
}

.nav-item:hover, .nav-item.active {
    background: var(--primary-dim);
    color: white;
}

.pro-upgrade-card {
    background: linear-gradient(135deg, #004400, #000);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--primary);
}

.pro-upgrade-card h4 {
    margin-bottom: 10px;
}

.pro-upgrade-card p {
    font-size: 0.8rem;
    color: #ccc;
    margin-bottom: 15px;
}

/* --- Main Content --- */
.main-content {
    grid-area: main;
    overflow-y: auto;
    padding: 30px;
    background: radial-gradient(circle at top left, #0a0a0a, #050505);
}

.infra-stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-item {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.tool-tile {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.tool-tile:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    background: #111;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.tile-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.tile-icon {
    font-size: 2rem;
    color: var(--primary);
}

.id-tag {
    color: var(--text-gray);
    font-size: 0.8rem;
}

.tile-name {
    margin-bottom: 12px;
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    transition: var(--transition);
}

.tool-tile:hover .tile-name {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.tile-desc {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.tile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-tag {
    background: var(--primary-dim);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}

.launch-btn {
    background: var(--primary);
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

/* --- Runtime Overlay --- */
.runtime-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.runtime-window {
    background: #080808;
    width: 100%;
    max-width: 1000px;
    height: 80vh;
    border-radius: 25px;
    border: 1px solid var(--primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
}

.window-header {
    padding: 20px 30px;
    background: #111;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.interactive-area {
    flex: 1;
    overflow: hidden;
    background: #000;
}

/* --- Tool Interface Styles --- */
.chat-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.msg-stream {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.msg {
    padding: 15px 20px;
    border-radius: 15px;
    max-width: 80%;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

.msg.ai {
    background: #151515;
    align-self: flex-start;
    border-right: 3px solid var(--primary);
    border-radius: 15px 15px 15px 0;
}

.msg.user {
    background: var(--primary-dim);
    align-self: flex-end;
    border-left: 3px solid var(--primary);
    border-radius: 15px 15px 0 15px;
}

.chat-input-area {
    padding: 20px 30px;
    background: #111;
    display: flex;
    gap: 15px;
    border-top: 1px solid var(--border);
}

.chat-input-area textarea {
    flex: 1;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    padding: 15px;
    height: 60px;
    resize: none;
    outline: none;
    transition: var(--transition);
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
}

.chat-input-area button {
    width: 60px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.chat-input-area button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-glow);
}
.image-interface {
    height: 100%;
    display: grid;
    grid-template-columns: 350px 1fr;
    background: #000;
}

.image-control {
    padding: 40px;
    background: #080808;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.image-control h3 {
    font-size: 1.4rem;
    color: var(--primary);
}

.image-control p {
    font-size: 0.9rem;
    color: var(--text-gray);
    margin-bottom: 10px;
}

.image-control textarea {
    width: 100%;
    height: 150px;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    padding: 15px;
    resize: none;
    outline: none;
    font-family: inherit;
}

.image-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: radial-gradient(circle at center, #111, #000);
    position: relative;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

.image-preview .placeholder {
    color: var(--text-gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.image-preview .placeholder i {
    font-size: 4rem;
    opacity: 0.2;
}

/* --- Code Editor Interface --- */
.code-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.code-editor-header {
    background: #111;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.code-editor-header span {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--primary);
}

.code-editor-header button {
    background: var(--primary);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
}

.code-editor {
    background: #050505;
    color: #d4d4d4;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    padding: 20px;
    border: none;
    border-left: 1px solid var(--border);
    resize: none;
    outline: none;
    line-height: 1.5;
}

.code-preview {
    background: white;
    border-radius: 0;
    overflow: hidden;
}

.code-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- Dashboard Layout Responsiveness --- */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 15px;
}

@media (max-width: 1024px) {
    body.dashboard-body {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        position: fixed;
        top: 80px;
        right: -300px;
        width: 280px;
        height: calc(100vh - 80px);
        z-index: 99;
        transition: var(--transition);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .dashboard-sidebar.active {
        right: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .search-container {
        flex: 1;
        margin: 0 20px;
    }

    .user-controls {
        gap: 10px;
    }

    .usage-meter {
        display: none; /* Hide on small headers */
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 0 15px;
        flex-wrap: wrap;
        height: auto;
        padding-bottom: 10px;
    }

    .logo-area {
        width: 100%;
        justify-content: space-between;
        padding: 15px 0;
    }

    .search-container {
        width: 100%;
        position: relative;
        top: 0;
        left: 0;
        margin: 0 0 10px 0;
    }

    .search-container.active {
        display: block;
    }

    .infra-stats-bar {
        grid-template-columns: 1fr;
    }

    .runtime-overlay {
        padding: 0;
    }

    .runtime-window {
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    .window-header {
        padding: 15px;
    }

    /* Tool Interface Specifics */
    .image-interface {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        overflow-y: auto;
    }

    .image-control {
        padding: 20px;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }

    .code-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .msg {
        max-width: 95%;
    }

    .chat-input-area {
        padding: 10px 15px;
    }
}

/* --- Refined Tool Runtime CSS --- */
.runtime-footer {
    padding: 15px 30px;
    background: #050505;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.server-logs {
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    color: #444;
}

.tool-specs {
    display: flex;
    gap: 20px;
    font-size: 0.7rem;
    color: var(--text-gray);
}

/* Animations */
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

[lang="en"] .dashboard-sidebar, [lang="de"] .dashboard-sidebar {
    right: auto;
    left: -300px;
    border-right: 1px solid var(--border);
    border-left: none;
}

[lang="en"] .dashboard-sidebar.active, [lang="de"] .dashboard-sidebar.active {
    left: 0;
}
