:root {
    --bg-dark: #0A0E1A;
    --team-x-color: #00E5FF;
    --team-x-glow: rgba(0, 229, 255, 0.4);
    --team-y-color: #FF6D00;
    --team-y-glow: rgba(255, 109, 0, 0.4);
    --status-active: #00FF41;
    --status-busy: #FFD600;
    --status-idle: #FF3D00;
    --font-header: 'Rajdhani', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    --panel-bg: rgba(16, 22, 36, 0.85);
    --border-glow: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: var(--font-header);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Language & RTL Support */
[dir="rtl"] {
    font-family: 'Vazirmatn', sans-serif;
}

[dir="rtl"] .stats-container {
    text-align: left;
}

[dir="rtl"] .command-bar {
    clip-path: polygon(2% 0, 98% 0, 100% 100%, 0 100%);
}

[dir="rtl"] .status-indicator {
    left: 15px;
    right: auto;
}

[dir="rtl"] .panel-header {
    letter-spacing: 0;
}

[dir="rtl"] #log-feed div {
    border-left: none;
    border-right: 2px solid transparent;
    padding-left: 0;
    padding-right: 8px;
    animation: slide-in-log-rtl 0.3s forwards;
}

@keyframes slide-in-log-rtl {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.top-right-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

[dir="rtl"] .top-right-controls {
    align-items: flex-start;
}

.language-switcher {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #666;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: all 0.3s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.lang-btn.active {
    background: var(--team-x-color);
    color: #000;
    border-color: var(--team-x-color);
    box-shadow: 0 0 10px var(--team-x-glow);
}

/* Background Effects */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.3;
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Layout */
.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
    z-index: 2;
    position: relative;
    gap: 10px;
}

/* Top Command Bar */
.command-bar {
    height: 80px;
    background: linear-gradient(to bottom, rgba(20, 30, 50, 0.9), rgba(10, 15, 25, 0.95));
    border: 1px solid var(--border-glow);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 25px;
    clip-path: polygon(0 0, 100% 0, 98% 100%, 2% 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.mission-info .label, .stats-container .label {
    color: #666;
    font-size: 0.7rem;
    letter-spacing: 2px;
    display: block;
}

.mission-info .value, .stats-container .value {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--team-x-color);
    text-shadow: 0 0 10px var(--team-x-glow);
}

.logo-container {
    text-align: center;
}

.logo {
    font-size: 2.5rem;
    letter-spacing: 8px;
    background: linear-gradient(to bottom, #fff, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255,255,255,0.4));
    animation: logo-pulse 4s infinite ease-in-out;
}

@keyframes logo-pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.stats-container {
    display: flex;
    justify-content: flex-end;
    gap: 30px;
    text-align: right;
}

/* Main Battlefield */
.battlefield {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 4px 1fr;
    gap: 10px;
    overflow: hidden;
}

.zone {
    background: rgba(10, 15, 25, 0.4);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
}

.team-label {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 3px;
}

.company-x .team-label { color: var(--team-x-color); text-shadow: 0 0 10px var(--team-x-glow); }
.company-y .team-label { color: var(--team-y-color); text-shadow: 0 0 10px var(--team-y-glow); }

.team-status {
    font-size: 0.8rem;
    color: #666;
    letter-spacing: 1px;
}

.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    overflow-y: auto;
    padding: 10px;
    perspective: 1000px;
}

/* Animated Divider */
.battlefield-divider {
    position: relative;
    background: rgba(255,255,255,0.05);
}

.battlefield-divider .beam {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
        transparent,
        var(--team-x-color) 20%, 
        var(--team-y-color) 80%,
        transparent);
    box-shadow: 0 0 15px var(--team-x-glow);
    animation: divider-pulse 2s infinite alternate;
}

@keyframes divider-pulse {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; box-shadow: 0 0 25px var(--team-x-glow); }
}

/* Agent Cards */
.agent-card-wrapper {
    width: 180px;
    height: 240px;
    perspective: 1000px;
    opacity: 0;
    transform: translateY(20px);
    animation: stagger-reveal 0.6s forwards;
}

@keyframes stagger-reveal {
    to { opacity: 1; transform: translateY(0); }
}

.agent-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.agent-card:hover {
    transform: rotateX(10deg) rotateY(10deg) translateZ(20px);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1A2234 0%, #0A0E1A 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    backface-visibility: hidden;
    clip-path: polygon(15% 0, 85% 0, 100% 15%, 100% 85%, 85% 100%, 15% 100%, 0 85%, 0 15%);
}

.company-x .card-face { border-color: rgba(0, 229, 255, 0.3); }
.company-y .card-face { border-color: rgba(255, 109, 0, 0.3); }

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.3s;
    opacity: 0.3;
}

.agent-card:hover .card-glow {
    opacity: 1;
    box-shadow: 0 0 30px var(--team-x-glow);
}

.company-y .agent-card:hover .card-glow {
    box-shadow: 0 0 30px var(--team-y-glow);
}

.role-badge {
    font-size: 0.6rem;
    letter-spacing: 1px;
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 10px;
    color: #888;
}

.progress-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 10px 0;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.05);
    stroke-width: 4;
}

.ring-fill {
    fill: none;
    stroke: var(--team-x-color);
    stroke-width: 6;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 5px var(--team-x-glow));
}

.company-y .ring-fill {
    stroke: var(--team-y-color);
    filter: drop-shadow(0 0 5px var(--team-y-glow));
}

.progress-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.status-indicator {
    position: absolute;
    top: 10px;
    right: 15px;
}

.status-dot {
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--status-active);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--status-active);
}

.status-dot.busy { background-color: var(--status-busy); box-shadow: 0 0 8px var(--status-busy); animation: pulse-amber 1s infinite; }
.status-dot.idle { background-color: var(--status-idle); box-shadow: 0 0 8px var(--status-idle); }
.status-dot.active { animation: pulse-green 1.5s infinite; }

@keyframes pulse-green {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

@keyframes pulse-amber {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.4; }
}

.hero-nameplate {
    width: 100%;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 10px;
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #eee;
}

.task-container {
    width: 100%;
    overflow: hidden;
    margin-top: 5px;
}

.task-marquee {
    white-space: nowrap;
    display: inline-block;
    animation: marquee 10s linear infinite;
}

.task-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: #666;
    text-transform: uppercase;
}

@keyframes marquee {
    from { transform: translateX(100%); }
    to { transform: translateX(-100%); }
}

/* Bottom Panels */
.bottom-panels {
    height: 180px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-glow);
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: rgba(255,255,255,0.03);
    padding: 5px 15px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #888;
}

.panel-content {
    flex: 1;
    padding: 10px 15px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #aaa;
    line-height: 1.4;
}

#log-feed div {
    margin-bottom: 4px;
    border-left: 2px solid transparent;
    padding-left: 8px;
    animation: slide-in-log 0.3s forwards;
}

@keyframes slide-in-log {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-time { color: #555; margin-right: 5px; }
.log-agent { color: var(--team-x-color); font-weight: 700; margin-right: 5px; }
.company-y .log-agent { color: var(--team-y-color); }

.intel-panel p {
    color: var(--status-active);
    opacity: 0.8;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}
