/**
 * Session Map Styles
 * 
 * Responsive layout and styling for session visualization
 */

/* Session-specific layout modifications */
body.session-map {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Override the existing map container for session layout */
body.session-map #map-container {
    flex: 1; /* Take remaining height from parent */
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow shrinking */
}

body.session-map #map-header {
    background: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    flex-shrink: 0;
    gap: 0;
    border: none;
}

body.session-map #map {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 400px;
}

/* Session info control positioning */
.session-info-control {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.9);
    background-image: url("/img/bg_transparent50.png");
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    max-width: 360px;
    max-height: calc(100vh - 100px);
    overflow: hidden;
    z-index: 1000;
    border: 1px solid #666;
    color: white;
}

.session-info-control.collapsed {
    max-height: 50px;
}

/* Session header */
.session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.7);
    border-bottom: 1px solid #666;
    min-height: 26px;
}

.session-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff001;
}

.session-toggle {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: #fff001;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.session-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Session content */
.session-content {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding: 0;
}

.session-stats {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.session-stats h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff001;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: white;
}

/* Session zones */
.session-zones {
    padding: 0;
}

.session-zones h4 {
    margin: 0;
    padding: 16px 16px 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #fff001;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zone-list {
    max-height: 400px;
    overflow-y: auto;
}

.zone-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.zone-item:hover {
    background-color: #f8f9fa;
}

.zone-item.highlighted {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding-left: 12px;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.zone-name {
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.zone-sequence {
    background: #007acc;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.zone-details {
    display: flex;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.zone-time {
    font-size: 12px;
    color: #ccc;
    font-weight: 500;
}

.zone-distance {
    font-size: 12px;
    color: #aaa;
}

.zone-points {
    font-size: 12px;
    color: #28a745;
    font-weight: 600;
}

.zone-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.take-type-small {
    background: #28a745;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.enemy-small {
    color: #dc3545;
    font-size: 11px;
    font-weight: 500;
}

/* Loading states */
.stats-loading,
.zones-loading,
.no-data {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Responsive design */
@media (max-width: 1024px) {
    .session-info-control {
        max-width: 320px;
        max-height: 60vh;
    }
    
    .session-content {
        max-height: calc(60vh - 50px);
    }
}

@media (max-width: 768px) {
    body.session-map #map {
        min-height: 300px;
    }
    
    .session-info-control {
        max-width: 280px;
        max-height: 50vh;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .zone-details {
        flex-direction: column;
        gap: 4px;
    }
    
    .session-content {
        max-height: calc(50vh - 50px);
    }
}

@media (max-width: 480px) {
    body.session-map #map-header {
        padding: 0;
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }
    
    .zone-item {
        padding: 10px 12px;
    }
    
    .session-stats {
        padding: 12px;
    }
    
    .session-zones h4 {
        padding: 12px 12px 8px 12px;
    }
}

/* Dark theme support */
body.session-map.dark-theme .session-info-control {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

body.session-map.dark-theme .session-header {
    background: #1a202c;
    border-bottom-color: #4a5568;
}

body.session-map.dark-theme .session-title {
    color: #e2e8f0;
}

body.session-map.dark-theme .session-toggle {
    color: #a0aec0;
}

body.session-map.dark-theme .session-toggle:hover {
    background: #4a5568;
}

body.session-map.dark-theme .zone-item {
    border-bottom-color: #4a5568;
}

body.session-map.dark-theme .zone-item:hover {
    background-color: #374151;
}

body.session-map.dark-theme .zone-name {
    color: #e2e8f0;
}

body.session-map.dark-theme .stat-value {
    color: #e2e8f0;
}

/* Custom scrollbar */
.session-content::-webkit-scrollbar,
.zone-list::-webkit-scrollbar {
    width: 6px;
}

.session-content::-webkit-scrollbar-track,
.zone-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.session-content::-webkit-scrollbar-thumb,
.zone-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.session-content::-webkit-scrollbar-thumb:hover,
.zone-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Session Layout - Responsive zone list layout */
.session-layout {
    flex: 1; /* Take remaining height after menu */
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow shrinking */
}

/* Desktop Layout - Left Panel */
@media (min-width: 769px) {
    .session-layout {
        display: flex;
        flex-direction: column;
        height: 100%; /* Take full height from flexbox parent */
        position: relative;
    }
    
    .map-container {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        min-height: 0; /* Allow shrinking below content size */
        overflow: hidden; /* Prevent overflow */
    }
    
    .zone-list-panel {
        width: 280px;
        min-width: 250px;
        max-width: 300px;
        background-color: #333;
        border-right: 1px solid #666;
        color: white;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        z-index: 1000;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
    }
    
    .zone-list-panel.minimized {
        width: 50px;
        min-width: 50px;
    }
    
    .zone-list-panel.minimized .zone-list-content {
        display: none;
    }
    
    .zone-list-panel.minimized .zone-list-header h3 {
        display: none;
    }
    
    .zone-list-panel.minimized .toggle-list-btn {
        width: 100%;
        text-align: center;
    }
    
    .map-container #map {
        flex: 1;
        height: auto;
        position: relative;
    }
}

/* Mobile Layout - Bottom Panel */
@media (max-width: 768px) {
    .session-layout {
        display: flex;
        flex-direction: column;
        height: 100%; /* Take full height from flexbox parent */
    }
    
    .map-container {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        min-height: 0; /* Allow proper flexbox shrinking */
        overflow: hidden; /* Prevent overflow */
    }
    
    .zone-list-panel {
        background-color: #333;
        border-top: 1px solid #666;
        color: white;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: fit-content; /* Size to content */
        max-height: 50vh; /* Don't take more than half the screen */
        min-height: 0; /* Allow panel to shrink to content */
        z-index: 1000;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
    }
    
    .zone-list-panel.minimized {
        height: 50px;
    }
    
    .zone-list-panel.minimized .zone-list-content {
        display: none;
    }
    
    .zone-list-content {
        overflow-x: auto;
        overflow-y: hidden;
        flex: 0 0 auto; /* Don't grow, just fit content */
        height: auto; /* Let content determine height */
        min-height: 0;
        display: block; /* Ensure it's a block element */
    }
    
    .zone-list-horizontal {
        display: flex;
        flex-direction: row;
        gap: 0;
        width: max-content;
        height: fit-content; /* Fit to content height */
        align-items: stretch;
        min-height: 0; /* No minimum height */
        margin: 0; /* No margins */
        padding: 0; /* No padding */
    }
    
    .zone-list-item {
        flex: 0 0 auto;
        width: 200px; /* Increased width for better readability */
        border-right: 1px solid #333;
        border-bottom: none;
        padding: 8px 10px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        height: fit-content; /* Fit to content height */
        min-height: 0;
        overflow: hidden;
        box-sizing: border-box; /* Include padding in height */
    }
    
    .map-container #map {
        flex: 1;
        position: relative;
    }
}

.zone-list-header {
    background-color: #555;
    border-bottom: 1px solid #666;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 16px;
    flex-shrink: 0;
    flex-grow: 0; /* Don't grow */
}

.zone-list-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff001;
}

.zone-list-controls {
    display: flex;
    gap: 8px;
}

.toggle-list-btn {
    background-color: #333;
    border: 1px solid #666;
    color: #fff001;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    min-width: 30px;
    text-align: center;
}

.toggle-list-btn:hover {
    background-color: #555;
}

.zone-list-content {
    flex: 0 0 auto; /* Don't grow, just fit content */
    overflow-y: auto;
    padding: 0;
    min-height: 0; /* Allow flexbox to shrink properly */
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack children vertically */
}

/* Force horizontal scrolling on mobile */
@media (max-width: 768px) {
    .zone-list-content {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        height: fit-content !important; /* Fit exactly to content */
        min-height: 0; /* No minimum height - let content determine */
        max-height: none; /* No max height constraint */
        flex: none; /* No flex sizing */
        display: block;
    }
    
    .zone-list-horizontal {
        height: fit-content; /* Fit exactly to content */
        min-height: 0; /* No minimum height */
        display: flex !important; /* Force horizontal layout */
        flex-direction: row !important;
    }
    
    /* Force zone stats to always use 2 rows for consistent height */
    .zone-list-item-stats {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 2px;
        height: auto; /* Let content determine height */
        align-items: center;
    }
    
    /* Ensure stats fill the grid properly */
    .zone-list-item-stat {
        grid-column: span 1;
        text-align: center;
        font-size: 10px;
    }
    
    /* Force mobile zone items to be horizontal */
    .zone-list-item {
        flex: 0 0 auto !important;
        width: 200px !important;
        display: flex !important;
        flex-direction: column !important;
    }
}

/* Force vertical scrolling on desktop */
@media (min-width: 769px) {
    .zone-list-content {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
    
    .zone-list-horizontal {
        display: block !important; /* Force vertical layout */
    }
}

.zone-list-loading {
    padding: 20px;
    text-align: center;
    color: #ccc;
    font-style: italic;
}

.zone-list-item {
    padding: 8px 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.zone-list-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.zone-list-item.highlighted {
    background-color: rgba(255, 240, 1, 0.1);
    border-left: 4px solid #fff001;
    padding-left: 12px;
}

.zone-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.zone-list-item-name {
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.zone-list-item-sequence {
    background: #fff001;
    color: #000;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.zone-list-item-datetime {
    color: #ccc;
    font-size: 10px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.zone-list-item-stats {
    display: flex;
    gap: 2px;
    margin-bottom: 4px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.zone-list-item-stat {
    font-size: 11px;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 2px;
}

.zone-list-item-points {
    margin-bottom: 4px;
    flex-shrink: 0;
}

.zone-list-item-points-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.zone-list-item-points .zone-list-item-stat {
    color: #28a745;
    font-weight: 600;
    font-size: 12px;
}

.zone-list-item-total {
    color: #fff001;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.zone-list-item-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 10px;
    margin-top: auto;
    flex-shrink: 0;
}

.zone-list-item-type {
    background: #28a745;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.zone-list-item-type.assist {
    background: #ffc107;
    color: #000;
}

.zone-list-item-type.revisit {
    background: #6c757d;
}

.zone-list-item-enemy {
    color: #ccc;
}

.map-container {
    position: relative;
    background: #f0f0f0;
}

/* Small mobile adjustments */
/* Compact header for mobile/bottom layout */
@media (max-width: 768px) {
    .zone-list-header {
        padding: 4px 8px;
        min-height: 12px;
    }
    
    .zone-list-header h3 {
        font-size: 12px;
        margin: 0;
    }
    
    .toggle-list-btn {
        padding: 3px 6px;
        font-size: 12px;
        min-width: 24px;
    }
}

@media (max-width: 480px) {
    .zone-list-panel {
        height: auto; /* Dynamic height */
        max-height: 45vh; /* Slightly smaller on very small screens */
    }
    
    .zone-list-item {
        width: 190px; /* Slightly smaller on very small screens */
        padding: 8px;
    }
    
    .zone-list-item-details {
        flex-direction: column;
        gap: 4px;
    }
    
    .zone-list-header {
        padding: 3px 6px;
        min-height: 10px;
    }
    
    .zone-list-header h3 {
        font-size: 11px;
    }
    
    .toggle-list-btn {
        padding: 2px 4px;
        font-size: 11px;
        min-width: 20px;
    }
}

/* Print styles */
@media print {
    .session-info-control {
        position: static !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }
    
    .session-content {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .zone-list {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .zone-list-content {
        max-height: none !important;
        overflow: visible !important;
    }
}