:root {
    --bg-main: #121212;
    --bg-surface: #1e1e1e;
    --bg-surface-hover: #2c2c2c;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #6366f1; /* Índigo similar a los botones primarios modernos */
    --accent-hover: #4f46e5;
    --border: #333333;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

/* ── Auth widget at the bottom of the sidebar ─────────────────────── */
.sidebar-auth {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-google-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: #ffffff0f;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.btn-google-login:hover {
    background: #ffffff1a;
    border-color: #555;
    transform: translateY(-1px);
}

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

/* User info card */
.user-info-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.user-name-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    flex-shrink: 0;
}

.btn-logout:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-links {
    list-style: none;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    font-weight: 500;
    transition: background-color var(--transition), color var(--transition);
}

.nav-links a:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-links a.active {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.icon {
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
    max-width: 900px;
    margin: 0 auto;
}

.view.active {
    display: block;
}

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

.view-header {
    margin-bottom: 32px;
}

.view-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.view-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards & Forms */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

input[type="text"], select {
    width: 100%;
    padding: 14px 16px;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-family);
    transition: border-color var(--transition);
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color var(--transition);
}

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

/* Activities Grid */
.activities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.activity-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: transform var(--transition), border-color var(--transition);
    cursor: pointer;
}

.activity-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-header h3 {
    margin-bottom: 0;
    font-size: 1.25rem;
}

.btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity var(--transition), transform var(--transition);
}

.btn-delete:hover {
    opacity: 1;
    transform: scale(1.1);
}

.activity-card .type-badge {
    display: inline-block;
    padding: 6px 12px;
    background-color: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Preview Section */
.preview-container {
    height: 500px;
    background-color: var(--bg-surface);
    border: 2px dashed var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.play-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.8;
}

.game-placeholder h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar-header {
        border-bottom: none;
        padding: 16px 0;
    }
    
    .nav-links {
        flex-direction: row;
        padding: 0;
        gap: 4px;
    }
    
    .nav-links a {
        padding: 12px;
        font-size: 0; /* Oculta el texto en móvil para dejar solo iconos */
    }
    
    .nav-links a .icon {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 24px 16px;
    }
}

/* Form Questions */
.question-block {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    position: relative;
}

.btn-remove-question {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color var(--transition);
}

.btn-remove-question:hover {
    color: #ef4444;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.option-row input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Game Engine */
.game-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

.question-text {
    font-size: 1.8rem;
    margin-bottom: 40px;
    text-align: center;
    color: var(--text-primary);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.btn-option {
    background: var(--bg-surface);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 24px;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.btn-option:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-4px);
    box-shadow: 0 8px 15px rgba(99, 102, 241, 0.15);
}

.btn-option:disabled {
    cursor: not-allowed;
    opacity: 0.9;
    transform: none;
    box-shadow: none;
}

.btn-option.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.btn-option.incorrect {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

.game-feedback {
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.game-feedback h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.game-feedback h3.correct-text {
    color: #22c55e;
}

.game-feedback h3.incorrect-text {
    color: #ef4444;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--text-secondary);
}

.btn-whatsapp {
    background-color: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(37, 211, 102, 0.2);
}

.btn-whatsapp:hover {
    background-color: #128C7E;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(37, 211, 102, 0.3);
}

@media (max-width: 600px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
}

/* Image Preview Form */
.image-url-group {
    margin-bottom: 16px;
}

.image-preview-container {
    margin-top: 12px;
    display: none;
    text-align: center;
    background: var(--bg-main);
    padding: 12px;
    border-radius: 8px;
    border: 1px dashed var(--border);
}

.image-preview-container img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 6px;
    object-fit: contain;
}

/* Animations */
.fade-out {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-in {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.game-content {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.question-counter {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Match Game Styles */
.match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.match-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.match-item {
    background: var(--bg-surface);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    animation: slideUpFade 0.4s ease backwards;
}

.match-item img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

.match-item:hover:not(:disabled) {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.15);
}

.match-item.match-selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.02);
}

.match-item.match-matched {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    cursor: not-allowed;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
    opacity: 0.9;
    z-index: 10;
}

.match-item.match-error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

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

@media (max-width: 600px) {
    .match-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Modal de Búsqueda de Imágenes */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.image-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
}

.image-result {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    background: var(--bg-main);
}

.image-result:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

.btn-search-img {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    border: 1px dashed var(--accent);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 12px;
    width: 100%;
    text-align: center;
}

.btn-search-img:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: #818cf8;
}

.search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #1e1e1e;
    color: #ffffff;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-input::placeholder {
    color: #888;
}

.btn-search-execute {
    padding: 0 24px;
    font-size: 1.1rem;
    font-weight: bold;
}

/* Toast Notification */
.toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: #22c55e;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s, visibility 0.3s;
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}
