/* Pinteur Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background-color: #4CAF50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
}

.header h1 a {
    color: white;
    text-decoration: none;
}

.header nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.header nav a:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Main */
.main {
    min-height: calc(100vh - 200px);
    padding: 20px 0;
}

/* Footer */
.footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background-color: #0b7dda;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.9rem;
}

/* Forms */
.auth-form, .form-card {
    max-width: 400px;
    margin: 40px auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-form h2, .form-card h2 {
    margin-bottom: 20px;
    text-align: center;
}

.auth-form label, .form-card label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="number"],
.auth-form textarea,
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="number"],
.form-card textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.auth-form button, .form-card button {
    width: 100%;
    margin-top: 10px;
}

/* Stats Grid */
.stats-grid, .admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3, .stat-card h4 {
    margin-bottom: 10px;
    color: #666;
    font-size: 0.9rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #4CAF50;
}

.stat-value.correct {
    color: #4CAF50;
}

.stat-value.wrong {
    color: #f44336;
}

.stat-sub {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
}

/* Daily Goal Card */
.daily-goal-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.daily-goal-card h3 {
    margin-bottom: 15px;
}

.goal-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.goal-option {
    cursor: pointer;
}

.goal-option input[type="radio"] {
    display: none;
}

.goal-card {
    background: white;
    border: 2px solid #ddd;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
}

.goal-option input[type="radio"]:checked + .goal-card {
    border-color: #4CAF50;
    background-color: #f0f8f0;
}

.goal-card h3 {
    margin-bottom: 10px;
}

/* Skill Tree */
.skill-tree {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.skill-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.skill-card.locked {
    opacity: 0.6;
}

.skill-card h4 {
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.3s;
}

.locked-message {
    color: #999;
    font-style: italic;
    margin-top: 10px;
}

/* Stages Grid */
.stages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stage-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
}

.stage-card.locked {
    opacity: 0.6;
}

.stage-card h3 {
    margin-bottom: 10px;
}

.stage-info {
    color: #666;
    font-size: 0.9rem;
    margin: 10px 0;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin: 10px 0;
}

.badge.completed {
    background-color: #4CAF50;
    color: white;
}

.badge.in-progress {
    background-color: #2196F3;
    color: white;
}

.review-badge {
    background-color: #FF9800;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin: 10px 0;
    display: inline-block;
}

/* Question Card */
.question-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.question-header {
    margin-bottom: 15px;
}

.question-number {
    color: #666;
    font-size: 0.9rem;
}

.question-text {
    margin: 15px 0;
    font-size: 1.1rem;
}

.options-list {
    list-style: none;
    margin: 15px 0;
}

.option-item {
    display: block;
    padding: 10px;
    margin: 5px 0;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.option-item:hover {
    background-color: #e9e9e9;
}

.option-item input[type="radio"] {
    margin-right: 10px;
}

.numeric-input, .word-answer {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.ordering-list {
    list-style: none;
    margin: 15px 0;
}

.ordering-list li {
    padding: 10px;
    margin: 5px 0;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: move;
}

.ordering-list li.selected {
    background-color: #e3f2fd;
}

/* Completion Page */
.completion-page, .success-page, .error-page {
    max-width: 600px;
    margin: 40px auto;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.completion-page h2, .success-page h2, .error-page h2 {
    margin-bottom: 20px;
}

.results {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
}

.result-item {
    text-align: center;
}

.error-message {
    color: #f44336;
    margin: 20px 0;
}

.success-message {
    color: #4CAF50;
    margin: 20px 0;
}

.info-message {
    color: #2196F3;
    margin: 20px 0;
}

/* Actions */
.actions {
    margin: 20px 0;
    text-align: center;
}

.actions .btn {
    margin: 0 10px;
}

/* Admin */
.admin-table {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 20px 0;
    overflow-x: auto;
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.admin-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.admin-nav ul {
    list-style: none;
    margin: 20px 0;
}

.admin-nav li {
    margin: 10px 0;
}

.admin-nav a {
    color: #2196F3;
    text-decoration: none;
    font-size: 1.1rem;
}

.admin-nav a:hover {
    text-decoration: underline;
}

.analytics-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.analytics-section h3 {
    margin-bottom: 15px;
}

/* Profile */
.profile-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.profile-section h3 {
    margin-bottom: 15px;
}

.xp-progress {
    margin: 20px 0;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.achievement-badge {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #4CAF50;
}

.achievement-badge h4 {
    margin-bottom: 10px;
    color: #4CAF50;
}

/* Numpad Styles */
.numpad-container {
    margin: 20px 0;
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.numpad-btn {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    user-select: none;
}

.numpad-btn:hover {
    background: #f0f0f0;
    border-color: #4CAF50;
}

.numpad-btn:active,
.numpad-btn-pressed {
    background: #4CAF50;
    color: white;
    transform: scale(0.95);
}

.numpad-btn-action {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

.numpad-btn-action:hover {
    background: #0b7dda;
    border-color: #0b7dda;
}

.numpad-btn-zero {
    grid-column: span 2;
}

.numeric-input {
    font-size: 1.5rem;
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
    /* Prevent mobile keyboard from appearing */
    caret-color: transparent;
}

.numeric-input:focus {
    outline: none;
    caret-color: transparent;
}

/* Prevent keyboard on mobile devices - input is readonly and managed by numpad */
.numeric-input[readonly] {
    cursor: default;
}

/* Continuous Learning Styles */
.continuous-learning-container {
    max-width: 800px;
}

.learning-header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.progress-info {
    margin-top: 15px;
}

#progress-text {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #666;
}

.stages-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.stage-boundary {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    background: #f9f9f9;
    transition: all 0.3s ease;
}

.stage-boundary.locked {
    opacity: 0.6;
    background: #f0f0f0;
    pointer-events: none;
}

.stage-boundary.completed {
    border-color: #4CAF50;
    background: #f1f8f4;
}

.stage-boundary.unlocked {
    border-color: #2196F3;
}

.stage-header h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.stage-description {
    color: #666;
    margin: 0 0 15px 0;
    font-size: 0.9rem;
}

.stage-progress {
    font-size: 14px;
    color: #666;
    font-weight: bold;
}

.locked-text {
    color: #999;
}

.question-wrapper {
    margin: 20px 0;
    transition: opacity 0.3s ease;
}

.question-wrapper.hidden {
    display: none;
}

.question-wrapper.active {
    display: block;
}

.question-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.stage-indicator {
    background: #2196F3;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.question-text {
    font-size: 1.3rem;
    margin: 20px 0;
    line-height: 1.6;
    color: #333;
}

.question-answer {
    margin: 20px 0;
}

.question-actions {
    margin-top: 30px;
    text-align: center;
}

.check-answer-btn,
.next-question-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
}

.question-feedback {
    margin-top: 20px;
    padding: 20px;
    border-radius: 8px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-feedback.correct {
    background: #d4edda;
    border: 2px solid #c3e6cb;
    color: #155724;
}

.question-feedback.incorrect {
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    color: #721c24;
}

.feedback-message {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.feedback-explanation {
    font-size: 0.95rem;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

/* ========== Mobile & responsive ========== */
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.container {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header {
        padding: 12px 0;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .header .container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header h1 {
        font-size: 1.25rem;
        text-align: center;
    }

    .header nav {
        margin-top: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .header nav a {
        margin-left: 0;
        padding: 10px 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.95rem;
    }

    .main {
        min-height: calc(100vh - 180px);
        padding: 16px 0;
    }

    .footer {
        padding: 16px;
        margin-top: 24px;
        font-size: 0.9rem;
    }

    /* Buttons – touch-friendly */
    .btn {
        padding: 14px 24px;
        min-height: 48px;
        font-size: 1rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-small {
        padding: 10px 16px;
        min-height: 44px;
        font-size: 0.9rem;
    }

    .auth-form, .form-card {
        margin: 24px auto;
        padding: 24px 20px;
        border-radius: 12px;
    }

    .auth-form h2, .form-card h2 {
        font-size: 1.35rem;
        margin-bottom: 20px;
    }

    .auth-form input, .form-card input, .auth-form textarea, .form-card textarea {
        padding: 14px;
        font-size: 16px; /* avoids iOS zoom on focus */
        min-height: 48px;
    }

    .stats-grid, .admin-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin: 20px 0;
    }

    .stat-card {
        padding: 16px;
        border-radius: 12px;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .stages-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stage-card {
        padding: 18px;
        border-radius: 12px;
    }

    .goal-options {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .goals-grid .goal-card {
        padding: 18px;
    }

    /* Question card & learn */
    .question-card {
        padding: 20px 16px;
        border-radius: 12px;
        margin: 16px 0;
    }

    .question-text {
        font-size: 1.15rem;
        line-height: 1.5;
        margin: 16px 0;
    }

    .numeric-input, .word-answer {
        padding: 14px;
        font-size: 16px;
        min-height: 48px;
    }

    .numpad-grid {
        max-width: 100%;
        gap: 8px;
    }

    .numpad-btn {
        padding: 18px 12px;
        font-size: 1.35rem;
        min-height: 52px;
        border-radius: 10px;
    }

    .numpad-btn-zero {
        grid-column: span 2;
    }

    /* Completion / success / error pages */
    .completion-page, .success-page, .error-page {
        margin: 24px 16px;
        padding: 28px 20px;
        border-radius: 12px;
    }

    .results {
        flex-direction: column;
        gap: 20px;
        margin: 24px 0;
    }

    /* Admin */
    .admin-table {
        padding: 12px;
        margin: 16px 0;
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table th, .admin-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .admin-nav ul {
        margin: 16px 0;
    }

    .admin-nav a {
        display: block;
        padding: 12px 0;
        min-height: 44px;
        line-height: 1.4;
    }

    .actions .btn {
        margin: 8px 6px;
        display: inline-flex;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .stats-grid, .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .header nav a {
        flex: 1 1 auto;
        min-width: 0;
    }

    .modal-content {
        width: calc(100% - 24px);
        margin: 12px;
        max-height: 90vh;
        overflow-y: auto;
    }
}
