/* Base styles */
:root {
    --primary-color: #6200ee;
    --secondary-color: #03dac6;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --error-color: #cf6679;
    --warning-color: #efb233;
    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.2);
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 120px;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-bottom: 0.5rem;
    font-weight: 700;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.site-name {
    font-size: 1.5rem;
    margin: 0;
}

/* Main content */
#main {
    padding: 1rem;
    margin-top: 70px;
    /* Adjusted by JS */
    flex: 1;
}

.page-title {
    text-align: left;
    margin-bottom: 1.5rem;
}

/* Authentication */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 1rem;
    padding-bottom: 100px;
    /* Space for fixed footer */
}

.auth-box {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.auth-box h2 {
    margin-bottom: 1.5rem;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Inputs and buttons */
input,
button {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(98, 0, 238, 0.3);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background-color: #7a36ff;
}

button:active {
    transform: translateY(1px);
}

fieldset {
    margin: 0 auto 1rem;
    padding: 0.5rem;
    width: 100%;
    max-width: 400px;
}

/* Warning and info messages */
.warnings-container {
    text-align: center;
    margin: 1rem auto;
    width: 100%;
    max-width: 700px;
}

.info,
.warn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.info {
    background-color: rgba(239, 178, 51, 0.1);
    border-left: 4px solid var(--warning-color);
}

.warn {
    background-color: rgba(255, 60, 60, 0.1);
    border-left: 4px solid var(--error-color);
    max-width: 700px;
}

.info svg,
.warn svg {
    margin-right: 0.75rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error messages */
.error-message {
    background-color: var(--error-color);
    color: white;
    padding: 1rem;
    text-align: center;
    margin: 1rem 0;
    border-radius: 4px;
}

/* Footer */
footer {
    background-color: var(--surface-color);
    color: var(--text-secondary);
    padding: 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 90;
}

footer .site-name {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .site-name {
        font-size: 1.25rem;
    }

    .auth-box {
        padding: 1.5rem;
    }

    input,
    select,
    button {
        padding: 0.6rem 0.8rem;
    }

    footer .site-name {
        font-size: 0.875rem;
    }
}

/* Hide elements when printing */
@media print {
    body * {
        visibility: hidden;
    }

    .auth-overlay,
    header,
    footer {
        display: none;
    }
}

/* Load button */
#main button {
    display: block;
    margin: 1rem auto;
    width: 100%;
    max-width: 400px;
}

select {
    padding: 12px 16px;
    height: 48px;
    line-height: 24px;
    border-radius: 4px;
    border: 1px solid #ccc;
    color: white;
    background-color: rgb(82, 82, 82);
    font-size: 14px;
    width: 100%;
    cursor: pointer;
    outline: none;
}

select:hover {
    border-color: #888;
}

select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, .25);
}

.status-info {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
}

.time-remaining {
    font-size: 1.2em;
    font-weight: bold;
    color: #efb233;
}

.status-error {
    background: rgba(255, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
    color: #ff6b6b;
}

.lang-switch {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

#auth-container .lang-switch,
#main .lang-switch {
    width: 100%;
    padding: 0.5rem;
}

.lang-btn {
    min-width: 100px;
    margin: 0;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Element selectors styling */
#element-selectors {
    background: var(--surface-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem auto;
    max-width: 800px;
}

.element-selector {
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 4px;
}

.type-checkbox {
    display: inline-flex;
    align-items: center;
    margin: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
}

.type-checkbox input {
    margin-right: 0.5rem;
}

.voice-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.voice-item {
    background: var(--surface-color);
    padding: 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.voice-item.playing {
    border: 2px solid var(--error-color);
    box-shadow: 0 0 10px rgba(var(--error-color-rgb), 0.3);
    animation: pulse 2s infinite;
}

.voice-title {
    flex: 1;
    margin-right: 0.5rem;
    word-break: break-word;
    min-width: 0;
}

.voice-controls {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.play-btn,
.download-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    margin: auto !important;
}

.play-btn {
    background: var(--primary-color);
    color: white;
}

.play-btn:hover {
    background: #7a36ff;
    transform: scale(1.03);
    -webkit-transform: scale(1.03);
    -moz-transform: scale(1.03);
    -ms-transform: scale(1.03);
    -o-transform: scale(1.03);
}

.download-btn {
    background: var(--secondary-color);
    color: black;
    text-decoration: none;
}

.download-btn:hover {
    background: var(--secondary-color);
    opacity: 0.8;
    transform: scale(1.03);
    -webkit-transform: scale(1.03);
    -moz-transform: scale(1.03);
    -ms-transform: scale(1.03);
    -o-transform: scale(1.03);
}

.material-icons {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.play-btn.playing {
    background: var(--error-color);
    animation: pulse 2s infinite;
}

.bulk-controls {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.bulk-controls button {
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
    max-width: 200px;
}

.bulk-controls button span {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    white-space: nowrap;
}

.bulk-controls button svg {
    width: 1.2em;
    height: 1.2em;
}

.bulk-controls .material-icons {
    font-size: 1.2em;
}

#category-select.enabled {
    opacity: 1;
    pointer-events: auto;
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(82, 82, 82, 0.5);
}

#category-select:disabled {
    border-color: rgba(204, 204, 204, 0.5);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 10px rgba(var(--error-color-rgb), 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(var(--error-color-rgb), 0.5);
    }

    100% {
        box-shadow: 0 0 10px rgba(var(--error-color-rgb), 0.3);
    }
}

.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.progress-box {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 300px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.bulk-controls .play-all-btn.playing {
    background-color: var(--error-color);
}

.bulk-controls .play-all-btn.playing:hover {
    background-color: #e35d6a;
}

@media (max-width: 768px) {
    .bulk-controls {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .bulk-controls button {
        font-size: 0.8rem;
        padding: 0.5rem;
        min-height: 40px;
    }

    .bulk-controls .material-icons {
        font-size: 1.1em;
    }

    .voice-items {
        grid-template-columns: 1fr;
    }

    .voice-item {
        flex-wrap: nowrap;
    }

    .voice-title {
        font-size: 0.9rem;
    }

    .play-btn:hover {
        transform: none;
        -webkit-transform: none;
        -moz-transform: none;
        -ms-transform: none;
        -o-transform: none;
    }

    .download-btn:hover {
        transform: none;
        -webkit-transform: none;
        -moz-transform: none;
        -ms-transform: none;
        -o-transform: none;
    }

    .type-checkbox {
        margin: 0.25rem;
        padding: 0.35rem;
        font-size: 0.85rem;
    }

    .type-checkbox input[type="checkbox"] {
        width: 14px;
        height: 14px;
        margin-right: 0.35rem;
    }

    #type-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.25rem;
        padding: 0.25rem;
    }

    #display-selectors {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin: 0.5rem 1rem;
    }
}

.selector-label {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.type-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Language switch styling */
.lang-switch .lang-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Scroll to top button */
.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 99;
}

.scroll-top.visible {
    opacity: 1;
}

/* Scroll into view animation */
.scrolled-into-view {
    scroll-margin-top: 100px;
}

.required-selection-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    background: var(--surface-color);
    border-radius: 8px;
    margin: 1rem auto;
    max-width: 600px;
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
}

.type-container-wrapper {
    margin-top: 0.5rem;
}

.type-toggle {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.type-toggle .material-icons {
    margin-right: 0.5rem;
    transition: transform 0.3s ease;
}

.type-toggle.expanded .material-icons {
    transform: rotate(180deg);
}

#type-container {
    display: none;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#type-container.expanded {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#display-selectors {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    width: auto;
    margin: 0.5rem auto;
    max-width: 800px;
    transition: all 0.2s ease;
}

#display-selectors:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

#display-selectors:active {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(1px);
}

.type-checkbox input[type="checkbox"] {
    margin: 0;
    margin-right: 0.5rem;
}