/* Minimal layout styles, preserving default browser look where possible */

body {
    font-family: sans-serif;
    margin: 0;
    padding: 10px; /* Reduced from 20px to save space */
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Lock height to dynamic viewport */
    box-sizing: border-box;
    overflow: hidden; /* Strict no scroll */
}

header {
    width: 100%;
    max-width: 600px;
    text-align: center;
    margin-bottom: 2rem;
}

#controls {
    margin-bottom: 1rem;
}

button {
    padding: 10px 15px;
    font-size: 1rem;
    cursor: pointer;
    margin: 5px;
}

main {
    flex: 1; /* Takes all remaining height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 600px;
    height: 100%;
    min-height: 0; /* Allows complete flexbox collapsing */
}

#flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%; /* Force fill the available main height */
    min-height: 0; /* Allow elements inside to squeeze */
    gap: 1vh; /* Use viewport relative gap */
}

#card-header {
    font-size: 1.2rem;
    font-weight: bold;
}

#word-image-container {
    width: 100%;
    flex: 1; /* Grows to take available space */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0; /* Crucial: allows the container to shrink below content size if needed */
}

#word-image {
    max-width: 100%;
    max-height: 100%; /* Fill but don't overflow the flex container */
    object-fit: contain;
}

.word-text {
    font-size: min(10vw, 8vh); /* Scalable font size */
    font-weight: bold;
    text-align: center;
    margin: 0;
    flex-shrink: 0; /* Don't compress the text */
}

#card-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-height: 60px;
    padding-bottom: 2vh; /* Extra safety padding at the bottom */
    /* Reserves space so UI doesn't jump unnecessarily */
}

#evaluation-btns {
    display: flex;
    gap: 1rem;
}

.hidden {
    display: none !important;
}

#empty-state {
    text-align: center;
    max-width: 400px;
    line-height: 1.5;
}

#status-message {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #444;
}

/* Phase 2: Decks & Library */
#library-view,
#review-view {
    width: 100%;
    height: 100%; /* Ensure view takes full container */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#current-deck-title {
    margin: 0 0 1vh 0; /* Scalable margin */
    font-size: min(6vw, 4vh);
    flex-shrink: 0;
}

.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
}

.deck-card {
    position: relative; /* For the options menu and checkbox */
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 1.5rem;
    padding-top: 2rem; /* Extra space for top elements */
    text-align: center;
    cursor: pointer;
    background-color: #f9f9f9;
    transition: background-color 0.2s;
}

.deck-card:hover {
    background-color: #eee;
}

.deck-card h3 {
    margin: 0 0 10px 0;
}

.deck-stats {
    font-size: 0.9rem;
    color: #666;
}

/* Deck Options Menu Styles */
.deck-options-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0 8px;
}

.deck-options-btn:hover {
    color: #333;
}

.deck-options-menu {
    position: absolute;
    top: 35px;
    right: 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.deck-options-menu button {
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    width: 100%;
    margin: 0;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.deck-options-menu button:last-child {
    border-bottom: none;
}

.deck-options-menu button:hover {
    background-color: #f5f5f5;
}

.text-danger {
    color: #d32f2f;
}

/* Bulk Selection Checkbox Styles */
.deck-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    z-index: 10;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.mode-btn {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: auto;
}

/* Session Report Styles */
#session-report {
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 1.2rem;
    border-bottom: 1px solid #eee;
}

.stat-row:last-child {
    border-bottom: none;
    font-weight: bold;
    margin-top: 1rem;
}