/* World Selection Screen Styles */

/* Main container */
#world-selection-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    /* Allow menu background to show through */
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.world-selection-container {
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--ui-border, rgba(93, 156, 236, 0.2));
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.world-selection-header {
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid var(--ui-border, rgba(93, 156, 236, 0.1));
}

.world-selection-header h2 {
    margin: 0 0 10px 0;
}

.world-selection-subtitle {
    color: var(--ui-text-secondary, #888);
    font-size: 16px;
    margin: 0;
}

/* Top Bar */
.world-selection-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(30, 30, 30, 0.5);
    border-bottom: 1px solid var(--ui-border, rgba(93, 156, 236, 0.1));
}

.world-select-btn {
    background-color: var(--ui-button-bg, rgba(60, 60, 60, 0.8));
    color: var(--ui-text-primary, #fff);
    border: 1px solid var(--ui-border, rgba(93, 156, 236, 0.2));
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.world-select-btn:hover {
    background-color: var(--ui-button-hover, rgba(80, 80, 80, 0.8));
    border-color: var(--ui-primary, #5d9cec);
}

.world-select-btn-primary {
    background-color: var(--ui-primary, #5d9cec);
    border-color: var(--ui-primary, #5d9cec);
}

.world-select-btn-primary:hover {
    background-color: var(--ui-primary-hover, #4a89d9);
}

.btn-icon {
    font-size: 18px;
}

/* Main Content Area */
.world-selection-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

/* Search & Filters */
.world-selection-controls {
    margin-bottom: 20px;
}

.world-search-input {
    width: 100%;
    padding: 12px 20px;
    background-color: var(--ui-input-bg, rgba(40, 40, 40, 0.8));
    border: 1px solid var(--ui-border, rgba(93, 156, 236, 0.2));
    border-radius: 10px;
    color: var(--ui-text-primary, #fff);
    font-size: 16px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.world-search-input:focus {
    outline: none;
    border-color: var(--ui-primary, #5d9cec);
    box-shadow: 0 0 0 2px rgba(93, 156, 236, 0.2);
}

.world-search-input::placeholder {
    color: var(--ui-text-secondary, #666);
}

.world-filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    overflow: hidden;
}

.filter-btn {
    background-color: var(--ui-button-bg, rgba(40, 40, 40, 0.8));
    color: var(--ui-text-primary, #fff);
    border: 1px solid var(--ui-border, rgba(93, 156, 236, 0.2));
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: var(--ui-button-hover, rgba(60, 60, 60, 0.8));
}

.filter-btn.active {
    background-color: var(--ui-primary, #5d9cec);
    border-color: var(--ui-primary, #5d9cec);
}

/* Stats Display */
.world-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    color: var(--ui-text-secondary, #888);
    font-size: 14px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-item span {
    color: var(--ui-primary, #5d9cec);
    font-weight: bold;
}

/* Worlds List */
.worlds-list-container {
    flex: 1;
    overflow-y: auto;
    background-color: rgba(30, 30, 30, 0.3);
    border-radius: 10px;
    border: 1px solid var(--ui-border, rgba(93, 156, 236, 0.1));
}

.worlds-table {
    width: 100%;
    border-collapse: collapse;
}

.worlds-table thead {
    position: sticky;
    top: 0;
    background-color: var(--panel-background, rgba(20, 20, 20, 0.95));
    z-index: 1;
}

.worlds-table th {
    text-align: center;
    padding: 15px 20px;
    color: var(--ui-text-secondary, #888);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--ui-border, rgba(93, 156, 236, 0.2));
}



/* World Row */
.world-row {
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--ui-border, rgba(93, 156, 236, 0.05));
}

.world-row:hover {
    background-color: rgba(93, 156, 236, 0.05);
}

.world-row.selected {
    background-color: rgba(93, 156, 236, 0.1);
    border-left: 3px solid var(--ui-primary, #5d9cec);
}

.world-row td {
    padding: 15px 20px;
    color: var(--ui-text-primary, #fff);
    font-size: 14px;
    text-align: center;
}

.world-row td:first-child {
    text-align: left;
    /* Keep WORLD column content left-aligned */
}

/* World Info Column */
.world-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: #4caf50;
    box-shadow: 0 0 4px #4caf50;
}

.status-dot.full {
    background-color: #ff9800;
    box-shadow: 0 0 4px #ff9800;
}

.world-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--ui-primary, #5d9cec);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.world-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.world-name {
    font-weight: 600;
    color: var(--ui-text-primary, #fff);
}

.world-type {
    font-size: 12px;
    color: var(--ui-text-secondary, #888);
}

/* Player Count Column */
.player-count-cell {
    min-width: 120px;
}

.player-count-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-count-text {
    font-size: 14px;
    min-width: 50px;
}

.player-count-bar {
    flex: 1;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.player-count-fill {
    height: 100%;
    background-color: #4caf50;
    transition: width 0.3s ease;
}

.player-count-fill.medium {
    background-color: #ff9800;
}

.player-count-fill.high {
    background-color: #f44336;
}

/* Mode Tag */
.mode-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.mode-tag.adventure {
    background-color: rgba(156, 39, 176, 0.2);
    color: #ba68c8;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

.mode-tag.survival {
    background-color: rgba(139, 195, 74, 0.2);
    color: #8bc34a;
    border: 1px solid rgba(139, 195, 74, 0.3);
}

.mode-tag.creative {
    background-color: rgba(93, 156, 236, 0.2);
    color: #5d9cec;
    border: 1px solid rgba(93, 156, 236, 0.3);
}

.mode-tag.pvp {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.mode-tag.hardcore {
    background-color: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

/* Ping Column */
.ping-value {
    font-family: monospace;
    font-size: 13px;
}

.ping-value.good {
    color: #4caf50;
}

.ping-value.medium {
    color: #ff9800;
}

.ping-value.bad {
    color: #f44336;
}

/* Footer */
.world-selection-footer {
    padding: 20px;
    border-top: 1px solid var(--ui-border, rgba(93, 156, 236, 0.1));
    display: flex;
    justify-content: center;
}

.join-world-btn {
    background-color: var(--ui-primary, #5d9cec);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 40px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.join-world-btn:hover:not(:disabled) {
    background-color: var(--ui-primary-hover, #4a89d9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(93, 156, 236, 0.3);
}

.join-world-btn:disabled {
    background-color: var(--ui-button-disabled, rgba(60, 60, 60, 0.5));
    color: var(--ui-text-secondary, #666);
    cursor: not-allowed;
}

/* Scrollbar Styling */
.worlds-list-container::-webkit-scrollbar {
    width: 8px;
}

.worlds-list-container::-webkit-scrollbar-track {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.worlds-list-container::-webkit-scrollbar-thumb {
    background-color: var(--ui-primary, #5d9cec);
    border-radius: 4px;
}

.worlds-list-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--ui-primary-hover, #4a89d9);
}

/* Responsive Design */
@media (max-width: 768px) {
    .world-selection-container {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 0;
    }

    /* Adjust header for mobile */
    .world-selection-header {
        padding: 15px 10px;
    }

    .world-selection-header h2 {
        font-size: 36px !important;
        margin-bottom: 5px !important;
    }

    .world-selection-subtitle {
        font-size: 14px;
    }

    /* Top bar adjustments */
    .world-selection-top-bar {
        padding: 10px 15px;
        gap: 10px;
    }

    .world-select-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    .btn-icon {
        font-size: 16px;
    }

    /* Main content area */
    .world-selection-main {
        padding: 15px;
    }

    /* Search and controls */
    .world-selection-controls {
        margin-bottom: 15px;
    }

    .world-search-input {
        padding: 10px 15px;
        font-size: 14px;
        margin-bottom: 10px;
    }

    /* Filter buttons - make scrollable */
    .world-filter-buttons {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding-bottom: 5px;
        margin: 0 -15px;
        padding-left: 15px;
        padding-right: 15px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .world-filter-buttons::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 5px 14px;
        white-space: nowrap;
    }

    /* Stats display */
    .world-stats {
        font-size: 12px;
        gap: 20px;
        margin-bottom: 15px;
    }

    /* World list table */
    .worlds-list-container {
        margin: 0 -15px;
    }

    .worlds-table {
        font-size: 13px;
    }

    .worlds-table th {
        padding: 10px 8px;
        font-size: 10px;
        letter-spacing: 0.5px;
    }

    .worlds-table td {
        padding: 12px 8px;
    }

    /* Hide some columns on very small screens */
    @media (max-width: 480px) {

        .worlds-table th:nth-child(3),
        .worlds-table td:nth-child(3) {
            display: none;
            /* Hide region column */
        }
    }

    /* World info adjustments */
    .world-info {
        gap: 10px;
    }

    .world-icon {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .world-name {
        font-size: 14px;
    }

    .world-type {
        font-size: 10px;
    }

    /* Player count */
    .player-count-info {
        gap: 8px;
    }

    .player-count-text {
        font-size: 12px;
        min-width: 40px;
    }

    /* Mode tags */
    .mode-tag {
        font-size: 10px;
        padding: 3px 8px;
    }

    /* Ping values */
    .ping-value {
        font-size: 11px;
    }

    /* Footer */
    .world-selection-footer {
        padding: 15px;
    }

    .join-world-btn {
        font-size: 14px;
        padding: 10px 30px;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .world-selection-header h2 {
        font-size: 32px !important;
    }

    .world-select-btn span:not(.btn-icon) {
        display: none;
        /* Hide button text, keep only icons */
    }

    .world-select-btn {
        padding: 8px 12px;
    }

    #buy-world-btn span {
        display: inline;
        /* Keep "Buy a World" text */
    }
}