/* Generell container */
#lineup-builder-app { font-family: 'Inter', sans-serif; background-color: #f4f4f4; padding: 1rem; border-radius: 12px; max-width: 1000px; margin: 2rem auto; -webkit-font-smoothing: antialiased; position: relative; box-sizing: border-box; }

/* Kolonne for å holde på brett og nullstill-knapp */
.lineup-column { display: flex; flex-direction: column; align-items: center; }

/* Hovedområde */
#lineup-output { padding: 1rem; background: #0b1129; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); color: #fff; width: 100%; box-sizing: border-box; }
.lineup-background { position: relative; width: 100%; aspect-ratio: 9 / 13; display: flex; flex-direction: column; overflow: hidden; }

/* Topp-bar */
.lineup-top-bar { display: flex; justify-content: space-between; align-items: flex-start; padding: 0.5rem 0.5rem; position: absolute; top: 0; left: 0; right: 0; z-index: 10; gap: 1rem;}
.lineup-top-left { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }

/* Dropdown-meny for formasjoner */
.lineup-title-wrapper { position: relative; cursor: pointer; }
.dropdown-trigger { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; transition: background-color 0.2s ease; }
.lineup-title-wrapper:hover .dropdown-trigger { background-color: rgba(255, 255, 255, 0.1); }
.lineup-formation-title { font-family: 'Geist', sans-serif; font-size: 1.2rem; font-weight: 600; margin: 0; color: rgba(255, 255, 255, 0.8); }
.dropdown-arrow { width: 12px; height: 12px; fill: rgba(255, 255, 255, 0.6); transition: transform 0.3s ease; }
.lineup-title-wrapper.is-open .dropdown-arrow { transform: rotate(180deg); }
#formation-list { display: none; position: absolute; top: 110%; left: 0; list-style: none; margin: 0; padding: 0.5rem; background-color: #2c3e50; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); z-index: 1001; }
#formation-list.is-open { display: block; }
#formation-list li { padding: 0.6rem 0.4rem; color: #fff; font-size: 0.9rem; font-weight: 500; border-radius: 4px; cursor: pointer; transition: background-color 0.2s ease; }
#formation-list li:hover { background-color: #34495e; }

/* Branding */
.lineup-brand { text-align: right; }
.lineup-brand img { height: 20px; display: block; margin: 0 0 4px auto; }
.lineup-brand span { display: block; font-size: 0.55rem; font-weight: 500; color: rgba(255, 255, 255, 0.5); }

/* Lagnavn */
#team-name-wrapper { text-align: left; position: relative; z-index: 5; }
#team-name-display { font-size: 0.9rem; font-weight: 600; color: #fff; margin: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: background-color 0.2s ease; border: 1px solid transparent; background-color: rgba(0,0,0,0.2); }
#team-name-display:hover { background-color: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); }
#team-name-display.is-placeholder { color: rgba(255, 255, 255, 0.4); font-style: normal; font-weight:500; }
#team-name-input { width: 150px; padding: 6px 10px; font-size: 0.9rem; font-weight: 600; color: #fff; background-color: #1c25a3; border: 1px solid #3c4aff; border-radius: 6px; text-align: left; }
.is-hidden { display: none; }

/* Spiller-layout */
#lineup-grid-container { position: relative; flex-grow: 1; margin-top: 10px; }
.player-slot { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: grab; width: 65px; transition: top 0.3s ease, left 0.3s ease, transform 0.2s ease; z-index: 1; touch-action: none; }
.player-slot.is-dragging { transition: none; opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); z-index: 100; }
.player-slot:active { cursor: grabbing; }
.player-slot.is-editing { transform: translate(-50%, -50%) scale(1.2); z-index: 1000; }
.player-slot.is-editing .player-avatar { box-shadow: 0 0 15px rgba(59, 130, 246, 0.7); }
.player-avatar { width: 40px; height: 40px; border-radius: 50%; background-color: rgba(255, 255, 255, 0.1); border: 1.5px solid rgba(255, 255, 255, 0.2); display: flex; align-items: center; justify-content: center; transition: box-shadow 0.2s ease; }
.player-slot.filled .player-avatar { background-color: #fff; border-color: #fff; }
.player-avatar svg { width: 50%; height: 50%; fill: rgba(255, 255, 255, 0.4); }
.player-slot.filled .player-avatar svg { fill: #0b1129; }
.lb-player-name { font-size: 0.85rem !important; font-weight: 500; margin-top: 5px; color: #fff; width: 125%; line-height: 1.3; white-space: normal; word-wrap: break-word; }
.lb-position-label { font-size: 0.8rem !important; color: rgba(255, 255, 255, 0.4); font-style: normal; }

/* Spillervalg-panel (kun for PC nå) */
#player-selection-panel { display: none; }

/* Stiler for mobilens redigeringsvindu */
#mobile-player-editor { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; align-items: center; justify-content: center; z-index: 1002; }
#lineup-builder-app.mobile-editor-is-open #mobile-player-editor { display: flex; }
#mobile-player-editor .editor-content { background-color: #fff; padding: 1rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); width: 90%; max-width: 325px; text-align: center; }
.editor-content h4 { margin: 0 0 1rem 0; font-size: 1.2rem; color: #333; }
#mobile-player-input { width: 100%; box-sizing: border-box; padding: 0.8rem; font-size: 1rem; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1rem; }
#mobile-autocomplete-list { list-style: none; padding: 0; margin: 0; max-height: 150px; overflow-y: auto; text-align: left; }
#mobile-autocomplete-list li, #squad-list li { padding: 0.8rem 0.5rem; font-size: 1rem; cursor: pointer; border-bottom: 1px solid #f0f0f0; transition: background-color 0.2s ease; }
#mobile-autocomplete-list li:hover, #squad-list li:hover { background-color: #f8f8f8; }

.mobile-editor-buttons { display: flex; gap: 0.5rem; margin-top: 1rem; }
#mobile-save-player-btn, #mobile-remove-player-btn { width: 100%; padding: 0.8rem; border: none; font-size: 1rem; border-radius: 8px; cursor: pointer; }
#mobile-save-player-btn { background-color: #0d1365; color: #fff; }
#mobile-remove-player-btn { background-color: #e0e0e0; color: #333; }

/* Stil for brukte spillere */
.used-player { color: #aaa; pointer-events: none; background-color: #f9f9f9; }

/* Stil for "Velg fra tropp" */
.squad-select-header { display: flex; align-items: center; margin: 1rem 0; }
.squad-select-header .line { flex-grow: 1; height: 1px; background-color: #eee; }
.squad-select-header .text { padding: 0 0.5rem; font-size: 0.8rem; color: #888; display: flex; align-items: center; gap: 0.4rem; }
.squad-select-header img { height: 16px; width: 16px; }

/* Overlay for mobil-editor */
#lineup-builder-app.mobile-editor-is-open::after { content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 999; }

.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 1rem; border-bottom: 1px solid #eee; }
.panel-tabs { display: flex; gap: 0.5rem; }
.tab-button { padding: 0.8rem 1rem; border: none; background: none; font-size: 0.9rem; font-weight: 600; color: #aaa; cursor: pointer; border-bottom: 3px solid transparent; }
.tab-button.active { color: #0b1129; border-bottom-color: #0d1365; }
.panel-content { padding: 1rem; max-height: 40vh; overflow-y: auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

#player-actions { margin-bottom: 1rem; }
#remove-player-btn-pc { width: 100%; padding: 0.8rem; background-color: #e0e0e0; color: #333; border: none; font-size: 1rem; border-radius: 8px; cursor: pointer; }

#squad-search, #custom-player-name { width: 100%; box-sizing: border-box; padding: 0.8rem; font-size: 1rem; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1rem; }
#squad-list { list-style: none; padding: 0; margin: 0; }
#add-custom-player-btn { width: 100%; padding: 0.8rem; background-color: #0d1365; color: #fff; border: none; font-size: 1rem; border-radius: 8px; cursor: pointer; }

#reset-lineup-btn { background: none; border: none; color: #000; cursor: pointer; padding: 0; font-size: 0.9rem; margin-top: 1rem; }

@media (max-width: 991px) {
    .lineup-background { aspect-ratio: 9 / 15; }
}

/* PC-visning */
@media (min-width: 992px) {
    .lineup-column { flex: 1; min-width: 0; }
    #lineup-output { max-width: 500px; }
    .lineup-background { aspect-ratio: 9 / 10; }
    .lineup-builder-container { display: flex; gap: 1.5rem; align-items: flex-start; justify-content: center; }
    #player-selection-panel { display: block; position: relative; width: 350px; flex-shrink: 0; background-color: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); height: fit-content; }
    .panel-content { max-height: 500px; }
}