/* ============================================================
   CODE PLAYGROUND - COMMON STYLESHEET
   Unified theme variables, responsive navbar, footer & utilities
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.25);
  --dark: #0f172a;
  --dark-surface: #1e293b;
  --dark-border: #334155;
  --light-bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --border-color: #e2e8f0;
  
  --easy: #10b981;
  --easy-bg: #d1fae5;
  --medium: #f59e0b;
  --medium-bg: #fef3c7;
  --hard: #ef4444;
  --hard-bg: #fee2e2;

  --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 -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 68px;
}

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

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  background-color: var(--light-bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ============================================================
   GLOBAL NAVBAR
   ============================================================ */
.cp-navbar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.cp-nav-container {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cp-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  transition: var(--transition);
}

.cp-nav-brand:hover {
  transform: translateY(-1px);
}

.cp-nav-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  display: block;
}

.cp-nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.cp-nav-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0.25rem;
  position: relative;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.cp-nav-link:hover {
  color: #ffffff;
}

.cp-nav-link.active {
  color: #ffffff;
  font-weight: 600;
}

.cp-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--primary);
}

/* Auth Buttons in Nav */
.cp-nav-auth {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.cp-btn-nav-login {
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: var(--transition);
}

.cp-btn-nav-login:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.cp-btn-nav-signup {
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.cp-btn-nav-signup:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* User Profile Nav Pill */
.cp-user-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.cp-user-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.cp-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
  border: 1.5px solid #ffffff;
}

.cp-user-name {
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  display: none;
  flex-direction: column;
  z-index: 1010;
  animation: fadeIn 0.15s ease-out forwards;
}

.cp-user-dropdown.show {
  display: flex;
}

.cp-user-dropdown a, .cp-user-dropdown button {
  padding: 0.6rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.cp-user-dropdown a:hover, .cp-user-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.cp-user-dropdown .logout-item {
  color: #f87171;
  border-top: 1px solid #334155;
  margin-top: 0.25rem;
  padding-top: 0.6rem;
}

.cp-user-dropdown .logout-item:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* Mobile Toggle */
.cp-mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 38px;
  height: 38px;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 1.3rem;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.cp-mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Drawer Overlay */
.cp-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cp-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile Drawer */
.cp-mobile-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  max-width: 85vw;
  height: 100vh;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 25px rgba(0, 0, 0, 0.5);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem;
  overflow-y: auto;
}

.cp-mobile-drawer.active {
  right: 0;
}

.cp-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 1.5rem;
}

.cp-drawer-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.cp-drawer-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.cp-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.cp-drawer-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}

.cp-drawer-link:hover, .cp-drawer-link.active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.cp-drawer-link.active {
  border-left: 3px solid var(--primary);
  color: var(--primary-light);
}

.cp-drawer-auth {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ============================================================
   GLOBAL FOOTER
   ============================================================ */
.cp-footer {
  margin-top: auto;
  background: #0f172a;
  color: #94a3b8;
  border-top: 1px solid #1e293b;
  padding: 3.5rem 1.5rem 1.5rem;
}

.cp-footer-container {
  max-width: 1380px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.cp-footer-brand h3 {
  color: #ffffff;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cp-footer-brand p {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 320px;
  margin-bottom: 1.25rem;
}

.cp-footer-col h4 {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.cp-footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cp-footer-col a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.88rem;
  transition: var(--transition);
}

.cp-footer-col a:hover {
  color: #ffffff;
  padding-left: 3px;
}

.cp-footer-bottom {
  max-width: 1380px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.cp-social-links {
  display: flex;
  gap: 1rem;
}

.cp-social-link {
  color: #94a3b8;
  font-size: 1.1rem;
  transition: var(--transition);
  text-decoration: none;
}

.cp-social-link:hover {
  color: var(--primary);
  transform: translateY(-2px);
}

/* ============================================================
   RESPONSIVE UTILITY CLASSES
   ============================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: var(--radius);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-easy {
  color: var(--easy);
  background: var(--easy-bg);
}

.badge-medium {
  color: var(--medium);
  background: var(--medium-bg);
}

.badge-hard {
  color: var(--hard);
  background: var(--hard-bg);
}

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

/* ============================================================
   MEDIA QUERIES FOR COMMON LAYOUT
   ============================================================ */
@media (max-width: 1024px) {
  .cp-footer-container {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .cp-nav-links, .cp-nav-auth {
    display: none;
  }

  .cp-mobile-toggle {
    display: flex;
  }

  .cp-footer-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .cp-footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

/* ============================================================
   GLOBAL AUTH REQUIRED MODAL & TOAST NOTIFICATION SYSTEM
   ============================================================ */
.cp-auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.cp-auth-overlay.show {
  opacity: 1;
  visibility: visible;
}

.cp-auth-modal {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 30px rgba(99, 102, 241, 0.2);
  width: 100%;
  max-width: 440px;
  padding: 2.25rem 2rem;
  text-align: center;
  position: relative;
  transform: scale(0.95);
  transition: all 0.25s ease;
  color: #f8fafc;
}

.cp-auth-overlay.show .cp-auth-modal {
  transform: scale(1);
}

.cp-auth-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #818cf8;
}

.cp-auth-modal h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

.cp-auth-modal p {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.cp-auth-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cp-auth-btn-login {
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  color: #ffffff;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  transition: var(--transition);
  display: block;
}

.cp-auth-btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  color: #ffffff;
}

.cp-auth-btn-signup {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: var(--transition);
  display: block;
}

.cp-auth-btn-signup:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.cp-auth-btn-cancel {
  background: transparent;
  color: #64748b;
  border: none;
  padding: 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: var(--transition);
}

.cp-auth-btn-cancel:hover {
  color: #94a3b8;
}

/* Toast Notifications */
.cp-toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.cp-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
}

.cp-toast.toast-success { border-left: 4px solid #10b981; }
.cp-toast.toast-error { border-left: 4px solid #ef4444; }
.cp-toast.toast-warning { border-left: 4px solid #f59e0b; }
.cp-toast.toast-info { border-left: 4px solid #3b82f6; }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
