/* Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --gray: #6b7280;
    --light: #f3f4f6;
    --dark: #1f2937;
}

body {
    font-family: system-ui, sans-serif;
    color: var(--dark);
    line-height: 1.5;
}

button {
    cursor: pointer;
    border: none;
    background: var(--light);
    padding: 8px 16px;
    border-radius: 4px;
}

button:hover {
    background: var(--primary);
    color: white;
}

/* Header */
header {
    padding: 20px;
    text-align: center;
}

.logo {
    max-width: 200px;
    filter: invert(1);
}

/* Search */
.search-bar {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px;
    border-bottom: 1px solid var(--light);
    display: flex;
    gap: 8px;
    justify-content: center;
    z-index: 100;
    align-items: center;
}

.search-bar input,
.search-bar select {
    padding: 8px 12px;
    border: 1px solid var(--light);
    border-radius: 4px;
}

.search-bar input {
    flex: 1;
    max-width: 70%;
    min-width: 0;
}

.search-bar select,
.search-bar button {
    flex-shrink: 0;
}

/* Content */
#content {
    margin: 0 auto;
    padding: 20px;
}

.concert-card {
    border: 1px solid var(--light);
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 4px;
}

/* Default single column for concert items */
.concert-items-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 12px;
    margin: 0 -12px;
}

/* One-column layout for concert items on tablets and up */
@media (min-width: 400px) {
    .concert-items-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Two-column layout for concert items on wide displays */
@media (min-width: 600px) {
    .concert-items-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 24px;
        column-gap: 24px;
    }
}

/* Three-column layout for very wide displays */
@media (min-width: 900px) {
    .concert-items-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0 32px;
    }
}

.concert-header {
    background: var(--light);
    padding: 12px;
    margin: -16px -16px 16px;
}

.piece-card {
    display: flex;
    padding: 6px 6px;
    border: 4px solid white;
    align-items: flex-start;
    box-sizing: border-box;
}

.piece-card:hover {
    border-left: 4px solid #ccc;
    border-top: 4px solid #fff;
    border-right: 4px solid #fff;
    border-bottom: 4px solid #fff;
}

.piece-card.highlight {
    background: rgba(37, 99, 235, 0.1);
}

.piece-actions {
    display: flex;
    gap: 4px;
    margin-right: 12px;
}

.piece-content {
    flex: 1;
}

.piece-title {
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.piece-title:hover {
    color: var(--primary);
}

.lock-icon {
    width: 12px;
    opacity: 0.5;
}

.piece-subtitle {
    font-size: 14px;
    color: var(--gray);
}

.movements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
}

.movement {
    cursor: pointer;
    color: var(--gray);
    display: inline-block;
    padding: 4px 8px;
    margin: -4px -4px;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
    border-radius: 4px;
    user-select: none;
}

.movement:hover {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
    text-decoration: underline;
}

.movement:active {
    background-color: rgba(59, 130, 246, 0.2);
    transform: scale(0.98);
}

.movement:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Theater */
.theater {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
}

.theater.active {
    display: block;
}

.theater-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
}

#theater-title {
    padding-left: 1em;
    padding-right: 1em;
}

.theater-header button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    padding: 8px 12px;
}

.theater-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.theater-header span {
    color: white;
}

#download-menu {
    position: absolute;
    top: 60px;
    right: 16px;
    background: white;
    border-radius: 4px;
    padding: 8px;
    z-index: 1001;
}

#download-menu a {
    display: block;
    padding: 8px;
    color: var(--dark);
    text-decoration: none;
}

#download-menu a:hover {
    background: var(--light);
}

.theater-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100% - 60px);
    padding: 20px;
}

#media-player,
#program-viewer {
    width: 100%;
    max-width: 800px;
}

#audio,
#video {
    width: 100%;
    margin-bottom: 16px;
}

/* Simple audio visualization */
.audio-viz {
    width: 100%;
    max-width: 400px;
    height: 200px;
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 48px;
    color: white;
    opacity: 0.9;
}

#program-img {
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    color: white;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.controls button {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 20px;
    padding: 8px 12px;
    min-width: 40px;
    flex-shrink: 0;
}

.controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden,
.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
}

.modal-content img {
    width: 48px;
    margin-bottom: 16px;
}

.modal-content input {
    width: 100%;
    padding: 8px;
    margin: 16px 0;
    border: 1px solid var(--light);
    border-radius: 4px;
}

#auth-error {
    color: red;
    margin-bottom: 16px;
}

.modal-content button {
    margin: 0 4px;
}

/* Mobile */
@media (max-width: 767px) {
    .concert-items-grid {
        padding: 0;
        margin: 0;
    }

    .search-bar select {
        max-width: 110px;
        font-size: 14px;
    }

    .piece-actions {
        margin-right: 8px;
        flex-shrink: 0;
    }

    .piece-actions button {
        width: 28px;
        height: 28px;
        padding: 0;
        font-size: 14px;
    }

    .controls {
        gap: 8px;
    }

    .controls button {
        padding: 6px 10px;
        font-size: 18px;
        min-width: 35px;
    }

    .controls span {
        font-size: 14px;
    }
}
