/**
 * Gramatika Plugin Frontend Styles
 */

/* Learning Container */
.gramatika-learning-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Step Content */
.gramatika-step-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    text-align-last: start;
}

.gramatika-step-title {
    font-size: 28px;
    font-weight: 700;
    color: #000000 !important; /* Force black color */
    margin-bottom: 15px;
    text-align: center;
}

.gramatika-step-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.gramatika-step-category {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.gramatika-step-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gramatika-step-instructions {
    font-size: 18px;
    color: #34495e;
    text-align: center;
    margin-bottom: 25px;
    font-style: italic;
}

.gramatika-step-text {
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
    margin-bottom: 25px;
}

.gramatika-step-text p {
    margin-bottom: 15px;
}

.gramatika-step-text ul,
.gramatika-step-text ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.gramatika-step-text li {
    margin-bottom: 5px;
}

/* Task Interface */
.gramatika-task-interface {
    border-top: 2px solid #ecf0f1;
    padding-top: 25px;
    margin-top: 25px;
}

/* HELP Button */
.gramatika-help-section {
    text-align: center;
    margin-bottom: 25px;
}

.gramatika-help-btn {
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.gramatika-help-btn:hover {
    background: #e67e22;
}

.gramatika-help-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    z-index: 10000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.gramatika-help-content h4 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 20px;
}

.gramatika-help-instruction {
    background: #3498db;
    color: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.gramatika-close-help {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    float: right;
}

.gramatika-close-help:hover {
    background: #7f8c8d;
}

/* Exercises Container */
.gramatika-exercises-container {
    margin-top: 20px;
}

.gramatika-exercise-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.gramatika-exercise-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.gramatika-exercise-item.completed {
    border-color: #27ae60;
    background: #f8fff9;
}

.gramatika-exercise-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Exercise Sentence */
.gramatika-exercise-sentence {
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
}

.gramatika-answer-input {
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 16px;
    width: 200px;
    max-width: 100%;
    transition: border-color 0.3s ease;
}

.gramatika-answer-input:focus {
    outline: none;
    border-color: #3498db;
}

.gramatika-answer-input:disabled {
    background: #ecf0f1;
    color: #7f8c8d;
}

/* Exercise Actions */
.gramatika-exercise-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.gramatika-check-answer-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.gramatika-check-answer-btn:hover {
    background: #2980b9;
}

.gramatika-check-answer-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.gramatika-correct-indicator {
    color: #27ae60;
    font-weight: 600;
    font-size: 16px;
}

/* Exercise Feedback */
.gramatika-exercise-feedback {
    font-size: 14px;
    font-weight: 600;
    min-height: 20px;
}

.gramatika-exercise-feedback.correct {
    color: #27ae60;
}

.gramatika-exercise-feedback.incorrect {
    color: #e74c3c;
}

/* Task Actions */
.gramatika-task-actions {
    text-align: center;
    margin-top: 30px;
}

/* Navigation */
.gramatika-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.gramatika-progress {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.gramatika-current-step-title {
    font-weight: 500;
    color: #34495e;
    font-size: 16px;
}

.gramatika-nav-buttons {
    display: flex;
    gap: 15px;
}

.gramatika-prev-btn,
.gramatika-next-btn,
.gramatika-reset-step-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.gramatika-prev-btn {
    background: #6c757d;
    color: white;
    border: none;
}

.gramatika-prev-btn:hover {
    background: #5a6268;
}

.gramatika-reset-step-btn {
    background: #dc3545;
    color: white;
    border: 2px solid #dc3545;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.gramatika-reset-step-btn:hover {
    background: #c82333;
    border-color: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.gramatika-next-btn {
    background: #28a745;
    color: white;
    border: 2px solid #28a745;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.gramatika-next-btn:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* Completion Screen */
.gramatika-completion {
    text-align: center;
    background: white;
    color: #2c3e50;
    padding: 50px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 2px solid #e9ecef;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
    position: relative;
    overflow: hidden;
}

.gramatika-completion.show {
    opacity: 1;
    transform: translateY(0);
}

.gramatika-completion-icon {
    font-size: 80px;
    margin-bottom: 30px;
    animation: celebrationBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s both;
    display: block;
}

@keyframes celebrationBounce {
    0% {
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.gramatika-completion h2 {
    font-size: 48px;
    margin-bottom: 20px;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.4s both;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gramatika-completion p {
    font-size: 24px;
    margin-bottom: 40px;
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.6s both;
    line-height: 1.4;
    font-weight: 500;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.gramatika-completion-stats {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    animation: optionsAppear 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.8s both;
}

@keyframes optionsAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gramatika-stat {
    background: rgba(255,255,255,0.2);
    padding: 20px;
    border-radius: 8px;
    margin: 0 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.gramatika-stat-number {
    font-size: 28px;
    font-weight: 700;
    display: block;
}

.gramatika-stat-label {
    font-size: 14px;
    opacity: 0.9;
}

.gramatika-completion-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    animation: optionsAppear 0.6s cubic-bezier(0.4, 0, 0.2, 1) 1s both;
}

.gramatika-restart-btn,
.gramatika-back-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 15px 25px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border: none !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
    color: white !important;
    line-height: 1.2 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    min-width: 200px !important;
    height: 56px !important;
    position: relative !important;
    overflow: hidden !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.gramatika-restart-btn {
    background: linear-gradient(135deg, #e8e8e8, #d0d0d0) !important;
    color: #495057 !important;
}

.gramatika-restart-btn:hover {
    background: linear-gradient(135deg, #d0d0d0, #e8e8e8) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
}

.gramatika-back-btn {
    background: linear-gradient(135deg, #c20000, #950000) !important;
    color: white !important;
}

.gramatika-back-btn:hover {
    background: linear-gradient(135deg, #950000, #c20000) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
}

/* Celebration smile bounce animation */
@keyframes smileBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

.gramatika-completion-icon {
    animation: smileBounce 2s ease-in-out infinite;
}

/* Confetti Animation */
.gramatika-confetti-piece {
    position: fixed;
    top: -10px;
    z-index: 9999;
    pointer-events: none;
    animation: gramatika-confetti-fall 4s ease-in-out forwards;
}

@keyframes gramatika-confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Loading States */
.gramatika-step-container.loading,
.gramatika-navigation.loading {
    opacity: 0.6;
    pointer-events: none;
}

.gramatika-step-container.loading::after,
.gramatika-navigation.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: gramatika-spin 1s linear infinite;
}

@keyframes gramatika-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Learning Mode - Hide Archive Content */
body:has(.gramatika-learning-container) #learning_archive,
.gramatika-learning-mode #learning_archive {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gramatika-learning-container {
        margin: 10px;
        padding: 15px;
    }

    .gramatika-step-title {
        font-size: 20px;
    }

    .gramatika-task-interface {
        padding: 15px;
    }

    .gramatika-navigation {
        flex-direction: column;
        gap: 15px;
    }

    .gramatika-nav-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .gramatika-prev-btn,
    .gramatika-next-btn {
        flex: 1;
        max-width: 120px;
    }

    .gramatika-completion-actions {
        flex-direction: column;
        align-items: center;
    }

    .gramatika-restart-btn,
    .gramatika-back-btn {
        width: 200px;
    }

    .gramatika-answer-input {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .gramatika-step-title {
        font-size: 18px;
    }

    .gramatika-task-instruction {
        font-size: 16px;
        padding: 12px;
    }

    .gramatika-exercise-item {
        padding: 15px;
    }

    .gramatika-answer-input {
        width: 120px;
        font-size: 14px;
    }

    .gramatika-check-answer-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .gramatika-prev-btn,
    .gramatika-next-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}
