/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Pastel Palette */
    --primary: #0b5cff;
    --accent: #ffb347;
    --soft-blue: #bfe6ff;
    --mint: #b8f2d6;
    --lavender: #e6d9ff;
    --bg: #f7fbff;
    --text-dark: #2c3e50;
    --text-light: #555;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--soft-blue) 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow);
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.game-subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
}

/* Level Selector */
.level-selector-section {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.level-label {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.level-select {
    padding: 10px 20px;
    border-radius: 25px;
    border: 2px solid var(--primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    background: white;
    color: var(--text-dark);
    min-width: 200px;
}

.level-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--soft-blue);
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 20px;
    margin: 20px 0;
}

@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

/* Command Panel */
.command-panel, .controls-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--soft-blue);
}

.command-palette {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.command-item {
    background: linear-gradient(135deg, var(--soft-blue) 0%, var(--lavender) 100%);
    padding: 15px;
    border-radius: 12px;
    cursor: grab;
    user-select: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: 2px solid transparent;
    font-weight: 600;
    color: var(--text-dark);
}

.command-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px var(--shadow-hover);
    border-color: var(--primary);
}

.command-item:active {
    cursor: grabbing;
}

.command-item.dragging {
    opacity: 0.5;
}

.command-item#clear-btn {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #ffcccc 0%, #ffb347 100%);
    cursor: pointer;
}

.command-icon {
    font-size: 1.5rem;
}

.command-text {
    font-size: 0.85rem;
}

/* Sequence Area */
.sequence-area {
    min-height: 300px;
    border: 2px dashed var(--primary);
    border-radius: 12px;
    padding: 15px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-hint {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 20px;
}

.sequence-item {
    background: linear-gradient(135deg, var(--mint) 0%, var(--soft-blue) 100%);
    padding: 12px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid var(--primary);
    cursor: move;
    transition: all 0.3s ease;
}

.sequence-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 8px var(--shadow);
}

.sequence-item.dragging {
    opacity: 0.5;
}

.sequence-item .remove-btn {
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sequence-item .remove-btn:hover {
    transform: scale(1.1);
}

.loop-block, .if-block {
    border-left: 4px solid var(--accent);
    padding-left: 10px;
    margin-left: 10px;
}

.loop-label, .if-label {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 5px;
}

.loop-inner, .if-inner {
    transition: all 0.3s ease;
}

.loop-inner:hover, .if-inner:hover {
    border-color: var(--primary) !important;
    background-color: rgba(191, 230, 255, 0.5) !important;
}

.loop-inner.drag-over, .if-inner.drag-over {
    border-color: var(--success) !important;
    background-color: rgba(76, 175, 80, 0.3) !important;
    transform: scale(1.02);
}

/* Game Board */
.game-board-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--shadow);
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--soft-blue);
}

.board-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.robot-status {
    font-weight: 600;
    color: var(--text-dark);
}

#robot-direction {
    font-size: 1.5rem;
    margin-left: 5px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    background: var(--text-dark);
    padding: 4px;
    border-radius: 8px;
    max-width: 600px;
    margin: 0 auto 15px;
}

.cell {
    aspect-ratio: 1;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    position: relative;
    transition: all 0.3s ease;
}

.cell.target {
    background: var(--mint);
    border: 3px solid var(--success);
}

.cell.item {
    background: var(--lavender);
}

.cell.obstacle {
    background: #cccccc;
    border: 2px solid #999;
}

.cell.robot {
    background: var(--soft-blue);
    border: 3px solid var(--primary);
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.board-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding-top: 15px;
    border-top: 2px solid var(--soft-blue);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.legend-icon {
    font-size: 1.5rem;
}

/* Control Buttons */
.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    text-align: center;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--soft-blue);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--soft-blue) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--lavender) 0%, var(--soft-blue) 100%);
    color: var(--text-dark);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent) 0%, #ffcc99 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-info {
    background: linear-gradient(135deg, var(--mint) 0%, var(--soft-blue) 100%);
    color: var(--text-dark);
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Log Area */
.log-area {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg);
    border: 2px solid var(--soft-blue);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.log-empty {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 20px;
}

.log-entry {
    padding: 8px 12px;
    margin-bottom: 5px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
    font-size: 0.9rem;
}

.log-entry.error {
    border-left-color: var(--error);
    background: #ffebee;
}

.log-entry.success {
    border-left-color: var(--success);
    background: #e8f5e9;
}

/* Mission Area */
.mission-area {
    background: var(--bg);
    border: 2px solid var(--soft-blue);
    border-radius: 12px;
    padding: 15px;
    min-height: 100px;
}

.mission-text {
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 0.95rem;
}

.mission-text strong {
    color: var(--primary);
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideDown 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--error);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 1.5rem;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    margin-bottom: 15px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--soft-blue);
}

#feedback-content {
    text-align: center;
    padding: 20px 0;
}

#feedback-content.success {
    color: var(--success);
    font-size: 1.5rem;
    font-weight: 600;
}

#feedback-content.error {
    color: var(--error);
    font-size: 1.2rem;
}

/* Teacher Section */
.teacher-section {
    margin-top: 40px;
    margin-bottom: 40px;
}

.teacher-card {
    background: linear-gradient(135deg, #fff9e6 0%, var(--bg) 100%);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 2px solid var(--accent);
}

.section-title {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--accent);
}

.teacher-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
}

.teacher-note {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.teacher-note h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.teacher-note h4 {
    color: var(--accent);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.teacher-note ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.teacher-note li {
    padding: 5px 0;
    line-height: 1.6;
    color: var(--text-dark);
}

.teacher-note li strong {
    color: var(--primary);
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--text-dark) 0%, #34495e 100%);
    color: white;
    text-align: center;
    padding: 30px 20px;
    margin-top: 50px;
}

.footer-note {
    margin-top: 10px;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Accessibility */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.8rem;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .command-palette {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-board {
        max-width: 100%;
    }

    .teacher-content {
        grid-template-columns: 1fr;
    }

    .control-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }

    .command-palette {
        grid-template-columns: 1fr;
    }

    .control-buttons {
        grid-template-columns: 1fr;
    }
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
