/* Coding Practice - Main Styles */

:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --secondary-color: #f59e0b;
  --text-dark: #1f2937;
  --text-light: #4b5563;
  --text-lighter: #9ca3af;
  --white: #ffffff;
  --light-bg: #f9fafb;
  --dark-bg: #111827;
  --gray-bg: #f3f4f6;
  --border-color: #e5e7eb;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --code-bg: #282c34;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s ease;
  --header-height: 80px;
}

/* Main Container Styles */
.coding-container {
  padding: 30px 0;
}

.coding-header {
  text-align: center;
  margin-bottom: 2rem;
}

.coding-header h1 {
  color: var(--text-dark);
  margin-bottom: 1rem;
  font-weight: 700;
}

.coding-header .lead {
  color: var(--text-light);
  max-width: 800px;
  margin: 0 auto;
}

.coding-layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 1.5rem;
  min-height: calc(100vh - var(--header-height) - 100px);
}

/* Problem Section Styles */
.problem-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.problem-list {
  max-height: 300px;
  overflow-y: auto;
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) var(--light-bg);
}

.problem-list::-webkit-scrollbar {
  width: 8px;
}

.problem-list::-webkit-scrollbar-track {
  background: var(--light-bg);
  border-radius: 8px;
}

.problem-list::-webkit-scrollbar-thumb {
  background-color: var(--primary-light);
  border-radius: 8px;
}

.problem-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.problem-list-item:hover {
  background-color: rgba(99, 102, 241, 0.05);
  transform: translateX(2px);
}

.problem-list-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  border-left-color: var(--primary-color);
  font-weight: 500;
}

.problem-title {
  font-weight: 500;
  color: var(--text-dark);
}

.badge {
  font-size: 0.7rem;
  padding: 0.25em 0.75em;
  border-radius: 1rem;
  font-weight: 600;
}

.badge-easy {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-medium {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-hard {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.problem-description {
  line-height: 1.7;
  color: var(--text-light);
}

.problem-description code {
  background-color: rgba(99, 102, 241, 0.1);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.9em;
}

.select-problem-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-lighter);
}

.problem-examples, .problem-constraints {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Code Editor Section Styles */
.editor-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-header {
  position: relative;
  z-index: 20; /* Higher z-index for the card header to ensure buttons are clickable */
  background-color: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
}

.language-selector {
  max-width: 140px;
}

.code-editor {
  min-height: 400px;
  border-radius: 0;
  border: 1px solid var(--border-color);
}

/* Make sure the CodeMirror editor takes full height */
.CodeMirror {
  height: 400px !important;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  border-radius: 4px;
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
}

.card-footer {
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
  padding: 1rem;
}

.timer-display {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Console Output Styles */
.output-console {
  min-height: 150px;
  max-height: 250px;
  overflow-y: auto;
  background-color: var(--code-bg);
  color: white;
  padding: 1rem;
  border-radius: 0 0 8px 8px;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  scrollbar-width: thin;
  scrollbar-color: #555 var(--code-bg);
}

.output-console::-webkit-scrollbar {
  width: 8px;
}

.output-console::-webkit-scrollbar-track {
  background: var(--code-bg);
}

.output-console::-webkit-scrollbar-thumb {
  background-color: #555;
  border-radius: 8px;
}

.console-welcome {
  color: #7c8594;
  margin-bottom: 1rem;
}

.console-error {
  color: #ff6b6b;
}

.console-success {
  color: #6bff9f;
}

.console-info {
  color: #6ba5ff;
}

.console-warning {
  color: #ffda6b;
}

/* Test Cases Styles */
.test-cases {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) var (--light-bg);
}

.test-cases::-webkit-scrollbar {
  width: 8px;
}

.test-cases::-webkit-scrollbar-track {
  background: var(--light-bg);
  border-radius: 8px;
}

.test-cases::-webkit-scrollbar-thumb {
  background-color: var(--primary-light);
  border-radius: 8px;
}

.test-case-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
  position: relative;
  z-index: 5;
}

.test-case-item:hover {
  background-color: rgba(99, 102, 241, 0.02);
}

.test-case-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.test-case-title {
  font-weight: 500;
  color: var(--text-dark);
}

.test-case-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.test-case-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.status-pending {
  color: var(--text-lighter);
  background-color: rgba(156, 163, 175, 0.1);
}

.status-success {
  color: var(--success);
  background-color: rgba(16, 185, 129, 0.1);
}

.status-error {
  color: var(--error);
  background-color: rgba(239, 68, 68, 0.1);
}

.test-case-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.test-case-input, .test-case-expected, .test-case-output {
  background-color: rgba(99, 102, 241, 0.05);
  padding: 0.5rem;
  border-radius: 4px;
  font-family: 'Roboto Mono', monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

.no-tests-message {
  display: flex;
  justify-content: center;
  padding: 2rem;
  color: var(--text-light);
}

/* Modal Styles */
.modal-backdrop {
  opacity: 0.6;
}

.success-animation {
  animation: pulse 1.5s infinite;
}

.stat-item {
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  background-color: rgba(99, 102, 241, 0.05);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-dark);
}

.solution-quality {
  text-align: center;
  margin: 15px 0;
}

.quality-label {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.quality-stars {
  color: var(--secondary-color);
  font-size: 1.5rem;
  letter-spacing: 2px;
}

/* Navbar / Mobile Menu Improvements */
.main-header {
  background-color: var(--white);
  box-shadow: var(--shadow-sm);
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
}

.mobile-menu {
  position: absolute;
  top: var(--header-height);
  left: 0;
  width: 100%;
  background-color: var(--white);
  box-shadow: var(--shadow-md);
  padding: 1rem 0;
  display: none;
  z-index: 1000;
  transform: translateY(-10px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu.active {
  transform: translateY(0);
  opacity: 1;
  display: block;
}

.mobile-menu a {
  display: block;
  padding: 0.75rem 2rem;
  color: var(--text-dark);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.mobile-menu a:hover {
  background-color: rgba(99, 102, 241, 0.05);
}

.mobile-menu a.active {
  color: var(--primary-color);
  font-weight: 500;
  background-color: rgba(99, 102, 241, 0.1);
}

.mobile-menu-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  display: none;
  color: var(--text-dark);
}

.mobile-menu-btn:focus {
  outline: none;
}

/* Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Button Enhancements */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.btn-success {
  transition: all 0.2s ease;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

/* Solution guide styling */
.solution-view {
  display: none !important;
}

/* Remove the hint about solutions */
.test-cases::after {
  content: "";
  display: none;
}

/* Toast notification styling */
.toast {
  font-size: 0.95rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast .toast-body {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
}

.toast .toast-body i {
  font-size: 1.25rem;
  margin-right: 0.75rem;
}

/* Add a specific class to handle the solution view state */
.test-cases.solutions-visible {
  position: relative;
  z-index: 10;
}

/* Make the buttons container stand out */
.test-cases-actions {
  position: relative;
  z-index: 1100 !important;
  display: flex;
  gap: 0.5rem;
}

/* Ensure modal content is above all */
.modal-content {
  position: relative;
  z-index: 1500;
}

/* Responsive Styles */
@media (max-width: 992px) {
  :root {
    --header-height: 70px;
  }
  
  .coding-container {
    margin-top: var(--header-height);
  }

  .coding-layout {
    grid-template-columns: 1fr;
  }
  
  .problem-section {
    order: 1;
  }
  
  .editor-section {
    order: 2;
  }
  
  .code-editor {
    min-height: 350px;
  }
  
  .CodeMirror {
    height: 350px !important;
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .desktop-nav {
    display: none;
  }
}

@media (max-width: 768px) {
  .coding-container {
    padding: 20px 0;
  }
  
  .editor-actions, .card-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start !important;
  }
  
  .language-selector {
    max-width: 100%;
    width: 100%;
  }
  
  .editor-actions {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    margin-top: 0.75rem;
  }
  
  .card-footer .d-flex {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .card-footer .btn {
    width: 100%;
  }
  
  .code-editor {
    min-height: 300px;
  }
  
  .CodeMirror {
    height: 300px !important;
  }
  
  .problem-list {
    max-height: 250px;
  }
}

/* Loading Animation */
.loading-indicator {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.spinner-border {
  width: 2rem;
  height: 2rem;
}

/* Footer Enhancements */
.main-footer {
  margin-top: 2rem;
}

/* API Feature Styling */
.api-feature {
  transition: opacity 0.3s ease;
}

.api-feature.d-none {
  display: none !important;
}

/* Problem actions */
.problem-actions {
  display: flex;
  align-items: center;
}

/* Recommendations styling */
.recommendations-list {
  max-height: 400px;
  overflow-y: auto;
}

.recommendation-item {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.recommendation-item:last-child {
  border-bottom: none;
}

.recommendation-item:hover {
  background-color: rgba(99, 102, 241, 0.05);
}

.recommendation-reason {
  font-style: italic;
}

/* PDF download button */
#download-pdf {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}
