/**
 * Shared styles for Jazz Musicians Website
 * Centralizes common styles, loading indicators, and accessibility improvements
 */

/* ========== CSS Variables ========== */
:root {
    --black: #000000;
    --white: #ffffff;
    --grey: #a1a0a0;
    --grey-light: #b9b8b8;
    --grey-dark: #666666;
    --background-dark: #202020;
    --background-medium: #323131;
    --background-light: #e6e6e6;
    --accent-yellow: #e6b800;
    --error-red: #b00020;
    --link-blue: #0000EE;
}

/* ========== Base Styles ========== */
html, body {
    font-family: Georgia, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* ========== Top Bar / Navigation ========== */
.top-bar {
    display: flex;
    align-items: center;
    padding: 0.75% 6%;
    width: auto;
    background-color: rgb(0, 0, 0);
}

.titleLink {
    font-size: 1.9em;
    font-weight: bold;
    color: var(--white);
    text-decoration: none;
}

.titleLink:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

.nav-link-left {
    display: flex;
    gap: 1em;
    margin-left: 1em;
}

.nav-link-right {
    display: flex;
    align-items: center;
    gap: 1em;
    margin-left: auto;
}

#auth-controls,
#account-controls {
    display: flex;
    align-items: center;
}

/* Navigation links */
.top-bar a:not(.titleLink) {
    color: var(--white);
    text-decoration: none;
    font-size: 1.2em;
    transition: color 0.3s ease;
}

.top-bar a:not(.titleLink):hover {
    color: var(--accent-yellow);
}

.top-bar a:not(.titleLink):focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

/* ========== Buttons ========== */
.button-top {
    background-color: var(--grey);
    color: var(--black);
    border: none;
    padding: 5px 10px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    flex-wrap: wrap;
    cursor: pointer;
    margin: 0;
    transition: background-color 0.2s ease;
}

.button-top:hover {
    background-color: var(--grey-light);
}

.button-top:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

#signout-btn {
    background: none;
    font-size: 18px;
    color: var(--white);
}

#signout-btn:hover {
    color: var(--accent-yellow);
}

#signout-btn:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

.link-button {
    margin: 1em 0;
    padding: 0.4em;
    border-radius: 7px;
    border: none;
    display: flex;
    color: var(--black);
    background-color: var(--grey);
    font-size: 20px;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.link-button:hover {
    background-color: var(--grey-light);
}

.link-button:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

/* ========== Horizontal/Vertical Lines ========== */
.horizontal-line {
    background-color: var(--white);
    height: 2px;
    width: 100%;
    margin-top: 2em;
    margin-bottom: 2em;
}

.vertical-line {
    background-color: var(--black);
    width: 2px;
    height: 100px;
}

/* ========== Form Elements ========== */
.input-box {
    height: 30px;
    font-size: 18px;
    width: 98%;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.input-box:focus {
    outline: 2px solid var(--accent-yellow);
    border-color: var(--accent-yellow);
}

.search-button {
    border-radius: 7px;
    border: none;
    width: 30%;
    height: 2.5em;
    font-size: 20px;
    align-self: center;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background-color 0.2s ease;
}

.search-button:hover {
    opacity: 0.9;
}

.search-button:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

/* ========== Panels / Cards ========== */
.panel {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 14px;
    box-sizing: border-box;
    width: 100%;
}

/* ========== Instrument/Genre Picker Styles ========== */
.selected-instruments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    min-height: 1.5em;
}

.instrument-tag {
    background: #ddd;
    color: #000;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.instrument-tag button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
}

.instrument-tag button:focus {
    outline: 2px solid var(--accent-yellow);
}

.instrument-dropdown {
    border: 1px solid #ccc;
    background: #fff;
    max-height: 180px;
    overflow: auto;
    width: 220px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    padding: 6px 0;
    position: absolute;
    z-index: 200;
}

.instrument-options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.instrument-options li {
    padding: 8px 12px;
    cursor: pointer;
}

.instrument-options li:hover,
.instrument-options li:focus {
    background: #f0f0f0;
}

/* ========== Loading Indicators ========== */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.loading-indicator::before {
    content: '';
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid #ddd;
    border-top-color: var(--accent-yellow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Loading skeleton animation */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading overlay for buttons */
button.is-loading,
.btn.is-loading {
    position: relative;
    color: transparent !important;
}

button.is-loading::after,
.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========== Animations ========== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== Accessibility ========== */

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--black);
    color: var(--white);
    padding: 8px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Ensure focus is visible on all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== Responsive Utilities ========== */
@media (max-width: 768px) {
    .top-bar {
        flex-wrap: wrap;
        padding: 2% 4%;
    }
    
    .nav-link-left {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
    
    .nav-link-right {
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
}

/* ========== Helper Text ========== */
.helper-text {
    color: #666;
    font-size: 12px;
}

/* ========== Error States ========== */
.error-message {
    color: var(--error-red);
    font-size: 14px;
    margin-top: 8px;
}

.input-error {
    border-color: var(--error-red) !important;
}

.input-error:focus {
    outline-color: var(--error-red);
}