/* Brand palettes: BookTube keeps the original red on black, NoTube is blue on black.
   The brand is set on <html data-brand="..."> by the app before the first paint. */
:root {
    --accent: #ff6b6b;
    --accent-hover: #ff5252;
    --accent-glow: rgba(255, 107, 107, 0.3);
    --bg: #1a1a1a;
    --surface: #2a2a2a;
    --surface-hover: #333;
    --border: #444;
    --control: #444;
    --control-hover: #555;
}

html[data-brand="notube"] {
    --accent: #4d8dff;
    --accent-hover: #2f6fe0;
    --accent-glow: rgba(77, 141, 255, 0.3);
    --bg: #14171f;
    --surface: #1f2430;
    --surface-hover: #262d3c;
    --border: #333c4d;
    --control: #313a4d;
    --control-hover: #3d4860;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

.screen {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: none;
    z-index: 1;
}

.screen.active {
    display: block !important;
    z-index: 10;
}

/* Main Screen Styles */
#mainScreen {
    display: flex;
    flex-direction: column;
}

#mainScreen.active {
    display: flex !important;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    font-size: 2.5rem;
    color: var(--accent);
}

h1 {
    font-size: 2rem;
    margin: 0;
}

.subtitle {
    font-size: 0.9rem;
    color: #888;
    margin-left: -10px;
}

.header-icons {
    display: flex;
    gap: 25px;
    align-items: center;
}

.favorites-icon,
.help-icon,
.close-icon {
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.3s;
    z-index: 100;
    position: relative;
}

.favorites-icon:hover,
.help-icon:hover,
.close-icon:hover {
    color: var(--accent);
}

.form-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    margin-top: -10vh;
}

form {
    background: var(--surface);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 280px;
}

.form-group {
    margin-bottom: 8px;
}

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #ddd;
    font-size: 0.9rem;
}

input[type="text"],
select {
    width: 100%;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.play-button {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 15px;
}

.play-button:hover {
    background: var(--accent-hover);
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    color: var(--accent);
    font-size: 1rem;
}

.loading-indicator.active {
    display: flex;
}

.loading-indicator i {
    font-size: 1.2rem;
}

/* Player Screen Styles */
#playerScreen {
    display: none;
}

#playerScreen.active {
    display: block !important;
}

.player-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#youtubePlayer {
    width: 100%;
    height: 100%;
}

.overlay-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 2.5rem;
    color: var(--accent);
    cursor: pointer;
    background: rgba(0,0,0,0.7);
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s;
    z-index: 1000;
}

.overlay-logo:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.1);
}

/* Sleep Timer Overlay */
.sleep-timer-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    padding: 15px 20px;
    border-radius: 10px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
}

.sleep-timer-overlay.active {
    display: flex;
}

.sleep-timer-overlay i {
    color: var(--accent);
}

#sleepTimerDisplay {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.timer-reset-select {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #fff;
    font-size: 0.9rem;
    padding: 5px;
    cursor: pointer;
    z-index: 1001;
}

.sleep-timer-overlay.show-select .timer-reset-select {
    display: block;
}

.sleep-timer-overlay.warning {
    background: var(--accent-glow);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0,0,0,0.8);
}

/* Near the top rather than a percentage down the viewport, and scrollable instead of
   running off the bottom of a phone screen */
.modal-content {
    background-color: var(--surface);
    margin: 4vh auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 10px;
    width: calc(100% - 32px);
    max-width: 400px;
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--accent);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--accent);
}

.modal-content p {
    margin: 10px 0;
}

.modal-content p.rename-note {
    font-size: 0.85em;
    color: #aaa;
}

.modal-content p.about-meta {
    margin: 8px 0 0;
    font-size: 0.8em;
    color: #888;
}

.modal-content a {
    color: var(--accent);
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

.sponsor-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 18px 0 4px;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.3s, color 0.3s;
}

/* Outlined, so it does not compete with the solid red Reset button */
.modal-content a.sponsor-button {
    color: var(--accent);
}

.modal-content a.sponsor-button:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.settings-buttons {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.settings-button {
    flex: 1;
    background: var(--control);
    color: #ddd;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.3s;
}

.settings-button:hover {
    background: var(--control-hover);
}

.reset-button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
    transition: background 0.3s;
}

.reset-button:hover {
    background: #c82333;
}

/* Favorites Screen */
#favoritesScreen {
    display: none;
    flex-direction: column;
    background: var(--bg);
}

#favoritesScreen.active {
    display: flex !important;
    z-index: 20;
}

.favorites-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Custom scrollbar for favorites */
.favorites-container::-webkit-scrollbar {
    width: 16px;
}

.favorites-container::-webkit-scrollbar-track {
    background: var(--surface);
}

.favorites-container::-webkit-scrollbar-thumb {
    background: var(--control);
    border-radius: 4px;
}

.favorites-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.favorites-list {
    max-width: 800px;
    margin: 0 auto;
}

.close-icon {
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.3s;
}

.close-icon:hover {
    color: var(--accent);
}

#backFromFavorites {
    cursor: pointer;
    transition: color 0.3s;
}

#backFromFavorites:hover {
    color: var(--accent-hover);
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin: 8px 0;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: background 0.3s;
}

.favorite-item:hover {
    background: var(--surface-hover);
}

.favorite-info {
    flex: 1;
    cursor: pointer;
}

.favorite-title {
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 4px;
}

.favorite-details {
    font-size: 0.8rem;
    color: #888;
}

.favorite-delete {
    color: #dc3545;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: color 0.3s;
}

.favorite-delete:hover {
    color: #ff4757;
}

/* Responsive */
@media (max-width: 600px) {
    header {
        padding: 15px;
    }

    .logo-title {
        gap: 10px;
    }

    .logo {
        font-size: 2rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        display: none;
    }

    .header-icons {
        gap: 20px;
    }

    .favorites-icon,
    .help-icon {
        font-size: 1.3rem;
    }

    form {
        padding: 30px 20px;
    }

    .sleep-timer-overlay {
        top: 20px;
        right: 15px;
        font-size: 1rem;
        padding: 10px 15px;
        white-space: nowrap;
    }

    #sleepTimerDisplay {
        font-size: 1.1rem;
    }

    /* Keep the About box inside a phone screen without scrolling */
    .modal-content {
        margin: 3vh auto;
        padding: 20px 16px;
    }

    .modal-content h2 {
        margin-bottom: 12px;
        font-size: 1.3rem;
    }

    .modal-content p {
        margin: 8px 0;
        font-size: 0.95rem;
    }

    .settings-button {
        font-size: 0.75rem;
        padding: 8px 6px;
    }
}
