/* Number Trainer Web Interface Styles */
/* Based on the modern GUI design with blue/green color scheme */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #2563eb;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
}

h2 {
    color: #374151;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Card component */
.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
    text-align: center;
}

/* Screen management */
.screen {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.screen.hidden {
    display: none;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-width: 120px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* Difficulty buttons */
.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.difficulty-buttons .btn {
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.btn-subtitle {
    font-size: 0.875rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Exercise screen */
.question {
    font-size: 3rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 2rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

#answer-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 2rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

#answer-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Button groups */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Result screen */
.result-message {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.result-message.correct {
    color: #10b981;
}

.result-message.incorrect {
    color: #ef4444;
}

.result-details {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

/* Statistics panel */
.stats-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 200px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stats-item:last-child {
    margin-bottom: 0;
}

.stats-label {
    color: #6b7280;
    font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        display: none;
    }

    .card {
        padding: 1.5rem;
        margin: 0 10px;
    }

    .question {
        font-size: 2.5rem;
    }

    #answer-input {
        font-size: 1.25rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .stats-panel {
        position: static;
        margin-top: 2rem;
        width: 100%;
        max-width: 500px;
    }
}

@media (max-width: 480px) {
    h1 {
        display: none;
    }

    .question {
        font-size: 2rem;
    }

    .card {
        padding: 1rem;
    }

    .difficulty-buttons .btn {
        padding: 1rem;
    }
}

/* Loading states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen {
    animation: fadeIn 0.3s ease;
}

/* Focus indicators for accessibility */
.btn:focus,
#answer-input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Back button - completely hidden by default */
.back-btn {
    display: none !important;
    position: absolute;
    visibility: hidden;
    opacity: 0;
}


/* Visibility classes - Default for desktop */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Back button styles - only on mobile */
    .back-btn {
        display: flex !important;
        position: fixed !important;
        visibility: visible !important;
        opacity: 1 !important;
        top: 20px;
        left: 20px;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid rgba(37, 99, 235, 0.2);
        padding: 8px 16px;
        cursor: pointer;
        transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
        z-index: 100;
        color: #2563eb;
        font-size: 16px;
        font-weight: 600;
        align-items: center;
        gap: 6px;
        border-radius: 12px;
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .back-btn:hover {
        background: rgba(37, 99, 235, 0.15);
        border-color: rgba(37, 99, 235, 0.4);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    }

    .back-btn:active {
        transform: scale(0.98);
        background: rgba(37, 99, 235, 0.25);
    }

    .back-btn::before {
        content: "←";
        font-size: 20px;
        font-weight: bold;
    }

    .back-btn::after {
        content: "Back";
    }

    /* Ensure container has padding for fixed button */
    .container {
        padding-top: 80px;
    }
}


/* PWA Meta Theme Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #111827;
        color: #f9fafb;
    }

    .container {
        background-color: #111827;
    }

    .card {
        background-color: #1f2937;
        color: #f9fafb;
    }

}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
    /* Enhanced touch targets */
    .btn {
        min-height: 48px; /* Apple HIG minimum */
        padding: 14px 24px;
        font-size: 16px; /* Prevent iOS zoom */
        border-radius: 12px;
        font-weight: 600;
        letter-spacing: 0.025em;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
        transition: all 0.2s ease;
    }

    .btn:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
    }

    /* Better input experience */
    #answer-input {
        min-height: 52px;
        font-size: 20px; /* Larger for readability */
        padding: 16px 20px;
        border-radius: 12px;
        border: 2px solid #e1e5e9;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        transition: all 0.2s ease;
    }

    #answer-input:focus {
        border-color: #2563eb;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
        outline: none;
    }

    /* Improved layout spacing */
    .difficulty-buttons {
        gap: 1.5rem;
        flex-direction: column;
        width: 100%;
    }

    .difficulty-buttons .btn {
        width: 100%;
        max-width: none;
        padding: 16px 24px;
    }

    .button-group {
        gap: 1rem;
        flex-direction: column;
        width: 100%;
    }

    .button-group .btn {
        width: 100%;
    }

    /* Better card spacing */
    .card {
        margin: 1rem 0.5rem;
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }

    .container {
        padding: 1rem;
        gap: 1rem;
    }

    /* Question display */
    .question {
        font-size: 2.5rem;
        margin-bottom: 2rem;
        line-height: 1.2;
    }

    /* Statistics panel */
    .stats-panel {
        margin: 1.5rem 0;
        padding: 1.5rem;
        border-radius: 12px;
    }

    .stats-item {
        padding: 0.75rem 0;
        font-size: 16px;
    }

    /* Result message improvements */
    .result-message {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
        padding: 1rem;
        border-radius: 12px;
    }
}

/* Responsive design for different screen sizes */

/* Small phones (320px - 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .card {
        margin: 0.5rem 0;
        padding: 1.5rem 1rem;
    }

    .question {
        font-size: 2rem !important;
        margin-bottom: 1.5rem;
    }

    h1 {
        display: none;
    }

    .btn {
        min-height: 52px;
        font-size: 16px;
        padding: 16px 20px;
    }

    #answer-input {
        min-height: 56px;
        font-size: 18px;
        padding: 18px 16px;
    }
}

/* Large phones / Small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 1.5rem;
        max-width: 600px;
    }

    .difficulty-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .difficulty-buttons .btn {
        flex: 1;
        min-width: 200px;
        max-width: 250px;
    }

    .question {
        font-size: 3rem;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 800px;
        padding: 2rem;
    }

    .card {
        padding: 3rem 2.5rem;
        margin: 2rem 1rem;
    }

    .difficulty-buttons {
        flex-direction: row;
        gap: 2rem;
    }

    .button-group {
        flex-direction: row;
        gap: 1.5rem;
    }

    .question {
        font-size: 3.5rem;
    }

    .btn {
        padding: 16px 32px;
        font-size: 18px;
    }
}

/* Large screens (1025px+) */
@media (min-width: 1025px) {
    .container {
        max-width: 1000px;
    }

    .card {
        padding: 3rem;
        margin: 2rem auto;
        max-width: 600px;
    }

    .question {
        font-size: 4rem;
    }
}

/* Landscape orientation optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    .container {
        padding: 1rem;
    }

    .card {
        padding: 1.5rem;
        margin: 0.5rem 0;
    }

    h1 {
        display: none;
    }

    .question {
        font-size: 2.5rem !important;
        margin-bottom: 1rem;
    }

    .stats-panel {
        margin: 1rem 0;
        padding: 1rem;
    }

    .difficulty-buttons {
        flex-direction: row;
        gap: 1rem;
    }

    .button-group {
        flex-direction: row;
        gap: 1rem;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    /* Additional padding for landscape on notched devices */
    @media (orientation: landscape) {
        .container {
            padding-left: max(1rem, env(safe-area-inset-left) + 1rem);
            padding-right: max(1rem, env(safe-area-inset-right) + 1rem);
        }
    }
}

/* Prevent text selection on buttons for better mobile experience */
.btn {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Improve input experience on mobile */
#answer-input {
    -webkit-appearance: none;
    appearance: none;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .screen {
        animation: none;
    }

    .btn {
        transition: none;
    }
}
