/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;500;600;700&display=swap');

/* CSS Variables */
:root {
    --rebel-primary: #00d9ff;
    --rebel-secondary: #006eff;
    --rebel-glow: rgba(0, 119, 255, 0.6);
    
    --empire-primary: #ff0000;
    --empire-secondary: #f56200;
    --empire-glow: rgba(255, 0, 0, 0.6);
    
    --contested-primary: #dc2626;
    --contested-secondary: #ef4444;
    --contested-glow: rgba(220, 38, 38, 0.6);
    
    --bg-space: #0a0a0f;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-panel: rgba(15, 23, 42, 0.95);
    --bg-card: rgba(30, 41, 59, 0.9);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(255, 107, 53, 0.3);
    
    --warning-color: #fbbf24;
    --success-color: #10b981;
    --danger-color: #ef4444;
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    overflow: hidden;
    font-family: 'Exo 2', sans-serif;
    background: var(--bg-space);
    color: var(--text-primary);
}
/* in your warmap.css, near the top */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
  z-index: 0;   /* <-- was -1, now 0 so it's above body/bg */
}
body > *:not(#starfield) {
  position: relative;
  z-index: 1;
}
/* Header */
.war-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-bottom: 2px solid var(--border-glow);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.war-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--rebel-primary);
    text-shadow: 0 0 10px var(--rebel-glow);
}

.nav-brand i {
    font-size: 2rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { 
        text-shadow: 0 0 5px var(--rebel-glow), 0 0 10px var(--rebel-glow);
    }
    50% { 
        text-shadow: 0 0 10px var(--rebel-glow), 0 0 20px var(--rebel-glow), 0 0 30px var(--rebel-glow);
    }
}

.nav-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.war-btn-small {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.war-btn-small:hover {
    background: var(--rebel-primary);
    border-color: var(--rebel-primary);
    box-shadow: 0 0 15px var(--rebel-glow);
    transform: translateY(-2px);
}

.back-btn {
    background: linear-gradient(135deg, var(--rebel-primary), var(--rebel-secondary));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--rebel-glow);
}

/* Main Layout - Moved closer to header */
.war-map-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    height: calc(100vh - 70px); /* Reduced from 80px to move content up */
    padding-top: 10px; /* Reduced from 80px to move content up */
    gap: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 1rem;
    margin-top: 0; /* Ensure no extra margin pushes it down */
}



/* Sidebars - Fixed scrolling and height */
.galaxy-sidebar, .planet-sidebar {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    height: 100%; /* Use full height of grid container */
    min-height: 0; /* Allow flexbox/grid to shrink */
}
/* Ensure content doesn't break out of sidebar */
.galaxy-sidebar > *, .planet-sidebar > * {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.galaxy-sidebar h2, .galaxy-sidebar h3 {
    font-family: 'Orbitron', sans-serif;
    color: var(--rebel-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.galaxy-sidebar h2 {
    font-size: 1.25rem;
    border-bottom: 2px solid var(--border-glow);
    padding-bottom: 0.5rem;
}

.galaxy-sidebar h3 {
    font-size: 1rem;
    margin-top: 2rem;
}

/* Faction Control */
.faction-control {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.faction > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.faction.rebel i { color: var(--rebel-primary); }
.faction.empire i { color: var(--empire-primary); }

.control-bar {
    background: var(--bg-darker);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.control-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.faction.rebel .control-fill {
    background: linear-gradient(90deg, var(--rebel-primary), var(--rebel-secondary));
    box-shadow: 0 0 10px var(--rebel-glow);
}

.faction.empire .control-fill {
    background: linear-gradient(90deg, var(--empire-primary), var(--empire-secondary));
    box-shadow: 0 0 10px var(--empire-glow);
}

.percentage {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Operations */
.operation-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.operation {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative; /* Needed for the ::before pseudo-element */
}

.operation:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.operation.urgent {
    border-color: var(--danger-color);
    background: linear-gradient(135deg, var(--bg-card), rgba(239, 68, 68, 0.1));
}

.operation.high {
    border-color: var(--warning-color);
    background: linear-gradient(135deg, var(--bg-card), rgba(251, 191, 36, 0.1));
}

.operation.medium {
    border-color: var(--success-color);
    background: linear-gradient(135deg, var(--bg-card), rgba(16, 185, 129, 0.1));
}

.operation.low {
    border-color: var(--text-muted);
    background: linear-gradient(135deg, var(--bg-card), rgba(100, 116, 139, 0.1));
}

.no-operations-panel {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.no-operations-panel i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-operations-panel h4 {
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.no-operations-panel p {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* News Feed */
.news-feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.news-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.3s ease;
}

.news-item:hover {
    border-color: var(--rebel-primary);
    transform: translateX(5px);
}

.news-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.news-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Galaxy Map */
.galaxy-map {
    position: relative;
    background: radial-gradient(ellipse at center, rgba(255, 107, 53, 0.05) 0%, transparent 70%);
    border-radius: 15px;
    overflow: hidden;
}

.map-controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.zoom-btn, .map-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.zoom-btn:hover, .map-btn:hover {
    background: var(--rebel-primary);
    border-color: var(--rebel-primary);
    box-shadow: 0 0 15px var(--rebel-glow);
    transform: scale(1.1);
}

@keyframes pulse-contested {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Star Map */
.star-map {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 600px;
    cursor: grab;
    transition: transform 0.3s ease;
}
.star-map.dragging {
  transition: none !important;
}
.star-map:active {
    cursor: grabbing;
}

/* Hyperspace Routes */
.hyperspace-routes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.route {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 1;
    stroke-dasharray: 5, 5;
    animation: route-flow 3s linear infinite;
}

@keyframes route-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 10; }
}

/* Planets */
.planet {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto; /* ← Explicitly add this */
    z-index: 10;
}

.planet:hover {
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 20;
}

.planet-glow {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: planet-pulse 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes planet-pulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.9;
    }
}
.faction-label {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.faction-label img {
    height: 18px;
    margin-right: 6px;
}
.planet-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;       /* remove the old bg-panel fill */
  border: 2px solid transparent; /* default, overridden per faction */
  box-shadow: none;              /* default, overridden per faction */
  transition: box-shadow 0.3s ease;
}
/* make your injected <img> fill that circle */
.planet-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.planet.rebel .planet-icon {
  border-color: var(--rebel-primary);
  box-shadow: 0 0 10px var(--rebel-glow);
}

.planet.empire .planet-icon {
  border-color: var(--empire-primary);
  box-shadow: 0 0 10px var(--empire-glow);
}
.planet.contested .planet-icon {
  border-color: var(--contested-primary);
  box-shadow: 0 0 10px var(--contested-glow);
}
.planet-name {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.planet:hover .planet-name {
    opacity: 1;
}

/* Battle Indicators */
.battle-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    z-index: 4;
    border: 2px solid var(--bg-panel);
}

.battle-indicator.active-battle {
    background: var(--contested-primary);
    animation: battle-flash 1s ease-in-out infinite;
}

.battle-indicator.rebel-victory {
    background: var(--rebel-primary);
}

.battle-indicator.empire-victory {
    background: var(--empire-primary);
}

.battle-indicator.contested {
    background: var(--warning-color);
    animation: contested-flash 2s ease-in-out infinite;
}

.battle-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--contested-primary);
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes battle-flash {
    0%, 100% { 
        box-shadow: 0 0 5px var(--contested-glow);
        opacity: 1;
    }
    50% { 
        box-shadow: 0 0 20px var(--contested-glow);
        opacity: 0.7;
    }
}

@keyframes contested-flash {
    0%, 100% { 
        background: var(--warning-color);
        box-shadow: 0 0 5px rgba(251, 191, 36, 0.6);
    }
    50% { 
        background: var(--contested-primary);
        box-shadow: 0 0 15px var(--contested-glow);
    }
}

@keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* Planet Details Sidebar */
.no-selection {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.no-selection i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-selection h3 {
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 1rem;
}

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

.planet-modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-panel);
    border: 2px solid var(--border-glow);
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

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

.modal-header h2 {
    font-family: 'Orbitron', sans-serif;
    color: var(--rebel-primary);
    text-shadow: 0 0 10px var(--rebel-glow);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.planet-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.planet-render {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--rebel-primary);   /* adjust per faction */
  box-shadow: 0 0 30px var(--rebel-glow);   /* adjust per faction */
  /* remove or keep the rotation if you like */
  animation: none;
}

@keyframes planet-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.planet-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 700;
}

.operation-details h3 {
    font-family: 'Orbitron', sans-serif;
    color: var(--rebel-primary);
    margin-bottom: 1rem;
}

.operation-status {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.operation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.action-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--rebel-primary), var(--rebel-secondary));
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--rebel-glow);
}

.action-btn.secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.action-btn.secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}


/* Responsive Design - Improved */
@media (max-width: 1200px) {
    .war-map-container {
        grid-template-columns: 250px 1fr 250px;
    }
}

@media (max-width: 992px) {
    .war-map-container {
        grid-template-columns: 200px 1fr 200px;
    }
    
    .galaxy-sidebar, .planet-sidebar {
        padding: 1rem;
    }
}
@media (max-width: 768px) {
    .war-map-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: calc(100vh - 70px); /* Updated to match main container */
    }
    
    .galaxy-sidebar, .planet-sidebar {
        height: auto;
        max-height: 250px; /* Increased from 200px */
        min-height: 150px;
    }
    
    /* Stack sidebars on mobile */
    .galaxy-sidebar {
        order: 1;
    }
    
    .galaxy-map {
        order: 2;
    }
    
    .planet-sidebar {
        order: 3;
    }
}

@media (max-width: 480px) {
    .war-map-container {
        padding: 70px 0.5rem 0.5rem; /* Updated from 80px to 70px */
        gap: 0.5rem;
    }
    
    .galaxy-sidebar, .planet-sidebar {
        padding: 0.75rem;
        max-height: 200px;
        min-height: 120px;
    }
    
    /* Smaller text on mobile for better fit */
    .galaxy-sidebar h2 {
        font-size: 1.1rem;
    }
    
    .galaxy-sidebar h3 {
        font-size: 0.9rem;
    }
    
    .operation {
        padding: 0.75rem;
    }
    
    .news-item {
        padding: 0.5rem;
    }
}
/* Better scrollbar styling for sidebars */
.galaxy-sidebar::-webkit-scrollbar,
.planet-sidebar::-webkit-scrollbar {
    width: 6px;
}

.galaxy-sidebar::-webkit-scrollbar-track,
.planet-sidebar::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 3px;
}

.galaxy-sidebar::-webkit-scrollbar-thumb,
.planet-sidebar::-webkit-scrollbar-thumb {
    background: var(--rebel-primary);
    border-radius: 3px;
}

.galaxy-sidebar::-webkit-scrollbar-thumb:hover,
.planet-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--rebel-secondary);
}
/* Fix for very small screens */
@media (max-width: 360px) {
    .war-map-container {
        grid-template-columns: 1fr;
    }
    
    .galaxy-sidebar, .planet-sidebar {
        max-height: 180px;
        font-size: 0.9rem;
    }
    
    .faction-control {
        gap: 0.75rem;
    }
    
    .operation-list {
        gap: 0.75rem;
    }
    
    .news-feed {
        gap: 0.75rem;
    }
}
/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--rebel-primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Accessibility */
.planet:focus {
    outline: 2px solid var(--rebel-primary);
    outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* Operation type icons */
.operation::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 2px;
}

.operation.urgent::before {
    background: var(--danger-color);
    box-shadow: 0 0 10px var(--danger-color);
}

.operation.high::before {
    background: var(--warning-color);
}

.operation.medium::before {
    background: var(--success-color);
}

.operation.low::before {
    background: var(--text-muted);
}