/**
 * style.css - Style aplikacji tabliczki mnożenia
 */

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

:root {
    --bg-color: #f5f0e6;
    --bg-secondary: #fff;
    --text-color: #333;
    --text-light: #666;
    --correct: #4caf50;
    --incorrect: #f44336;
    --accent: #ef5350;
    --accent-light: #ef7b7b;
    --shadow: rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --numpad-bg: #f5f5f5;
    --numpad-key: #fff;
    --numpad-key-hover: #e8e8e8;
    --numpad-key-pressed: #ddd;
    --tryagain: #ff9800;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
.header {
    background: var(--bg-secondary);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
    text-decoration: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--accent-light);
}

/* Main container */
.main-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 15px;
}

/* Status panel */
.status-panel {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 25px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    box-shadow: 0 2px 10px var(--shadow);
}

.status-item {
    text-align: center;
    flex-shrink: 0;
}

.status-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent);
}

.progress-container {
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Start section */
.start-section {
    text-align: center;
    padding: 50px 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px var(--shadow);
}

.start-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 20px;
}

.start-section h2 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.start-section p {
    color: var(--text-light);
    margin-bottom: 30px;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #ddd;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #ccc;
}

.btn-large {
    padding: 16px 40px;
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}

/* Game section */
.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Problem display */
.problem-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 25px;
    padding-bottom: 60px;
    box-shadow: 0 4px 15px var(--shadow);
    width: 100%;
    text-align: center;
    position: relative;
    overflow: visible;
}

.problem-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 3.5rem;
    font-weight: bold;
    font-family: 'Consolas', 'Courier New', monospace;
    margin-bottom: 15px;
}

.operand {
    color: var(--text-color);
}

.operator {
    color: var(--accent);
}

.equals {
    color: var(--text-light);
}

.answer-wrapper {
    position: relative;
    display: inline-block;
    overflow: visible;
}

.problem-display {
    overflow: visible;
}

.answer-blank {
    display: inline-block;
    min-width: 100px;
    padding: 5px 15px;
    background: #f0f0f0;
    border: 3px dashed #ccc;
    border-radius: 10px;
    color: var(--text-light);
    transition: all 0.2s;
}

.answer-blank.has-value {
    background: #fff;
    border-style: solid;
    border-color: var(--accent);
    color: var(--text-color);
}

.answer-blank.correct-answer {
    background: #e8f5e9;
    border-color: var(--correct);
    color: var(--correct);
    animation: bounce 0.5s ease;
}

.answer-blank.wrong-answer {
    background: #ffebee;
    border-color: var(--incorrect);
    color: var(--incorrect);
    animation: shake 0.4s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* Feedback */
.feedback-container {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.feedback {
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.feedback.correct {
    background: var(--correct);
    color: white;
}

.feedback.incorrect {
    background: var(--incorrect);
    color: white;
}

.feedback.tryagain {
    background: var(--tryagain);
    color: white;
}

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

/* Numpad */
.numpad-section {
    width: 100%;
}

.numpad-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 280px;
    margin: 0 auto;
}

.numpad-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.numpad-key {
    width: 70px;
    height: 70px;
    font-size: 1.8rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.1s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.key-digit {
    background: var(--numpad-key);
    color: var(--text-color);
    box-shadow: 0 3px 6px var(--shadow);
}

.key-digit:hover {
    background: var(--numpad-key-hover);
}

.key-digit.pressed {
    background: var(--numpad-key-pressed);
    transform: translateY(2px);
    box-shadow: 0 1px 3px var(--shadow);
}

.key-clear {
    background: #ffcdd2;
    color: var(--incorrect);
    box-shadow: 0 3px 6px var(--shadow);
}

.key-clear:hover {
    background: #ef9a9a;
}

.key-clear.pressed {
    background: #e57373;
    transform: translateY(2px);
}

.key-submit {
    background: var(--correct);
    color: white;
    box-shadow: 0 3px 6px var(--shadow);
}

.key-submit:hover {
    background: #66bb6a;
}

.key-submit.pressed {
    background: #43a047;
    transform: translateY(2px);
}

.numpad-key.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Visualization */
#visualization-container {
    margin-top: 15px;
    padding: 15px;
    background: #fafafa;
    border-radius: var(--border-radius);
}

#visualization-container.hidden {
    display: none;
}

.dot-grid {
    display: grid;
    justify-content: center;
    margin-bottom: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotAppear 0.3s ease forwards;
    opacity: 0;
}

@keyframes dotAppear {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.division-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

.dot-group {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.visualization-label {
    font-size: 0.85rem;
    color: var(--text-light);
    text-align: center;
}

/* Result panel */
.result-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.result-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
    position: relative;
}

.result-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-close:hover {
    background: #e0e0e0;
    color: var(--text-color);
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.result-emoji {
    font-size: 4rem;
    margin-bottom: 10px;
}

.result-content h2 {
    margin-bottom: 20px;
    color: var(--accent);
}

.result-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Config page */
.config-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.config-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 4px 15px var(--shadow);
}

.config-card h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--accent);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.form-group-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.radio-option:hover,
.checkbox-option:hover {
    background: #eee;
}

.radio-option input,
.checkbox-option input {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.table-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.table-checkbox:hover {
    background: #eee;
}

.table-checkbox input {
    display: none;
}

.table-checkbox.selected {
    background: var(--accent);
    color: white;
}

select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.form-actions .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 600px) {
    .header {
        flex-direction: column;
        gap: 10px;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .status-panel {
        gap: 15px;
        padding: 8px 12px;
    }

    .status-value {
        font-size: 1.1rem;
    }

    .problem-display {
        font-size: 2.5rem;
        gap: 10px;
    }

    .answer-blank {
        min-width: 70px;
        padding: 3px 10px;
    }

    .numpad-key {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .numpad-container {
        max-width: 220px;
    }

    .numpad-row {
        gap: 8px;
    }

    .result-stats {
        flex-direction: column;
        gap: 15px;
    }

    .form-actions {
        flex-direction: column;
    }

    .tables-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .table-checkbox {
        padding: 10px 8px;
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    .problem-display {
        font-size: 2rem;
    }

    .numpad-key {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .numpad-container {
        max-width: 200px;
    }
}
