/* Mobile-first CSS for KvízAréna PWA */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Typography */
h2 {
    color: #007bff;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.8rem;
}

h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #333;
}

/* Quiz List Screen */
#screen-quiz-list {
    flex: 1;
}

.quiz-button {
    width: 100%;
    padding: 20px;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.quiz-button:hover {
    background-color: #0056b3;
}

.quiz-button:active {
    transform: scale(0.98);
}

.quiz-info {
    font-size: 0.9rem;
    font-weight: normal;
    margin-top: 5px;
    opacity: 0.9;
}

/* Game Screen */
#screen-game {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#game-header {
    margin-bottom: 20px;
}

#quiz-title {
    font-size: 1.5rem;
    color: #007bff;
    margin-bottom: 10px;
}

#game-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: #666;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#question-text {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-size: 1.1rem;
}

#answers-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-button {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    color: #333;
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.answer-button:hover {
    background-color: #e7f3ff;
    border-color: #007bff;
}

.answer-button:active {
    transform: scale(0.98);
}

.answer-button.correct {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.answer-button.incorrect {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.answer-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Feedback message */
.feedback-message {
    margin: 15px 0;
    padding: 15px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
}

.feedback-message.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-message.incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback-message.timeout {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Results Screen */
#screen-results {
    flex: 1;
    text-align: center;
}

#results-container {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.final-score {
    font-size: 3rem;
    font-weight: bold;
    color: #007bff;
    margin: 20px 0;
}

.score-label {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 30px;
}

.play-again-button {
    width: 100%;
    max-width: 300px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background-color: #28a745;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.play-again-button:hover {
    background-color: #218838;
}

.play-again-button:active {
    transform: scale(0.98);
}

/* Loading state */
.loading {
    text-align: center;
    color: #666;
    padding: 40px;
}

/* Error state */
.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #f5c6cb;
    margin: 20px 0;
}

/* Container for the whole timer (number + bar) */
.timer-bar-container {
    display: flex; /* Puts number and bar side-by-side */
    align-items: center; /* Vertically centers them */
    width: 100%; /* Full width of the parent (#app) */
    padding: 10px 0;
    margin-bottom: 15px; /* Space above the question */
}

/* The number (remaining seconds) */
#timer-bar-text {
    font-size: 1.5em; /* Larger number */
    font-weight: bold;
    color: #333;
    padding-right: 15px; /* Space between number and bar */
    flex-shrink: 0; /* Prevents the number from shrinking */
    transition: color 0.3s;
}

/* The "track" for the progress bar */
.timer-bar-track {
    flex-grow: 1; /* Takes up the remaining space */
    height: 10px; /* Very thin */
    background-color: #eee; /* Background color */
    border-radius: 5px;
    overflow: hidden; /* Clips the progress bar inside */
}

/* The progress bar itself */
#timer-bar-progress {
    height: 100%;
    width: 100%; /* Starts at 100% */
    background-color: #007bff; /* Blue */
    border-radius: 5px;
    /* Smooth animation for width and color */
    transition: width 0.1s linear, background-color 0.3s; 
}

/* Warning class (for both text and bar) */
#timer-bar-text.warning {
    color: #dc3545; /* Red */
}

#timer-bar-progress.warning {
    background-color: #dc3545; /* Red */
}

/* Responsive adjustments for larger screens */
@media (min-width: 768px) {
    #app {
        padding: 40px;
    }

    h2 {
        font-size: 2.2rem;
    }

    .quiz-button {
        font-size: 1.3rem;
        padding: 25px;
    }

    #question-text {
        font-size: 1.3rem;
        padding: 25px;
    }

    .answer-button {
        font-size: 1.2rem;
        padding: 20px;
    }
}

/* Login screen styles */
#screen-login {
    text-align: center;
    padding: 40px 20px;
}

#screen-login .form-group {
    margin: 20px 0;
}

#nickname-input {
    width: 100%;
    max-width: 400px;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    text-align: center;
}

#login-button {
    width: 100%;
    max-width: 400px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#login-button:hover {
    background-color: #0056b3;
}

#login-button:active {
    transform: scale(0.98);
}

/* Result item card styles */
.result-item-card {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
}
.result-item-card h4 {
    margin-top: 0;
}
.result-item-card p {
    margin: 5px 0;
}
.result-item-card .correct {
    color: #155724; /* Zelená */
}
.result-item-card .incorrect {
    color: #721c24; /* Červená */
}
.error-message {
    color: #721c24;
    font-weight: bold;
}

/* Results ranking styles */
#results-ranking {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#results-ranking h3 {
    color: #007bff;
    margin-bottom: 15px;
}

#results-ranking h4 {
    color: #28a745;
    margin-top: 15px;
}

#results-summary-container {
    margin-bottom: 20px;
}

#play-again-button {
    width: 100%;
    max-width: 400px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background-color: #28a745;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto;
}

#play-again-button:hover {
    background-color: #218838;
}

#play-again-button:active {
    transform: scale(0.98);
}

/* Style the user info (now on dark background) */
#user-info {
    color: white;
    position: relative; /* Creates positioning context for absolute positioned dropdown */
    padding: 10px;
    display: flex; /* Aligns avatar and name */
    align-items: center;
    cursor: pointer;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
}

#user-info i {
    margin-left: 5px;
}

/* Make dropdown align to the right */
.user-dropdown {
    /* (The .show class is toggled by JS) */
    display: none;
    position: absolute;
    right: 0;
    top: 100%; /* Position below the bar */
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 100;
    min-width: 170px;
}

.user-dropdown.show {
    display: block;
}

/* Ensure dropdown links have dark text for visibility on white background */
.user-dropdown a {
    display: block;
    padding: 10px 15px;
    color: #333; /* Links inside dropdown are dark */
    text-decoration: none;
    white-space: nowrap;
}
.user-dropdown a:hover {
    background: #f4f4f4;
}
.user-dropdown a i {
    margin-right: 8px;
}

/* Main Navigation */
.main-nav {
    display: flex;
    background: #343a40;
    justify-content: space-between; /* This pushes items apart */
    align-items: center; /* This vertically centers them */
    padding: 0 10px; /* Add some padding */
}
.main-nav > .nav-links-left > .nav-link {
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
}
.main-nav > .nav-links-left > .nav-link:hover {
    background: #495057;
}
.main-nav > .nav-links-left > .nav-link.active {
    border-bottom-color: #007bff;
}
.main-nav > .nav-links-left > .nav-link i {
    margin-right: 8px;
}

/* Tables */
.leaderboard-table, .history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
.leaderboard-table th, .leaderboard-table td,
.history-table th, .history-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}
.leaderboard-table th, .history-table th { 
    background: #f4f4f4; 
}
.avatar-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

/* Achievement Card */
.achievement-card {
    display: flex;
    align-items: center;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
}
.achievement-card i {
    color: #007bff;
    margin-right: 15px;
}
.achievement-card div {
    flex: 1;
}
.achievement-card strong {
    font-size: 1.1em;
}
.achievement-card p {
    margin: 5px 0 0;
    font-size: 0.9em;
    color: #555;
}

/* Screen containers */
#screen-home, #screen-leaderboard, #screen-profile, #screen-settings {
    flex: 1;
}

/* Delete button */
.delete-button {
    padding: 10px 20px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 20px;
}

.delete-button:hover {
    background-color: #c82333;
}

/* Navigation bar left-side links container */
.main-nav .nav-links-left {
    display: flex; /* Keeps left-side links together */
}

/* PWA install button icon spacing */
#install-app-btn i {
    margin-right: 8px;
}
