/* tour_manager/app/static/css/responsive.css - OPPDATERT VERSION */

/* Base styles for better mobile experience */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #0f172a;
    color: #f1f5f9;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Main container layout */
.main-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    /* Default for larger screens: marketplace left, team right */
    flex-direction: row-reverse; /* This places formation-section (order 2) on the right, player-list-section (order 1) on the left */
}

/* Sidebar styles - these are likely vestigial if using .player-list-section as the sidebar now */
.sidebar {
    /* Removed fixed width and positioning for the new layout */
    /* width: 280px; */
    /* background: #1e293b; */
    /* padding: 1rem; */
    /* position: fixed; */
    /* left: 0; */
    /* top: 0; */
    /* height: 100vh; */
    /* overflow-y: auto; */
    /* z-index: 1000; */
    /* transform: translateX(0); */
    /* transition: transform 0.3s ease; */
    display: none; /* Hide if this is no longer used as the primary sidebar */
}

/* If the .player-list-section is now acting as the sidebar, some of these might need to be moved there */
.sidebar-header, .sidebar-section, .sidebar-search, .sidebar-item {
    /* These styles might need to be re-applied to elements within .player-list-section if they replace the old sidebar */
}


/* Main content area */
.main-content {
    flex: 1;
    /* Removed margin-left as the layout is now flex-based within .tour-manager-container */
    margin-left: 0; 
    padding: 1rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Tour manager specific styles */
.tour-manager-container {
    display: flex;
    flex-direction: row-reverse; /* Marketplace on left, Team on right for desktop */
    gap: 1rem;
    max-width: 100%;
}

/* Player List Section - now on the left (effectively the sidebar) */
.player-list-section {
    flex-shrink: 0; /* Prevents it from shrinking too much */
    width: 350px; /* Fixed width for the marketplace/sidebar on desktop */
    background: #1e293b;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 100vh;
    order: 1; /* Place on the left for row-reverse */
    border-right: 1px solid #475569; /* Add a right border */
}

/* Formation Section - now on the right */
.formation-section {
    flex: 1;
    padding: 2rem;
    order: 2; /* Place on the right for row-reverse */
}


/* Formation area improvements */
.formation-area {
    padding: 1.5rem;
    background: #1e293b;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.formation-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #f1f5f9;
    text-align: center;
}

.formation-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    max-width: 100%;
}

.position-slot {
    background: rgba(51, 65, 85, 0.6);
    border: 2px dashed #475569;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.position-slot:hover:not(.filled) {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.position-slot.filled {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    border-style: solid;
    cursor: default;
}

.position-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.selected-player {
    text-align: center;
    position: relative;
    width: 100%;
}

.player-jersey {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    display: block;
    object-fit: cover;
    border: 3px solid #22c55e;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.selected-player-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    line-height: 1.2;
}

.selected-player-team {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.selected-player-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fbbf24;
}

.remove-player-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.remove-player-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.6);
}

/* Team stats responsive */
.team-stats {
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: #f1f5f9;
    display: block;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Player list improvements */
.player-list-container {
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.player-list-header {
    display: grid;
    grid-template-columns: 1fr auto auto; /* Removed %Valgt column */
    gap: 1rem;
    padding: 1rem;
    background: #334155;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
}

.sort-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.sort-header:hover {
    color: #f1f5f9;
}

.sort-header.active {
    color: #3b82f6;
}

.player-list {
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #475569 #1e293b;
}

.player-list::-webkit-scrollbar {
    width: 8px;
}

.player-list::-webkit-scrollbar-track {
    background: #1e293b;
}

.player-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.player-item {
    display: grid;
    grid-template-columns: 1fr auto auto; /* Removed %Valgt column */
    gap: 1rem;
    padding: 1rem;
    background: rgba(51, 65, 85, 0.3);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
}

.player-item:hover:not(.disabled) {
    background: rgba(59, 130, 246, 0.2);
    transform: translateX(4px);
}

.player-item.selected {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid #22c55e;
}

.player-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.player-position {
    width: 48px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.player-position.lagkaptein { background: #8b5cf6; }
.player-position.spurter { background: #10b981; }
.player-position.klatrer { background: #f59e0b; }
.player-position.ungdom { background: #3b82f6; }
.player-position.tempo { background: #ef4444; }
.player-position.hjelperytter { background: #6b7280; }
.player-position.director { background: #1f2937; }

.player-details {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.player-team {
    font-size: 0.8rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-stat {
    font-size: 0.875rem;
    color: #94a3b8;
    text-align: right;
    min-width: 60px;
}

.player-price {
    font-weight: 600;
    color: #fbbf24;
}

/* Action buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-primary,
.btn-secondary {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
    background: #475569;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #374151;
    transform: translateY(-2px);
}

/* Mobile hamburger menu - likely not needed if .player-list-section is always visible */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Mobile responsive styles */
@media (max-width: 1024px) {
    .tour-manager-container {
        flex-direction: column; /* Stack vertically on smaller screens */
    }
    
    .player-list-section {
        width: 100%;
        order: 1; /* Player list on top */
        border-right: none;
        border-bottom: 2px solid #475569; /* Add bottom border when stacked */
    }
    
    .formation-section {
        order: 2; /* Formation below player list */
    }
    
    .mobile-menu-toggle {
        /* display: flex; */ /* Re-enable if a mobile menu is needed elsewhere */
        /* align-items: center; */
        /* justify-content: center; */
    }
    
    .mobile-overlay.active {
        /* display: block; */ /* Re-enable if a mobile menu is needed elsewhere */
    }
    
    .formation-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .position-slot {
        min-height: 120px;
        padding: 0.75rem;
    }
    
    .team-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .player-jersey {
        width: 40px;
        height: 40px;
    }
    
    .remove-player-btn {
        width: 24px;
        height: 24px;
        top: -6px;
        right: -6px;
    }
    
    .player-list-header {
        grid-template-columns: 1fr auto auto; /* Adjusted for removed %Valgt */
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .player-item {
        grid-template-columns: 1fr auto auto; /* Adjusted for removed %Valgt */
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

@media (max-width: 768px) {
    .formation-grid {
        grid-template-columns: 1fr;
    }
    
    .team-stats {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .category-pills {
        justify-content: center;
    }
    
    .pill-btn {
        font-size: 0.7rem;
        padding: 0.35rem 0.7rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .player-position {
        width: 40px;
        height: 24px;
        font-size: 0.7rem;
    }
    
    .player-name {
        font-size: 0.85rem;
    }
    
    .player-team {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }
    
    .formation-area,
    .team-stats,
    .player-list-container {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .position-slot {
        min-height: 100px;
        padding: 0.5rem;
    }
    
    .position-label {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }
    
    .selected-player-name {
        font-size: 0.8rem;
        line-height: 1.1;
    }
    
    .selected-player-team,
    .selected-player-price {
        font-size: 0.7rem;
    }
    
    .player-jersey {
        width: 32px;
        height: 32px;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .player-list {
        max-height: 50vh;
    }
    
    .player-item {
        padding: 0.5rem;
    }
    
    .player-position {
        width: 36px;
        height: 20px;
        font-size: 0.65rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.mb-3 { margin-bottom: 1rem; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Message styles */
.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.message.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    color: #22c55e;
}

.message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}

.message.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    color: #f59e0b;
}

.message.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid #3b82f6;
    color: #3b82f6;
}

/* Focus styles for accessibility */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .position-slot {
        border-width: 3px;
    }
    
    .player-item {
        border: 2px solid transparent;
    }
    
    .player-item:hover:not(.disabled) {
        border-color: #3b82f6;
    }
    
    .player-item.selected {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}