@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
}

.custom-select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="white"><path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.25 4.25a.75.75 0 01-1.06 0L5.21 8.27a.75.75 0 01.02-1.06z" clip-rule="evenodd" /></svg>');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5em 1.5em;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
}

input[type=range]::-moz-range-track {
    height: 8px;
    border-radius: 4px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 2px solid white;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #a855f7;
    cursor: pointer;
    margin-top: -4px;
    box-shadow: 0 0 0 2px #c084fc;
}

input[type=range]::-moz-range-thumb {
    border: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #a855f7;
    cursor: pointer;
}

/* Toggle Buttons */
.player-toggle {
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
}

.player-toggle.active {
    background-color: #16a34a !important;
    box-shadow: 0 0 10px rgba(22, 163, 74, 0.5);
}

.player-toggle:not(.active) {
    background-color: #dc2626 !important;
}

.audio-toggle {
    transition: all 0.2s;
    min-height: 44px;
}

.audio-toggle.active {
    background-color: #9333ea !important;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
}

.audio-toggle:not(.active) {
    background-color: #475569 !important;
}

.view-toggle {
    transition: all 0.2s;
    min-height: 44px;
}

.view-toggle.active {
    background-color: #9333ea !important;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
}

.view-toggle:not(.active) {
    background-color: #475569 !important;
}

/* Collapsible Header Styles */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
}

.collapsible-header:hover {
    background-color: rgba(168, 85, 247, 0.1);
}

.collapsible-header .collapse-icon {
    display: none; /* Hidden on desktop */
    transition: transform 0.3s;
}

.collapsible-content {
    overflow: visible;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.collapsible-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    overflow: hidden;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

/* View Mode Styles */
body.tabbed-mode #tab-controls {
    display: flex;
}

body.tabbed-mode .tab-content {
    display: none;
}

body.tabbed-mode .tab-content:not(.hidden) {
    display: block;
}

body.unified-mode #tab-controls {
    display: none;
}

body.unified-mode #tab-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

body.unified-mode .tab-content {
    display: block !important;
}

body.unified-mode #content-popups {
    grid-column: 1;
}

body.unified-mode #content-maps {
    grid-column: 2;
}

body.unified-mode #content-sounds {
    grid-column: 3;
}

/* Adjust content for unified view */
body.unified-mode #content-popups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

body.unified-mode #content-popups > * {
    width: 100%;
}

body.unified-mode #content-popups .grid {
    display: flex;
    flex-direction: column;
}

body.unified-mode #clear-alerts-btn {
    width: 100%;
    margin: 0 0 1rem 0;
}

/* Tabbed mode specific styles for popups/alerts tab ONLY */
body.tabbed-mode #content-popups:not(.hidden) {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

body.tabbed-mode #content-popups #clear-alerts-btn {
    grid-column: 1 / -1;
    width: 66.666%;
    margin: 0 auto;
}

/* Ensure Maps and Soundboard tabs maintain their original layout in tabbed mode */
body.tabbed-mode #content-maps:not(.hidden) {
    display: block !important;
}

body.tabbed-mode #content-sounds:not(.hidden) {
    display: block !important;
}

/* Stack map sections in unified view */
body.unified-mode #content-maps > .grid {
    display: flex !important;
    flex-direction: column;
    gap: 1.5rem;
}

/* Scale soundboard buttons in unified view */
body.unified-mode #soundboard {
    gap: 0.5rem;
}

body.unified-mode .sound-btn {
    width: 3.5rem !important;
    height: 3.5rem !important;
    padding: 0.25rem !important;
}

body.unified-mode .sound-btn i {
    width: 0.75rem !important;
    height: 0.75rem !important;
}

body.unified-mode .sound-btn span {
    font-size: 0.5rem !important;
}

/* Context Menu Styles for Custom Maps */
.context-menu {
    position: fixed;
    background: #1e293b;
    border: 1px solid #a855f7;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    min-width: 150px;
    padding: 0.25rem 0;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: #e2e8f0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-menu-item:hover {
    background: #a855f7;
    color: white;
}

.context-menu-item i {
    width: 1rem;
    height: 1rem;
}

/* Logged out state - dim the tabs when not logged in */
body.logged-out #tab-content {
    opacity: 0.5;
    pointer-events: none;
}

body.logged-out #tab-content::before {
    content: "Please enter a username to continue";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(168, 85, 247, 0.95);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* ============================================ */
/* MOBILE RESPONSIVE STYLES */
/* ============================================ */

/* Mobile: 768px and below */
@media (max-width: 768px) {
    /* Show collapse icons on mobile */
    .collapsible-header .collapse-icon {
        display: block !important;
    }

    /* Make collapsible headers more obvious on mobile */
    .collapsible-header {
        padding: 0.75rem !important;
    }

    /* Adjust padding for smaller screens */
    body > div {
        padding: 1rem !important;
    }

    /* Header controls - stack vertically */
    header .grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Make collapsible sections start collapsed on mobile */
    .mobile-collapsed {
        max-height: 0 !important;
        opacity: 0;
    }

    /* Tab controls - stack or make smaller */
    #tab-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #tab-controls .tab-button {
        flex: 1;
        min-width: 100px;
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

    /* Alert/Loot sections - stack vertically */
    body.tabbed-mode #content-popups:not(.hidden) {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    body.tabbed-mode #content-popups #clear-alerts-btn {
        width: 100% !important;
    }

    /* FIX: Alert/Loot buttons - keep them in one line but smaller */
    .space-y-1 > div,
    .space-y-\.5 > div {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.25rem;
        width: 100%;
        overflow-x: visible;
    }

    /* Party button - fixed width */
    .party-alert-btn {
        flex: 0 0 90px;
        min-width: 90px;
        max-width: 90px;
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }

    /* Player buttons - equal flex */
    .player-alert-btn {
        flex: 1;
        min-width: 38px;
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    /* Unified mode - stack vertically on mobile */
    body.unified-mode #tab-content {
        grid-template-columns: 1fr !important;
    }

    body.unified-mode #content-popups,
    body.unified-mode #content-maps,
    body.unified-mode #content-sounds {
        grid-column: 1 !important;
    }

    /* Make buttons more touch-friendly */
    button {
        min-height: 44px;
    }

    /* Larger tap targets for player toggles */
    .player-toggle {
        min-width: 48px;
        min-height: 48px;
        font-size: 1rem;
    }

    /* FIX: Map grid - single column and constrain width */
    #content-maps .grid {
        grid-template-columns: 1fr !important;
    }

    /* FIX: Map buttons - constrain to screen width */
    .map-btn {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Soundboard - adjust button size */
    #soundboard {
        gap: 0.5rem;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .sound-btn {
        width: 100% !important;
        min-height: 60px;
    }

    /* Modal adjustments */
    #map-config-modal > div {
        max-width: 95% !important;
        margin: 1rem;
    }

    /* Font size adjustments for readability */
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.125rem !important;
    }
}

/* Extra small mobile: 480px and below */
@media (max-width: 480px) {
    /* Even tighter spacing */
    body > div {
        padding: 0.5rem !important;
    }

    /* Smaller header */
    h1 {
        font-size: 1.5rem !important;
    }

    /* Tab buttons smaller */
    #tab-controls .tab-button {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* Audio/View toggles - adjust */
    .audio-toggle,
    .view-toggle {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
}
