/* ============================================
   WENDY - Mobile-First Security Learning Platform
   ============================================ */

/* CSS Variables */
:root {
    --bg-primary: #0b0f16;
    --bg-secondary: #111724;
    --bg-card: #161c2b;
    --border-color: #262f45;
    --text-primary: #e8ebf2;
    --text-secondary: #9aa3b9;
    --text-muted: #6f7b96;
    --accent: #7dd3fc;
    --accent-hover: #a5e3ff;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --touch-target: 48px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Base */
html, body {
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    flex: 1;
    padding-bottom: 80px; /* Space for bottom nav on mobile */
}

@media (min-width: 768px) {
    main {
        padding-bottom: 1rem;
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

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

.text-muted {
    color: var(--text-muted) !important;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Header / Navbar */
.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 1030;
    padding: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 16px;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    transition: color 0.15s ease;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-icon {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.bottom-nav-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cards */
.card,
.level-card,
.challenge-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover,
.level-card:hover,
.challenge-card:hover {
    border-color: var(--accent);
}

.challenge-card.completed {
    border-color: var(--success);
}

.challenge-card.locked {
    opacity: 0.6;
}

/* Buttons - Touch-friendly sizing */
.btn {
    min-height: var(--touch-target);
    padding: 12px 20px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.btn-sm {
    min-height: 40px;
    padding: 8px 16px;
}

.btn-lg {
    min-height: 56px;
    padding: 16px 32px;
    font-size: 1.1rem;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--bg-primary);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-card);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-outline-warning {
    border-color: var(--warning);
    color: var(--warning);
}

.btn-outline-warning:hover {
    background-color: var(--warning);
    color: var(--bg-primary);
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: var(--bg-primary);
}

/* Form Controls - Touch-friendly */
.form-control,
.form-select {
    min-height: var(--touch-target);
    padding: 12px 16px;
    font-size: 16px; /* Prevents iOS zoom */
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-secondary);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.15);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 6px 10px;
}

.bg-accent {
    background-color: var(--accent) !important;
}

.bg-success-soft {
    background-color: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.bg-warning-soft {
    background-color: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.completed {
    background-color: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.status-badge.unlocked {
    background-color: rgba(125, 211, 252, 0.15);
    color: var(--accent);
}

.status-badge.skipped {
    background-color: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.status-badge.locked {
    background-color: rgba(111, 123, 150, 0.15);
    color: var(--text-muted);
}

/* List Groups */
.list-group-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    padding: 16px;
}

.list-group-item:first-child {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.list-group-item:last-child {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* Challenge Cards */
.challenge-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: all 0.15s ease;
}

.challenge-item:not(.locked):hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.challenge-item.locked {
    opacity: 0.5;
}

.challenge-item.completed {
    border-left: 3px solid var(--success);
}

.challenge-icon {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
}

.challenge-content {
    flex: 1;
    min-width: 0;
}

.challenge-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.challenge-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.challenge-action {
    flex-shrink: 0;
    align-self: center;
}

/* Hints Section */
.hints-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 24px;
}

.hint-button {
    min-height: var(--touch-target);
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.hint-button:hover:not(:disabled) {
    border-color: var(--accent);
}

.hint-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint-content {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    border-left: 3px solid var(--accent);
}

/* Result/Feedback Section */
.result-section {
    padding: 20px;
    border-radius: var(--radius-md);
    margin: 20px 0;
}

.result-section.success {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid var(--success);
}

.result-section.error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--danger);
}

.result-section.info {
    background: rgba(125, 211, 252, 0.1);
    border: 1px solid var(--accent);
}

/* Strength Meter */
.strength-meter {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.strength-meter-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-meter-fill.very-weak { width: 5%; background: var(--danger); }
.strength-meter-fill.weak { width:20%; background: #fb923c; }
.strength-meter-fill.fair { width: 50%; background: var(--warning); }
.strength-meter-fill.strong { width: 70%; background: #a3e635; }
.strength-meter-fill.very-strong { width: 100%; background: var(--success); }

/* Footer */
footer {
    background-color: var(--bg-secondary);
    border-color: var(--border-color) !important;
}

/* Utility */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-primary { color: var(--accent) !important; }

/* Mobile optimizations */
@media (max-width: 576px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .btn-lg {
        width: 100%;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    main {
        padding-bottom: max(80px, calc(64px + env(safe-area-inset-bottom)));
    }
}

/* Focus states for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Animation for result reveals */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section {
    animation: slideIn 0.3s ease;
}

.result-section.danger {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--danger);
}

/* SQL Injection Challenge Styles */

/* Login Panel */
.login-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.login-panel-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f2439 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.login-panel-icon {
    font-size: 1.25rem;
}

.login-panel-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.login-panel-body {
    padding: 20px;
}

/* Query Display */
.query-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.query-display.query-injected {
    border-color: var(--danger);
    background: rgba(248, 113, 113, 0.05);
    animation: queryPulse 0.5s ease;
}

@keyframes queryPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
    50% { box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.3); }
}

.query-code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    word-break: break-all;
    white-space: normal;
}

/* Explanation Box */
.explanation-box {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Code styling in explanations */
.explanation-box code,
section code {
    background: rgba(125, 211, 252, 0.15);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

/* Dark code blocks in "What You Learned" */
.bg-darker {
    background: var(--bg-primary) !important;
}

/* Message and explanation content */
.message-box {
    line-height: 1.6;
    font-size: 0.95rem;
}

.explanation-content {
    font-size: 0.875rem;
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: inherit;
}

.hint-text {
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Alert styling for dark theme */
.alert-secondary {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* ============================================
   Error Page Styles
   ============================================ */

.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-page > .text-center {
    width: 100%;
}

.error-icon-wrapper {
    display: flex;
    justify-content: center;
}

.error-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    animation: error-pulse 2s ease-in-out infinite;
}

.error-icon-accent {
    background: rgba(125, 211, 252, 0.15);
    color: var(--accent);
    border: 2px solid var(--accent);
}

.error-icon-warning {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    border: 2px solid var(--warning);
}

.error-icon-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
    border: 2px solid var(--danger);
}

.error-icon-success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
    border: 2px solid var(--success);
}

.border-accent {
    border-color: var(--accent) !important;
}

@keyframes error-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Error page mobile optimizations */
@media (max-width: 576px) {
    .error-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .error-page {
        min-height: 50vh;
    }
}

/* Mobile adjustments for query display */
@media (max-width: 576px) {
    .query-display {
        padding: 10px 12px;
    }
    
    .query-code {
        font-size: 0.75rem;
    }
    
    .login-panel-body {
        padding: 16px;
    }
    
    .explanation-content,
    .hint-text {
        font-size: 0.8rem;
    }
}