/* App-specific styles for Video Shuffler */
:root {
    --theme-primary: #E11D48;
    --theme-primary-light: #F43F5E;
    --theme-primary-dark: #BE123C;
    --theme-secondary-accent: #FB7185;
    --theme-primary-bg: #FFF1F2;
    --theme-secondary-bg: #FFE4E6;
    --theme-text-on-primary: #ffffff;
    
    --app-bg-main: #FFFFFF;
    --app-bg-page: var(--theme-primary-bg);
    --app-bg-sidebar: var(--theme-secondary-bg);
    --app-border-color: #FAD5D8;
    --app-text-secondary: var(--theme-primary-dark);
    --app-btn-disabled-bg-new: #E6BFC2;
    --app-btn-disabled-text-new: #946A70;
}

main > .page-section:first-of-type {
    background-color: var(--app-bg-page);
}

.app-container {
  border: 1px solid var(--app-border-color);
  border-radius: 24px;
  overflow: hidden;
  background-color: var(--app-bg-main);
  text-align: left;
  transition: all 0.3s ease-in-out;
}
.app-header {
  display: grid;
  grid-template-columns: 1fr 13fr 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  background-color: var(--theme-primary);
  color: var(--theme-text-on-primary);
  border-bottom: 1px solid var(--theme-primary-dark);
}
.app-header-title {
    grid-column: 2;
    text-align: center;
    padding: 0 1rem;
}
.app-header .btn-icon {
    justify-self: end;
}
.app-header h2 {
    font-size: 1.2rem;
    margin: 0;
}
.app-main {
  display: grid;
  grid-template-columns: minmax(240px, 34%) 1fr;
}

.app-sidebar, .app-content {
  padding: 1.5rem;
  min-width: 0;
}
.app-sidebar {
    border-right: 1px solid var(--app-border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--app-bg-sidebar);
}
.app-sidebar section {
  margin-bottom: 1rem;
}
.app-sidebar section:last-child {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 1rem;
}
.app-sidebar h3 {
  font-size: 1.1rem;
  border-bottom: 2px solid var(--theme-primary);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}
.info-box {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: #ffffff;
    border-radius: 24px;
    font-size: 0.85rem;
    line-height: 1.4;
    border-left: 4px solid var(--theme-primary);
    margin: 1rem 0;
}
.info-box i {
    font-size: 1.5rem;
    color: var(--theme-primary);
    margin-top: 0.25rem;
}
.info-box a {
    color: var(--theme-primary);
    font-weight: 600;
}
.actions-message {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--app-border-color);
    border-radius: 24px;
    margin-bottom: 0.5rem;
    min-height: 50px;
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-color);
    transition: all 0.3s ease;
}
.app-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.app-actions .btn {
    flex: 1;
}
.app-actions .btn-primary {
    background-color: var(--theme-primary);
    color: var(--theme-text-on-primary);
}
.app-actions .btn-primary:hover {
    background-color: var(--theme-primary-dark);
}

.app-container .btn:disabled,
.app-container .btn-primary:disabled,
.app-container .btn-secondary:disabled {
  background-color: var(--app-btn-disabled-bg-new);
  color: var(--app-btn-disabled-text-new);
  border-color: transparent;
  opacity: 1;
}

.btn-icon {
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--theme-text-on-primary);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.btn-icon .fa-compress {
    display: none;
}
.app-container.is-focused .btn-icon .fa-expand {
    display: none;
}
.app-container.is-focused .btn-icon .fa-compress {
    display: inline-block;
}

/* === Focus Mode === */
body.focus-mode-active {
    overflow: hidden;
}
body.focus-mode-active .site-header,
body.focus-mode-active .site-footer,
body.focus-mode-active main > *:not(#app-section-wrapper) {
    display: none;
}
body.focus-mode-active #app-section-wrapper {
    padding: 0;
    background-color: transparent;
}
body.focus-mode-active #app-section-wrapper .container {
    max-width: none;
    padding: 0;
}
.app-container.is-focused {
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    width: 100%;
}
.app-container.is-focused .app-main {
    flex-grow: 1;
    min-height: 0;
}
.app-container.is-focused .app-sidebar,
.app-container.is-focused .app-content {
    display: flex;
    flex-direction: column;
}

/* More balanced compact styles for focus mode */
.app-container.is-focused .app-header {
    padding: 1rem 1.5rem;
}
.app-container.is-focused .app-header-title {
    padding: 0 0.5rem;
}
.app-container.is-focused .app-header h2 {
    font-size: 1.1rem;
}
.app-container.is-focused .app-sidebar,
.app-container.is-focused .app-content {
    padding: 1rem;
}
.app-container.is-focused .app-sidebar section {
    margin-bottom: 0.5rem;
}
.app-container.is-focused .app-sidebar section:last-child {
    margin-top: auto;
    padding-top: 1rem;
}
.app-container.is-focused .app-sidebar h3 {
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    font-size: 1rem;
}
.app-container.is-focused .info-box {
    margin: 0.5rem 0;
    padding: 0.85rem 1rem;
}
.app-container.is-focused .file-drop-zone {
    padding: 1.5rem 1rem;
}
/* === End Focus Mode === */


/* === File Drop Zone (Style unified across shufflers) === */
.file-drop-zone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    border: 2px dashed var(--app-border-color);
    border-radius: 24px;
    background-color: #ffffff;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, padding 0.3s ease;
}
.file-drop-zone:hover, .file-drop-zone.is-dragover {
    background-color: var(--theme-primary-bg);
    border-color: var(--theme-primary);
}
.file-drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.file-drop-zone-text {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-color);
}
.file-drop-zone-text i {
    font-size: 1.8rem;
    color: var(--theme-primary);
    display: block;
    margin-bottom: 0.5rem;
}
.file-drop-zone-info {
    font-size: 0.9rem;
    color: var(--app-text-secondary);
}

.flashcard-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.flashcard-status {
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.progress-container {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.autoplay-toggle-container,
.filename-toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    justify-self: center;
}
.autoplay-toggle-container {
    grid-column: 1;
}
.filename-toggle-container {
    grid-column: 3;
}

.autoplay-toggle-wrapper,
.filename-toggle-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.card-counter {
    font-weight: 700;
    font-size: 1.2rem;
}
.progress-bar {
    width: 80%;
    height: 12px;
    background-color: var(--app-border-color);
    border-radius: 12px;
    overflow: hidden;
    margin: 0 auto;
}
.progress-bar-inner {
    height: 100%;
    background-color: var(--theme-primary);
    transition: width 0.3s ease;
}
.toggle-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

/* === Toggle Control (Shared) === */
.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 1.2rem;
    color: var(--text-color);
}
.toggle-control input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-ui {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: var(--app-border-color);
    border-radius: 11px;
    transition: background-color 0.2s ease-in-out;
    flex-shrink: 0;
}
.toggle-ui::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s ease-in-out;
}
.toggle-control input:checked + .toggle-ui {
    background-color: var(--theme-primary);
}
.toggle-control input:checked + .toggle-ui::after {
    transform: translateX(18px);
}

.flashcard-area {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.flashcard {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 60vh;
    border: 1px solid var(--app-border-color);
    border-radius: 24px;
    background-color: var(--app-bg-page);
    overflow: hidden;
    transition: height 0.3s ease;
    flex-shrink: 0;
}
.flashcard-face {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flashcard-face .video-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.flashcard-intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--app-text-secondary);
    font-weight: 500;
}
.flashcard-intro-content i {
    display: block;
    margin-bottom: 1rem;
    font-size: 3.5rem;
    color: var(--text-color);
}
.flashcard-intro-content p {
    font-size: 1.5rem;
    text-align: center;
}


/* === Overlaid Captions & Static Controls === */
.flashcard-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 1rem 1.5rem;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    text-align: center;
    word-break: break-word;
    z-index: 10;
}
.flashcard.is-name-visible .flashcard-caption {
    transform: translateY(0);
    opacity: 1;
}
.flashcard-caption p {
    margin: 0;
    line-height: 1.2;
}
/* Font size classes for caption */
.flashcard-caption.font-size-xl { font-size: 2.75rem; }
.flashcard-caption.font-size-lg { font-size: 2.25rem; }
.flashcard-caption.font-size-md { font-size: 1.75rem; }
.flashcard-caption.font-size-sm { font-size: 1.4rem; }

.video-player-wrapper {
    margin-top: 1rem;
}

.custom-video-player {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.player-btn {
    background-color: var(--theme-primary);
    border: none;
    color: var(--theme-text-on-primary);
    font-size: 1.4rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    border-radius: 50%;
}
.player-btn:hover:not(:disabled) {
    background-color: var(--theme-primary-dark);
}
.player-btn:disabled {
    background-color: var(--app-btn-disabled-bg-new);
    color: var(--app-btn-disabled-text-new);
    opacity: 1;
    cursor: not-allowed;
}
.play-pause-btn .fa-pause { display: none; }
.play-pause-btn.is-playing .fa-play { display: none; }
.play-pause-btn.is-playing .fa-pause { display: block; }

.volume-btn .fa-volume-mute { display: none; }
.volume-btn.is-muted .fa-volume-up { display: none; }
.volume-btn.is-muted .fa-volume-mute { display: block; }

.fullscreen-btn .fa-compress-alt { display: none; }
.flashcard-viewer.is-theatre-mode .fullscreen-btn .fa-expand-alt { display: none; }
.flashcard-viewer.is-theatre-mode .fullscreen-btn .fa-compress-alt { display: block; }

.player-timeline {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.player-time-current, .player-time-duration {
    color: var(--app-text-secondary);
    font-size: 0.9rem;
    font-family: 'Courier New', Courier, monospace;
    min-width: 35px;
    text-align: center;
}
.player-progress-container {
    width: 100%;
    height: 8px;
    background-color: var(--app-border-color);
    border-radius: 4px;
    cursor: pointer;
}
.player-progress-bar {
    width: 0;
    height: 100%;
    background-color: var(--theme-secondary-accent);
    border-radius: 4px;
    transition: width 0.1s linear;
}
.player-volume-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.player-volume-slider {
    width: 80px;
    cursor: pointer;
}

/* Custom Range Slider Styles (Shared) */
input[type=range].player-volume-slider { -webkit-appearance: none; background: transparent; }
input[type=range].player-volume-slider:focus { outline: none; }
input[type=range].player-volume-slider::-webkit-slider-runnable-track { width: 100%; height: 6px; cursor: pointer; background: var(--app-border-color); border-radius: 3px; }
input[type=range].player-volume-slider::-webkit-slider-thumb { -webkit-appearance: none; height: 14px; width: 14px; border-radius: 50%; background: var(--theme-primary); cursor: pointer; margin-top: -4px; }
input[type=range].player-volume-slider::-moz-range-track { width: 100%; height: 6px; cursor: pointer; background: var(--app-border-color); border-radius: 3px; }
input[type=range].player-volume-slider::-moz-range-thumb { height: 14px; width: 14px; border-radius: 50%; background: var(--theme-primary); cursor: pointer; border: none; }

.flashcard-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}
.flashcard-controls .btn-primary {
    background-color: var(--theme-primary);
    color: var(--theme-text-on-primary);
}
.flashcard-controls .btn-primary:hover {
    background-color: var(--theme-primary-dark);
}

/* === Player Theatre Mode === */
.flashcard-viewer.is-theatre-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(var(--vh, 1vh) * 100); /* Use viewport variable for consistency */
    background-color: black;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-sizing: border-box;
}
.flashcard-viewer.is-theatre-mode .flashcard-status,
.flashcard-viewer.is-theatre-mode .app-header /* A bit of a hack, but covers edge cases */ {
    display: none; 
}
.flashcard-viewer.is-theatre-mode .flashcard-area {
    width: 100%;
    height: 100%;
    flex-grow: 1;
    margin-bottom: 0;
}
.flashcard-viewer.is-theatre-mode .flashcard { 
    border: none;
    border-radius: 0;
    background-color: transparent;
    height: 100%;
    max-height: none;
    aspect-ratio: auto; /* Allow the container to fill the space */
}
.flashcard-viewer.is-theatre-mode .flashcard-controls {
    display: none;
}
.flashcard-viewer.is-theatre-mode .video-player-wrapper {
    flex-shrink: 0; /* Prevent player from shrinking */
}


/* === Unified Responsive Styles === */

/* Large desktops */
@media (min-width: 768px) {
    .app-container.is-focused {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%; /* More reliable than 100vw */
        height: calc(var(--vh, 1vh) * 100); /* Fix for vh units */
        z-index: 2000;
    }
    .app-container.is-focused .app-main {
        overflow-y: auto;
        grid-template-columns: minmax(240px, 25%) 1fr;
    }
    .app-container.is-focused .app-sidebar {
        overflow-y: auto;
    }

    .app-container.is-focused .flashcard-caption.font-size-xl { font-size: 3.5rem; }
    .app-container.is-focused .flashcard-caption.font-size-lg { font-size: 2.75rem; }
    .app-container.is-focused .flashcard-caption.font-size-md { font-size: 2rem; }
    .app-container.is-focused .flashcard-caption.font-size-sm { font-size: 1.6rem; }
}

@media (min-width: 768px) and (max-width: 992px) {
    /* Make layout more compact vertically for tablets */
    .app-sidebar, .app-content {
        padding: 0.75rem;
    }
    .file-drop-zone {
        padding: 1rem;
    }
    .app-sidebar h3 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }
    .info-box {
        margin: 0.5rem 0;
        padding: 0.75rem;
    }
    .flashcard-status {
        margin-bottom: 0.5rem;
    }
    .video-player-wrapper {
        margin-top: 0.5rem;
    }
    .flashcard-controls {
        margin-top: 0.5rem;
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--app-border-color);
    }
    .flashcard-status {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
        "autoplay filename"
        "progress progress";
        gap: 1rem 0.5rem;
    }
    .progress-container {
        grid-area: progress;
        grid-column: 1 / -1;
    }
    .autoplay-toggle-container {
        grid-area: autoplay;
        justify-self: start;
    }
    .filename-toggle-container {
        grid-area: filename;
        justify-self: end;
    }
    body.focus-mode-active {
        overflow: auto;
    }
    .app-container.is-focused {
        position: static;
        height: auto;
        min-height: calc(var(--vh, 1vh) * 100); /* Fix for vh units */
    }
    .app-container.is-focused .app-main,
    .app-container.is-focused .app-sidebar {
        overflow-y: visible;
    }
    .app-container:not(.is-focused) .app-header {
        padding-top: 1.15rem;
        padding-bottom: 1.15rem;
    }
    .flashcard-controls {
        grid-template-columns: 1fr 1fr;
    }
    .app-actions .btn,
    .flashcard-controls .btn {
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
    }
}

@media (max-width: 992px) {
    .flashcard-controls {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 576px) {
    .custom-video-player {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .player-btn.play-pause-btn {
        order: 1;
    }
    .player-timeline {
        width: 100%;
        order: 0;
    }
    .player-volume-controls {
        order: 2;
        flex-grow: 1;
        justify-content: flex-start;
    }
    .player-btn.fullscreen-btn {
        order: 3;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .app-header, .app-sidebar, .app-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .app-header h2 {
        font-size: 1.05rem;
    }
    .app-actions .btn,
    .flashcard-controls .btn { 
        padding: 1rem 0.5rem; 
        gap: 0.3rem; 
    }
    .flashcard-controls {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .flashcard-intro-content p {
        font-size: 1.1rem;
    }
    .flashcard-status .toggle-label {
        display: none;
    }
    .flashcard-caption.font-size-xl { font-size: 2rem; }
    .flashcard-caption.font-size-lg { font-size: 1.7rem; }
    .flashcard-caption.font-size-md { font-size: 1.4rem; }
    .flashcard-caption.font-size-sm { font-size: 1.2rem; }
}

/* Status Messages (Shared) */
.actions-message.actions-message--success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}
.actions-message.actions-message--error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}
.actions-message.actions-message--info {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}

/* Completion Message as Card State */
.flashcard.is-completion-card {
    background-color: #fff;
}
.flashcard.is-completion-card .flashcard-face {
    background-color: #d4edda;
    color: #155724;
}
.flashcard.is-completion-card .video-element {
    display: none !important;
}
.completion-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}
.completion-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}
.completion-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.completion-content p {
    font-size: 1.2rem;
    margin: 0;
}

@media (max-width: 768px) {
    .completion-icon {
        font-size: 2.25rem;
    }
    .completion-content h3 {
        font-size: 1.3rem;
    }
    .completion-content p {
        font-size: 1.05rem;
    }
}