/**
 * Server Browser (New) Page Styles
 * @version 1.0.0
 */

/* Modern CS2Browser Style */
.server-browser {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 80px; /* Add top padding to prevent header overlap */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Loading Progress Indicator */
#loading-progress {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: white;
    padding: 15px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 400px;
    animation: slideDown 0.3s ease;
}

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

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-info {
    text-align: center;
    font-size: 14px;
    color: #666;
}

.progress-item {
    margin-bottom: 12px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
}

.progress-label span:first-child {
    font-weight: 500;
}

.progress-label span:last-child {
    color: #667eea;
    font-weight: 600;
}

.header-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    color: white;
}

.header-section h1 {
    margin: 0 0 20px 0;
    font-size: 32px;
    font-weight: 600;
}

.stats-bar {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap;
}

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

.stat-item .number {
    font-size: 24px;
    font-weight: bold;
}

.stat-item .label {
    opacity: 0.9;
    font-size: 14px;
}

/* Category Filter */
.category-filter {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-filter h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

/* Advanced Filters Section */
.filters-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

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

.filter-group label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: white;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.search-input {
    position: relative;
}

.search-input input {
    width: 100%;
    padding-left: 40px !important;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.btn-filter {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-apply {
    background: #667eea;
    color: white;
}

.btn-apply:hover {
    background: #5568d3;
}

.btn-reset {
    background: #f0f0f0;
    color: #666;
}

.btn-reset:hover {
    background: #e0e0e0;
}

.btn-auto-refresh {
    background: #f0f0f0;
    color: #666;
    position: relative;
}

.btn-auto-refresh:hover {
    background: #e0e0e0;
}

.btn-auto-refresh.active {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.btn-auto-refresh.active:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
}

.auto-refresh-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    margin-left: 6px;
    animation: pulse-indicator 2s infinite;
}

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

/* iOS Style Toggle Switch */
.ios-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.ios-toggle-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.ios-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    cursor: pointer;
}

.ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.ios-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ios-toggle input:checked + .ios-toggle-slider {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.ios-toggle input:checked + .ios-toggle-slider:before {
    transform: translateX(24px);
}

.ios-toggle-status {
    font-size: 12px;
    color: #999;
    min-width: 50px;
}

.ios-toggle-status.active {
    color: #4CAF50;
    font-weight: 500;
}

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-pill {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid #e0e0e0;
    background: white;
    color: #666;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.category-pill:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
}

.category-pill.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Server Grid */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    /* Performance: contain layout changes */
    contain: layout;
}

.server-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    /* Performance: use GPU acceleration for transforms */
    transform: translateZ(0);
    will-change: transform, box-shadow;
    /* Performance: contain card paint/layout */
    contain: layout paint;
}

.server-card:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.server-image {
    position: relative;
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.server-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Performance: optimize rendering for visible content */
    content-visibility: auto;
}

.server-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.server-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.action-btn:hover {
    background: white;
    transform: scale(1.1);
}

.server-info {
    padding: 16px;
}

.server-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-map {
    font-size: 14px;
    color: #666;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-count {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 12px;
}

.player-count-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.player-count .players {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
}

.player-count .max-players {
    color: #999;
    font-size: 14px;
}

.bot-count {
    color: #ff9800;
    font-size: 12px;
}

/* Server comments (data return time) */
.server-comments {
    color: #999;
}

/* Player Progress Bar */
.player-progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

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

.progress-green {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
}

.progress-yellow {
    background: linear-gradient(90deg, #FF9800, #FFC107);
}

.progress-red {
    background: linear-gradient(90deg, #f44336, #E91E63);
}

/* Clickable card link */
.server-card-link {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    cursor: pointer;
}

.server-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

/* Favorite Button */
.action-btn.favorited {
    background: #ff4081 !important;
}

.action-btn.favorited svg {
    fill: white !important;
}

/* Refresh Button */
.action-btn.refresh-btn {
    background: rgba(102, 126, 234, 0.9);
}

.action-btn.refresh-btn:hover {
    background: rgba(102, 126, 234, 1);
}

.action-btn.refresh-btn.refreshing svg {
    animation: spin 1s linear infinite;
}

.action-btn.refresh-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

/* Card refresh animation */
.server-card.refreshing {
    position: relative;
}

.server-card.refreshing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
    pointer-events: none;
    z-index: 5;
    border-radius: 12px;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.server-card.refresh-success {
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
    50% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.5); }
    100% { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 30px 0;
}

.page-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    background: white;
    color: #666;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.page-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.page-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Responsive */
@media (max-width: 768px) {
    .server-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .category-pills {
        justify-content: center;
    }
}

/* Login Modal Styles */
.login-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.login-modal-overlay.active {
    display: flex;
}

.login-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.login-modal-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.login-modal-icon svg {
    width: 40px;
    height: 40px;
    fill: white;
}

.login-modal h3 {
    font-size: 22px;
    color: #333;
    margin-bottom: 10px;
}

.login-modal p {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.login-modal-buttons {
    display: flex;
    gap: 12px;
    flex-direction: column;
}

.login-modal-btn {
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-modal-btn.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.login-modal-btn.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.login-modal-btn.btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.login-modal-btn.btn-secondary:hover {
    background: #e0e0e0;
}

/* Navigation favorites link */
.nav-favorites {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-favorites:hover {
    background: rgba(255,255,255,0.25);
}

.nav-favorites svg {
    width: 20px;
    height: 20px;
}

/* Add Server Button - Enhanced Prominence */
.btn-add-server {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%) !important;
    color: white !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    padding: 12px 24px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4), 0 0 0 0 rgba(76, 175, 80, 0.5);
    animation: addServerPulse 2s infinite;
    position: relative;
    overflow: hidden;
}

.btn-add-server::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: addServerShine 3s infinite;
}

@keyframes addServerPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4), 0 0 0 0 rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5), 0 0 0 8px rgba(76, 175, 80, 0);
    }
}

@keyframes addServerShine {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 100%;
    }
}

.btn-add-server:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%) !important;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.5) !important;
}

/* Add Server Modal */
.add-server-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.add-server-modal h3 {
    font-size: 22px;
    color: #333;
    margin-bottom: 10px;
}

.add-server-modal p {
    color: #666;
    font-size: 14px;
    margin-bottom: 25px;
}

.add-server-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 15px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.add-server-input:focus {
    outline: none;
    border-color: #667eea;
}

.add-server-hint {
    font-size: 12px;
    color: #999;
    margin-bottom: 20px;
    text-align: left;
}

.add-server-result {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: left;
    display: none;
}

.add-server-result.success {
    background: #e8f5e9;
    border: 1px solid #4CAF50;
    color: #2e7d32;
    display: block;
}

.add-server-result.error {
    background: #ffebee;
    border: 1px solid #f44336;
    color: #c62828;
    display: block;
}

.add-server-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    color: #667eea;
}

.add-server-loading.active {
    display: flex;
}

.add-server-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Refresh Countdown Progress Bar - Full width below category filter */
.refresh-countdown-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.refresh-countdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

#refresh-countdown-time {
    font-weight: 600;
    color: #667eea;
}

.refresh-progress-bar-container {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.refresh-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 1s linear;
    width: 100%;
}

/* Auto Join Modal Styles */
.auto-join-modal {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.auto-join-modal h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 8px;
}

.auto-join-server-name {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    word-break: break-all;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
}

.auto-join-modal-status {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #ffcc80;
}

.auto-join-modal-status .auto-join-status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.auto-join-modal-status .auto-join-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 152, 0, 0.3);
    border-top-color: #FF9800;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.auto-join-modal-status .auto-join-status-info {
    font-size: 13px;
    color: #666;
}

.auto-join-modal-settings {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.auto-join-setting-row {
    margin-bottom: 12px;
}

.auto-join-setting-row label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.auto-join-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auto-join-input {
    width: 70px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: white;
    color: #333;
    font-size: 14px;
}

.auto-join-input-hint {
    font-size: 13px;
    color: #999;
}

.auto-join-preview {
    padding: 10px;
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid #FF9800;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: #333;
}

/* Auto Join Button in Card */
.action-btn.auto-join-btn {
    background: rgba(255, 152, 0, 0.9);
}

.action-btn.auto-join-btn:hover {
    background: rgba(255, 152, 0, 1);
}

.action-btn.auto-join-btn.active {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    animation: pulse-auto-join 2s infinite;
}

@keyframes pulse-auto-join {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}
