:root {
    /* Light mode colors */
    --background-color: #f4f4f4;
    --text-color: #333333;
    --card-background: #ffffff;
    --navbar-background: #abd8f7;
    --navbar-text: #000000;
    --primary-color: #4caf50;
    --primary-hover: #45a049;
    --secondary-color: #2196f3;
    --accent-color: #ff9800;
    --danger-color: #ff4444;
    --danger-hover: #cc0000;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --sidebar-background: rgba(255, 255, 255, 0.95);
    --card-border: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --text-shadow: rgba(0, 0, 0, 0.2);
    --gradient-start: #f4f4f4;
    --gradient-end: #e0e0e0;
  }
  
  [data-theme="dark"] {
    /* Dark mode colors */
    --background-color: #1a1a2e;
    --text-color: #e0e0e0;
    --card-background: #2d2d3d;
    --navbar-background: #000000;
    --navbar-text: #fffdfd;
    --primary-color: #00ff88;
    --primary-hover: #00cc6a;
    --secondary-color: #2196f3;
    --accent-color: #ff9800;
    --danger-color: #ff4444;
    --danger-hover: #cc0000;
    --success-color: #00ff88;
    --warning-color: #ff9800;
    --sidebar-background: rgba(0, 0, 0, 0.3);
    --card-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --text-shadow: rgba(0, 255, 136, 0.3);
    --gradient-start: #1a1a2e;
    --gradient-end: #16213e;
  }
  
  body {
    margin: 0;
    padding: 0;
    font-family: 'Orbitron', sans-serif;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-color);
    transition: all 0.3s ease;
  }
  
  /* Navbar Styles */
      .navbar {
    background: var(--navbar-background);
    backdrop-filter: blur(10px);
    color: var(--navbar-text);
    padding: 15px 0;
    width: 100%;
    top: 0;
    z-index: 1000;
    position: fixed;
    box-shadow: 0 2px 10px var(--shadow-color);
      }
     
      .navbar ul {
        display: flex;
    justify-content: space-between;
        align-items: center;
    margin: 0;
    padding: 0 20px;
    list-style: none;
  }
  
  .topbarout {
        display: flex;
    gap: 20px;
        align-items: center;
      }
    
  .topbarout a {
    color: var(--navbar-text);
    text-decoration: none;
    transition: all 0.3s ease;
  }
  
  .topbarout a:hover {
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--text-shadow);
  }
  
      /* Theme Switch */
      .switch {
        position: relative;
        display: inline-block;
    width: 60px;
    height: 34px;
  }
  
      .switch input {
        opacity: 0;
        width: 0;
        height: 0;
      }
  
      .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #2a2a2a;
        transition: 0.4s;
    border-radius: 34px;
        overflow: hidden;
      }
  
      .slider:before {
        position: absolute;
        content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: #ffd700;
        transition: 0.4s;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px #2a2a2a;
  }
  
  input:checked + .slider {
    background-color: #2196F3;
  }
  
  input:checked + .slider:before {
    transform: translateX(26px);
    background-color: #ffffff;
    box-shadow: inset 0 0 0 2px #2196F3;
  }
  
  /* Main Container Layout */
  .main-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    padding: 80px 20px 20px;
    min-height: 100vh;
  }
  
  /* Sidebar Styles */
  .sidebar {
    background: var(--sidebar-background);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px var(--shadow-color);
  }
  
  /* Profile Section */
  .profile-section {
    text-align: center;
    margin-bottom: 30px;
  }
  
  .avatar-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
  }
  
  #user-avatar {
    width: 100%;
    height: 100%;
        border-radius: 50%;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 20px var(--text-shadow);
  }
  
  .level-badge {
        position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-color);
    color: var(--background-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--background-color);
  }
  
  /* Content Area */
  .content-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .challenges-section,
  .progress-section,
  .special-challenges {
    background: var(--sidebar-background);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px var(--shadow-color);
  }
  
  /* Common Elements */
  h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--text-shadow);
  }
  
  /* Logout Button */
  #logout {
    padding: 8px 16px;
    background-color: var(--danger-color);
    border: none;
    color: var(--navbar-text);
    cursor: pointer;
    font-size: 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    margin-left: 20px;
  }
  
  #logout:hover {
    background-color: var(--danger-hover);
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--shadow-color);
  }
  
  /* Responsive Design */
  @media (max-width: 1200px) {
    .main-container {
      grid-template-columns: 250px 1fr 250px;
    }
  }
  
  @media (max-width: 992px) {
    .main-container {
      grid-template-columns: 1fr;
    }
    
    .sidebar {
      margin-bottom: 20px;
    }
  }
    
  /*for the dropdown*/
  .checkbox input[type="checkbox"] {
    display: none;
  }
  
  /* Dropdown Styles */
  .checkbox {
    position: relative;
  }
  
  .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--navbar-background);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    padding: 10px 0;
    min-width: 200px;
    z-index: 1001;
    display: none;
    border: 1px solid var(--card-border);
  }
  
  .checkbox input[type="checkbox"]:checked ~ .dropdown {
    display: block;
  }
  
  .dropdown ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  
  .dropdown ul li {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--navbar-text);
  }
  
  .dropdown ul li:hover {
    background: var(--primary-color);
    color: var(--background-color);
  }
  
  /* Button Styles */
  .button {
    display: block;
    width: 30px;
    height: 30px;
    position: relative;
    cursor: pointer;
    margin-top: 5px;
  }
  
  .button span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--navbar-text);
    position: absolute;
    transition: all 0.3s ease;
    border-radius: 3px;
  }
  
  .button span:nth-child(1) {
    top: 0;
  }
  
  .button span:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
  }
  
  .button span:nth-child(3) {
    bottom: 0;
  }
  
  /* Hamburger Animation */
  input[type="checkbox"]:checked + .button span:nth-child(1) {
    transform: rotate(45deg);
    top: 13px;
  }
  
  input[type="checkbox"]:checked + .button span:nth-child(2) {
        opacity: 0;
      }
  
  input[type="checkbox"]:checked + .button span:nth-child(3) {
    transform: rotate(-45deg);
    bottom: 13px;
  }
  
  /* Stats Container */
  .stats-container {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 10px;
  }
  
  .coins-display {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 1.2em;
      color: var(--text-color);
      background: var(--card-background);
      padding: 5px 15px;
      border-radius: 20px;
      border: 2px solid #ffd700;
      box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  }
  
  .coins-display span:first-child {
      font-size: 1.4em;
  }
  
  /* Unlock Button */
  .unlock-btn {
      background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%);
      color: #1a1a2e;
      border: none;
      padding: 10px 20px;
      border-radius: 5px;
      cursor: pointer;
      font-family: 'Orbitron', sans-serif;
      text-transform: uppercase;
      letter-spacing: 1px;
      transition: all 0.3s ease;
      margin-top: 10px;
      width: 100%;
  }
  
  .unlock-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
  }
  
  /* Challenge Card Styles */
  .challenge-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid var(--primary-color);
    backdrop-filter: blur(10px);
    color: var(--text-color);
    box-shadow: 0 4px 6px var(--shadow-color);
  }
  
  .challenge-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5em;
    text-shadow: 0 0 10px var(--text-shadow);
  }
  
  .challenge-card h4 {
    color: var(--primary-color);
    margin: 10px 0;
  }
  
  .challenge-details {
    margin: 15px 0;
  }
  
  .challenge-details ul {
    list-style-type: none;
    padding: 0;
    margin: 10px 0;
  }
  
  .challenge-details li {
    margin: 5px 0;
    padding-left: 20px;
    position: relative;
    color: var(--text-color);
  }
  
  .challenge-details li:before {
    content: '⚡';
        position: absolute;
    left: 0;
    color: var(--primary-color);
  }
  
  .challenge-details p {
    color: var(--text-color);
    margin: 10px 0;
  }
  
  .complete-btn {
    background: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 12px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    margin-top: 15px;
    width: 100%;
  }
  
  .complete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow-color);
    background: var(--primary-hover);
  }
  
  /* Special Challenge Styles */
  .challenge-card.special {
    border-color: #ffd700;
    box-shadow: 0 4px 6px rgba(255, 215, 0, 0.2);
  }
  
  .challenge-card.special h3 {
    color: #ffd700;
  }
  
  /* Answer Section */
  .answer-section {
    margin-top: 15px;
    padding: 15px;
    background: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--primary-color);
  }
  
  .answer-section h4 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
  }
  
  .answer-section p {
    color: var(--text-color);
    line-height: 1.5;
  }
  
  .rank-section {
      background: var(--card-bg);
      border-radius: 20px;
      padding: 20px;
      margin-top: 20px;
      text-align: center;
      border: 1px solid rgba(0, 255, 136, 0.1);
  }
  
  .rank-section h3 {
      color: var(--text-color);
      margin-bottom: 15px;
      font-size: 1.2rem;
  }
  
  .rank-display {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      margin-bottom: 15px;
  }
  
  .rank-image-container {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      overflow: hidden;
      border: 3px solid var(--primary-color);
      box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
      position: relative;
      background: var(--background-dark);
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.3s ease;
  }
  
  .rank-image-container:hover {
      transform: scale(1.05);
      box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
  }
  
  .rank-image-container img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.3s ease;
  }
  
  .rank-image-container:hover img {
      transform: scale(1.1);
  }
  
  .rank-name {
      font-size: 1.2rem;
      color: var(--primary-color);
      font-weight: bold;
      text-transform: uppercase;
      margin: 10px 0;
      text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
  }
  
  .rank-progress {
      width: 100%;
      padding: 0 10px;
  }
  
  .progress-bar {
      width: 100%;
      height: 10px;
      background: var(--background-dark);
      border-radius: 5px;
      overflow: hidden;
      margin-bottom: 5px;
      border: 1px solid rgba(0, 255, 136, 0.2);
  }
  
  #rank-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
      border-radius: 5px;
      transition: width 0.3s ease;
  }
  
  .rank-progress p {
      font-size: 0.9rem;
      color: var(--text-color);
      margin: 5px 0;
  }
  
  /* Add glow effect for active rank */
  .rank-image-container::after {
      content: '';
      position: absolute;
      top: -3px;
      left: -3px;
      right: -3px;
      bottom: -3px;
      border-radius: 50%;
      background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
      z-index: -1;
      opacity: 0.5;
      animation: rankGlow 2s infinite;
  }
  
  @keyframes rankGlow {
      0% {
          opacity: 0.5;
          transform: scale(1);
      }
      50% {
          opacity: 0.7;
          transform: scale(1.02);
      }
      100% {
          opacity: 0.5;
          transform: scale(1);
      }
  }

  /* Chatbot Dialog Styles */
  .chatbot-dialog {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: var(--card-background);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    cursor: move;
    border: 1px solid var(--border-color);
    resize: both;
    min-width: 300px;
    min-height: 400px;
  }

  .chatbot-dialog.active {
    display: flex;
    flex-direction: column;
  }

  .chatbot-header {
    padding: 15px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    position: relative;
    z-index: 2;
  }

  .chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
  }

  .chatbot-controls {
    display: flex;
    gap: 10px;
  }

  .control-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.3s;
  }

  .control-btn:hover {
    opacity: 0.8;
  }

  .chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
  }

  .chatbot-input-container {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
  }

  .chatbot-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-color);
    color: var(--text-color);
  }

  .chatbot-send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.3s;
  }

  .chatbot-send-btn:hover {
    background: var(--primary-color-dark);
  }

  /* Message Styles */
  .message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 5px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }

  .user-message {
    background: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
  }

  .bot-message {
    background: var(--secondary-color);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
  }

  .message-text {
    flex: 1;
    word-wrap: break-word;
    white-space: pre-line;
    line-height: 1.5;
  }

  .message-text:not(:empty)::before {
    content: '';
    display: block;
    margin-bottom: 5px;
  }

  .bot-message .message-text {
    padding-left: 5px;
  }

  .fa-spinner {
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  /* Add resize handle styles */
  .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: transparent;
    z-index: 1001;
  }

  .resize-handle.nw { top: 0; left: 0; cursor: nw-resize; }
  .resize-handle.ne { top: 0; right: 0; cursor: ne-resize; }
  .resize-handle.sw { bottom: 0; left: 0; cursor: sw-resize; }
  .resize-handle.se { bottom: 0; right: 0; cursor: se-resize; }
  .resize-handle.n { top: 0; left: 10px; right: 10px; cursor: n-resize; }
  .resize-handle.s { bottom: 0; left: 10px; right: 10px; cursor: s-resize; }
  .resize-handle.e { top: 10px; right: 0; bottom: 10px; width: 10px; cursor: e-resize; }
  .resize-handle.w { top: 10px; left: 0; bottom: 10px; width: 10px; cursor: w-resize; }

  /* Ensure content doesn't overlap with resize handles */
  .chatbot-header {
    padding: 15px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    position: relative;
    z-index: 2;
  }

  .chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
  }

  .experience-container {
    width: 100%;
    margin: 10px 0;
    background: var(--card-background);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
  }

  .experience-bar {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 5px 0;
    border: 2px solid var(--primary-color);
    position: relative;
  }

  .experience-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    transition: width 0.3s ease;
    border-radius: 10px;
    position: relative;
    width: 0%; /* Start at 0 width */
  }

  .experience-fill.active {
    width: var(--progress, 0%);
  }

  .experience-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.1) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.1) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: moveStripes 1s linear infinite;
  }

  .experience-text {
    text-align: center;
    color: var(--text-color);
    font-size: 0.9em;
    margin-top: 5px;
    font-weight: bold;
  }

  @keyframes moveStripes {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 20px 0;
    }
  }