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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a2a6c, #2c3e50);
    color: #fff;
    overflow: hidden;
}

#dashboard-container {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 250px;
    background: rgba(30, 30, 40, 0.95);
    padding: 20px 0;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

#logo {
    text-align: center;
    padding: 0 20px 20px;
    font-size: 20px;
    font-weight: bold;
    color: #4fc3f7;
    border-bottom: 1px solid #444;
    margin-bottom: 20px;
}

#sidebar nav ul {
    list-style: none;
    padding: 0 15px;
}

#sidebar nav ul li {
    margin-bottom: 5px;
}

#sidebar nav ul li a {
    display: block;
    padding: 12px 15px;
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 5px;
    transition: background 0.3s;
}

#sidebar nav ul li a:hover,
#sidebar nav ul li.active a {
    background: rgba(33, 150, 243, 0.3);
    color: #4fc3f7;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: 250px;
    transition: margin 0.3s ease-in-out;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #4fc3f7;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

header {
    background: rgba(20, 20, 30, 0.9);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    z-index: 50;
    position: relative;
}

header h1 {
    font-size: 24px;
    color: #4fc3f7;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.operational {
    background-color: #4CAF50;
}

.status-dot.maintenance {
    background-color: #FFC107;
}

.status-dot.issues {
    background-color: #F44336;
}

.date-display {
    font-size: 14px;
    color: #bbb;
}

#dashboard-content {
    flex: 1;
    padding: 20px;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

#search-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(40, 40, 60, 0.6);
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 400px;
}

#search-input {
    flex: 1;
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #333;
    color: white;
    font-size: 14px;
}

#search-btn {
    padding: 10px 15px;
    background: rgba(33, 150, 243, 0.8);
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

#search-btn:hover {
    background: rgba(33, 150, 243, 1);
}

.filter-options {
    display: flex;
    gap: 10px;
}

.filter-options select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #333;
    color: white;
}

#ship-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(40, 40, 60, 0.6);
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 15px;
}

#ship-selector label {
    font-weight: bold;
    color: #4fc3f7;
}

#ship-dropdown {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #333;
    color: white;
    min-width: 200px;
}

.ship-status-summary {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.status-card {
    background: rgba(50, 50, 70, 0.7);
    padding: 12px;
    border-radius: 8px;
    min-width: 120px;
    text-align: center;
}

.status-value {
    font-size: 20px;
    font-weight: bold;
    color: #4fc3f7;
    margin-bottom: 5px;
}

.status-label {
    font-size: 12px;
    color: #bbb;
}

#visualization-panel {
    flex: 1;
    min-height: 500px;
    margin-bottom: 20px;
    position: relative;
}

#container {
    position: relative;
    width: 100%;
    height: 100%;
}

#scene-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    min-height: 500px;
    margin: 0;
    padding: 0;
}

#info-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
    max-width: 300px;
    z-index: 10;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#info-panel h2,
#info-panel h3 {
    color: #4fc3f7;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #4fc3f7;
    padding-bottom: 5px;
}

#info-panel h3 {
    margin-top: 15px;
    font-size: 16px;
}

#info-panel p {
    margin: 8px 0;
    font-size: 14px;
}

#info-panel strong {
    display: inline-block;
    width: 100px;
    color: #e0f7fa;
}

#controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    max-width: 200px;
}

#controls button {
    display: block;
    margin: 5px 0;
    padding: 10px 15px;
    background: rgba(33, 150, 243, 0.8);
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    width: 100%;
}

#controls button:hover {
    background: rgba(33, 150, 243, 1);
}

#legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    z-index: 10;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    max-width: 250px;
}

#legend h3 {
    margin: 5px 0;
    color: #4fc3f7;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px 40px;
    border-radius: 10px;
    z-index: 100;
}

#loading.hidden {
    display: none;
}

#charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.chart-card {
    background: rgba(40, 40, 60, 0.6);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.chart-card h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
    text-align: center;
}

#management-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.panel-card {
    background: rgba(40, 40, 60, 0.6);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.panel-card h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.maintenance-list,
.inventory-list,
.staff-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.maintenance-item,
.inventory-item,
.staff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(60, 60, 80, 0.5);
    border-radius: 6px;
}

.item-info {
    flex: 1;
}

.item-info .date {
    font-size: 0.85em;
    color: #bbb;
}

.item-status {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    text-align: center;
    min-width: 80px;
}

.item-status.urgent {
    background: rgba(244, 67, 54, 0.3);
    color: #ff8a80;
}

.item-status.normal {
    background: rgba(33, 150, 243, 0.3);
    color: #81d4fa;
}

.item-status.low {
    background: rgba(255, 152, 0, 0.3);
    color: #ffd54f;
}

.item-status.adequate {
    background: rgba(76, 175, 80, 0.3);
    color: #a5d6a7;
}

.item-status.active {
    background: rgba(76, 175, 80, 0.3);
    color: #a5d6a7;
}

/* Additional mobile optimizations */
@media (max-width: 1200px) {
    #charts-container {
        grid-template-columns: 1fr;
    }
    
    #management-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: block;
    }
    
    #sidebar {
        transform: translateX(-100%);
        width: 280px;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
    
    #main-content {
        margin-left: 0;
    }
    
    #sidebar nav ul {
        flex-direction: column;
        padding: 0 15px;
    }
    
    #sidebar nav ul li {
        margin: 5px 0;
        width: 100%;
    }
    
    #sidebar nav ul li a {
        padding: 15px;
        font-size: 16px;
    }
    
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .overlay.active {
        display: block;
    }
    
    #ship-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .ship-status-summary {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .status-card {
        flex: 1;
        min-width: 0;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    #info-panel {
        max-width: 250px;
        padding: 15px;
        font-size: 14px;
        z-index: 100;
    }
    
    #info-panel h2 {
        font-size: 18px;
    }
    
    #controls {
        position: fixed;
        top: 20px;
        right: 10px;
        width: auto;
        z-index: 100;
        background: rgba(0, 0, 0, 0.8);
        max-width: 180px;
    }
    
    #controls button {
        padding: 12px 16px;
        font-size: 14px;
        margin: 5px 0;
        min-height: 44px; /* Minimum touch target size */
        width: 100%;
    }
    
    #legend {
        position: fixed;
        bottom: 10px;
        left: 10px;
        font-size: 10px;
        padding: 10px;
        z-index: 100;
    }
    
    #legend h3 {
        font-size: 12px;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    #visualization-panel {
        min-height: 400px;
    }
    
    /* Adjust layout for mobile */
    #scene-container {
        height: 70vh !important;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    #search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    #ship-selector {
        padding: 10px;
        align-items: stretch;
    }
    
    #ship-dropdown {
        min-width: auto;
        width: 100%;
    }
    
    .ship-status-summary {
        flex-direction: column;
    }
    
    #info-panel {
        max-width: calc(100% - 20px);
        padding: 10px;
        font-size: 12px;
        top: 10px;
        left: 10px;
        right: 10px;
        z-index: 100;
        max-height: 30vh;
        overflow-y: auto;
    }
    
    #info-panel h2 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    #info-panel p {
        margin: 5px 0;
    }
    
    #controls {
        top: auto;
        bottom: 100px; /* Position above the legend to avoid overlap */
        left: 10px;
        right: 10px;
        padding: 10px;
        background: rgba(0, 0, 0, 0.85);
        max-width: none;
    }
    
    #controls button {
        padding: 15px;
        font-size: 16px;
        margin: 8px 0;
        width: 100%;
        min-height: 48px; /* Larger touch targets for mobile */
    }
    
    #legend {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 8px;
        font-size: 9px;
        max-width: none;
    }
    
    #legend h3 {
        font-size: 12px;
    }
    
    .legend-color {
        width: 10px;
        height: 10px;
    }
    
    #loading {
        font-size: 14px;
        padding: 15px 30px;
    }
    
    .status-card {
        min-width: 80px;
        padding: 8px;
        margin: 5px 0;
    }
    
    .status-value {
        font-size: 16px;
    }
    
    .status-label {
        font-size: 10px;
    }
    
    #scene-container {
        height: 65vh !important;
    }
    
    /* Ensure navigation items are adequately spaced on mobile */
    #sidebar nav ul li a {
        padding: 15px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Larger touch targets for filter options */
    #status-filter, #type-filter {
        min-height: 44px;
        padding: 12px;
        font-size: 16px;
    }
    
    /* Mobile-friendly search input */
    #search-input {
        min-height: 44px;
        padding: 12px 15px;
        font-size: 16px;
    }
    
    #search-btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
}