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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: #e0e0e0;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(20, 25, 45, 0.9);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #2d3561 0%, #1e2347 100%);
    padding: 30px;
    text-align: center;
    border-bottom: 2px solid #3d4575;
    position: relative;
}

header h1 {
    color: #64b5f6;
    font-size: 2.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* User controls in header */
.user-controls {
    position: absolute;
    top: 30px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-display {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #90caf9;
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-login {
    background: #64b5f6;
    color: #0a0e27;
}

.btn-login:hover {
    background: #42a5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(100, 181, 246, 0.3);
}

.btn-logout {
    background: #ef5350;
    color: white;
}

.btn-logout:hover {
    background: #e53935;
}

.btn-primary {
    background: #64b5f6;
    color: #0a0e27;
}

.btn-primary:hover {
    background: #42a5f5;
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-delete, .delete-btn {
    background: #ef5350;
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
}

.btn-delete:hover, .delete-btn:hover {
    background: #e53935;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(239, 83, 80, 0.4);
}

.btn-clear {
    background: #ffd54f;
    color: #0a0e27;
}

.btn-clear:hover {
    background: #ffecb3;
}

.btn-add {
    background: #64b5f6;
    color: #0a0e27;
}

.btn-add:hover {
    background: #42a5f5;
}

.btn:disabled, .btn-add:disabled, .btn-primary:disabled {
    background: #757575;
    color: white;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn:disabled:hover, .btn-add:disabled:hover, .btn-primary:disabled:hover {
    background: #757575;
    transform: none;
    box-shadow: none;
}

/* Navigation */
.navigation {
    display: flex;
    gap: 0;
    background: rgba(30, 35, 55, 0.9);
    border-bottom: 1px solid #3d4575;
}

.nav-link {
    padding: 15px 30px;
    color: #90caf9;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
}

.nav-link:hover {
    background: rgba(100, 181, 246, 0.1);
    color: #64b5f6;
}

.nav-link.active {
    background: rgba(100, 181, 246, 0.15);
    color: #64b5f6;
    border-bottom-color: #64b5f6;
}

/* Controls */
.controls {
    padding: 20px 30px;
    background: rgba(30, 35, 55, 0.8);
    border-bottom: 1px solid #3d4575;
}

.home-system-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.home-system-selector label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #90caf9;
}

.home-system-selector select {
    padding: 10px 15px;
    font-size: 1rem;
    background: #1e2347;
    color: #e0e0e0;
    border: 2px solid #3d4575;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
}

.home-system-selector select:hover {
    border-color: #64b5f6;
}

.home-system-selector select:focus {
    outline: none;
    border-color: #64b5f6;
    box-shadow: 0 0 0 3px rgba(100, 181, 246, 0.2);
}

/* Filters Section */
.filters-section {
    padding: 20px 30px;
    background: rgba(30, 35, 55, 0.8);
    border-bottom: 1px solid #3d4575;
}

.filters-section h3 {
    color: #64b5f6;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.filters-row {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-group > label {
    font-size: 1rem;
    font-weight: 600;
    color: #90caf9;
}

.filter-group select {
    padding: 10px 15px;
    font-size: 1rem;
    background: #1e2347;
    color: #e0e0e0;
    border: 2px solid #3d4575;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.filter-group select:hover {
    border-color: #64b5f6;
}

.filter-group select:focus {
    outline: none;
    border-color: #64b5f6;
    box-shadow: 0 0 0 3px rgba(100, 181, 246, 0.2);
}

/* Multiselect Dropdown */
.multiselect-dropdown {
    position: relative;
    min-width: 250px;
}

.multiselect-button {
    width: 100%;
    padding: 10px 15px;
    background: #1e2347;
    color: #e0e0e0;
    border: 2px solid #3d4575;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    text-align: left;
}

.multiselect-button:hover {
    border-color: #64b5f6;
}

.multiselect-button:focus {
    outline: none;
    border-color: #64b5f6;
    box-shadow: 0 0 0 3px rgba(100, 181, 246, 0.2);
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    color: #90caf9;
}

.multiselect-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.multiselect-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: #1e2347;
    border: 2px solid #3d4575;
    border-radius: 5px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 10px;
}

.multiselect-dropdown.open .multiselect-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multiselect-options::-webkit-scrollbar {
    width: 8px;
}

.multiselect-options::-webkit-scrollbar-track {
    background: #0a0e27;
    border-radius: 4px;
}

.multiselect-options::-webkit-scrollbar-thumb {
    background: #3d4575;
    border-radius: 4px;
}

.multiselect-options::-webkit-scrollbar-thumb:hover {
    background: #64b5f6;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.checkbox-label:hover {
    background-color: rgba(100, 181, 246, 0.1);
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #64b5f6;
}

.checkbox-label span {
    color: #e0e0e0;
    font-size: 0.95rem;
}

/* Table container */
.table-container {
    overflow-x: auto;
    padding: 20px 30px;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(30, 35, 55, 0.6);
}

thead {
    background: linear-gradient(135deg, #2d3561 0%, #252a4d 100%);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    color: #90caf9;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #3d4575;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 35px;
    transition: background-color 0.2s ease;
}

th.sortable:hover {
    background-color: rgba(100, 181, 246, 0.1);
}

th.sortable.active {
    color: #64b5f6;
}

.sort-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #64b5f6;
    opacity: 0;
    transition: opacity 0.2s ease;
}

th.sortable.active .sort-indicator {
    opacity: 1;
}

tbody tr {
    border-bottom: 1px solid #2d3561;
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: rgba(100, 181, 246, 0.05);
}

td {
    padding: 15px 20px;
    color: #e0e0e0;
}

td.loading,
td.error,
td.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #90caf9;
    font-style: italic;
}

td.error {
    color: #ef5350;
}

/* Special column styling */
td:nth-child(1) {
    font-weight: 600;
    color: #ffd54f;
}

td:nth-child(2) {
    font-family: 'Courier New', monospace;
    color: #81c784;
}

td:nth-child(5) {
    font-family: 'Courier New', monospace;
    color: #90caf9;
}

/* Null value styling */
.null-value {
    color: #757575;
    font-style: italic;
}

/* Editable cells */
td.editable {
    position: relative;
    cursor: pointer;
}

td.editable:hover {
    background-color: rgba(100, 181, 246, 0.1);
    outline: 1px solid rgba(100, 181, 246, 0.3);
}

td.editable::after {
    content: '✎';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    font-size: 0.8em;
    color: #64b5f6;
    transition: opacity 0.2s ease;
}

td.editable:hover::after {
    opacity: 0.5;
}

/* Footer */
.footer {
    padding: 20px 30px;
    background: rgba(30, 35, 55, 0.8);
    border-top: 1px solid #3d4575;
    text-align: center;
}

.footer p {
    color: #90caf9;
    font-size: 1rem;
}

.footer span {
    font-weight: 700;
    color: #64b5f6;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .controls {
        padding: 15px 20px;
    }

    .home-system-selector {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .home-system-selector select {
        width: 100%;
    }

    .filters-section {
        padding: 15px 20px;
    }

    .filters-row {
        flex-direction: column;
        gap: 20px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select,
    .multiselect-dropdown {
        width: 100%;
        min-width: unset;
    }

    .table-container {
        padding: 15px 20px;
    }

    th, td {
        padding: 10px;
        font-size: 0.9rem;
    }

    th.sortable {
        padding-right: 25px;
    }
}

/* Location type badges */
.location-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 5px;
    text-transform: uppercase;
}

.location-type.sector {
    background-color: rgba(100, 181, 246, 0.2);
    color: #64b5f6;
}

.location-type.planet {
    background-color: rgba(129, 199, 132, 0.2);
    color: #81c784;
}

.location-type.moon {
    background-color: rgba(255, 213, 79, 0.2);
    color: #ffd54f;
}

.location-type.asteroid {
    background-color: rgba(255, 138, 101, 0.2);
    color: #ff8a65;
}

.location-type.location {
    background-color: rgba(186, 104, 200, 0.2);
    color: #ba68c8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, #2d3561 0%, #1e2347 100%);
    margin: 10% auto;
    padding: 30px;
    border: 2px solid #3d4575;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #64b5f6;
    margin-bottom: 20px;
    text-align: center;
}

.close {
    color: #90caf9;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover,
.close:focus {
    color: #64b5f6;
}

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

.form-group label {
    display: block;
    color: #90caf9;
    margin-bottom: 8px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 10px;
    background: #1e2347;
    border: 2px solid #3d4575;
    border-radius: 5px;
    color: #e0e0e0;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #64b5f6;
    box-shadow: 0 0 0 3px rgba(100, 181, 246, 0.2);
}

.form-group select {
    width: 100%;
    padding: 10px;
    background: #1e2347;
    border: 2px solid #3d4575;
    border-radius: 5px;
    color: #e0e0e0;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.form-error {
    background: rgba(239, 83, 80, 0.2);
    border: 1px solid #ef5350;
    color: #ef5350;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.form-success {
    background: rgba(129, 199, 132, 0.2);
    border: 1px solid #81c784;
    color: #81c784;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-actions .btn {
    padding: 10px 20px;
}

/* Add System Section */
.add-system-section {
    padding: 30px;
    background: rgba(30, 35, 55, 0.8);
    border-bottom: 1px solid #3d4575;
}

.add-system-section h2 {
    color: #64b5f6;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Table container heading */
.table-container h2 {
    color: #64b5f6;
    margin-bottom: 15px;
    font-size: 1.5rem;
    padding: 0;
}

/* System link styling */
.system-link {
    color: #ffd54f;
    text-decoration: none;
    transition: color 0.3s ease;
}

.system-link:hover {
    color: #ffecb3;
    text-decoration: underline;
}
