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

html {
  height: -webkit-fill-available;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  background-color: #f0f2f5;
  color: #333;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  position: relative;
}

/* Add styles for when keyboard is open */
body.keyboard-open {
  /* Remove fixed position to allow normal scrolling */
  /* Just prevent elastic bounce/overscroll */
  overflow-x: hidden;
  touch-action: pan-y;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
  body,
  .chat-container,
  .modal-content {
    /* The height of iOS address bar is 44px */
    height: -webkit-fill-available;
  }
}

/* Main Container */
.app-container {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
  gap: 20px;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  max-height: 100vh;
}

/* Sidebar with educational content */
.sidebar {
  flex: 0 0 350px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  padding: 20px 20px 0 20px;
  position: relative;
  height: calc(100vh - 30px);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-toggle-mobile {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 8px;
  margin: 0 -20px;
  background-color: #f0f0f0;
  cursor: pointer;
  border-top: 1px solid #e0e0e0;
  margin-top: 10px;
}

.sidebar-toggle-mobile i {
  color: #666;
  transition: transform 0.3s ease;
}

.sidebar-content {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 20px;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #c9d1e0;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #a3afc2;
}

.course-info {
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.course-info h2 {
  color: #2c3e50;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.course-info p {
  color: #7f8c8d;
  font-size: 0.9rem;
}

.education-content {
  padding-bottom: 20px;
}

.education-content h3 {
  margin: 20px 0 15px;
  color: #2c3e50;
  font-weight: 600;
  font-size: 1.2rem;
}

.education-content h4 {
  margin: 15px 0 10px;
  color: #34495e;
  font-size: 1.05rem;
  font-weight: 500;
}

.phishing-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background-color: #edf2ff;
  padding: 14px;
  border-radius: 8px;
  border-left: 4px solid #4a69bd;
  transition: transform 0.2s ease;
}

.stat:hover {
  transform: translateY(-2px);
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: #4a69bd;
  margin-bottom: 3px;
}

.stat-label {
  font-size: 0.9rem;
  color: #5d6d7e;
}

.phishing-flags {
  list-style-type: none;
  margin-bottom: 25px;
  padding: 8px;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.phishing-flags li {
  margin-bottom: 12px;
  padding-left: 22px;
  position: relative;
}

.phishing-flags li:last-child {
  margin-bottom: 0;
}

.phishing-flags li:before {
  content: "•";
  color: #e74c3c;
  font-size: 18px;
  font-weight: bold;
  position: absolute;
  left: 0;
}

.example-section {
  background-color: #f9f9f9;
  padding: 16px;
  border-radius: 10px;
  margin: 20px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.assignment-examples {
  background-color: #e8f5e9;
  border-left: 4px solid #4caf50;
}

.example-btn {
  display: block;
  width: 100%;
  padding: 12px 15px;
  margin-bottom: 10px;
  background-color: #e3f2fd;
  border: 1px solid #d0e3f3;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  color: #2c3e50;
  font-weight: 500;
}

.example-btn:last-child {
  margin-bottom: 0;
}

.example-btn:hover {
  background-color: #bbdefb;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.example-btn:active {
  transform: translateY(0px);
}

/* Assignment Box Styles */
.assignment-box {
  background-color: #fff8e1;
  border: 1px solid #ffecb3;
  border-left: 5px solid #ffc107;
  border-radius: 10px;
  padding: 18px;
  margin-top: 25px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.assignment-box h3 {
  color: #e65100;
  margin-top: 0;
  font-size: 1.15rem;
  border-bottom: 1px solid #ffe0b2;
  padding-bottom: 10px;
  margin-bottom: 15px;
  font-weight: 600;
}

.assignment-box p {
  margin-bottom: 12px;
  color: #5d4037;
}

.data-list {
  list-style-type: none;
  padding: 5px 0 5px 5px;
  margin-bottom: 18px;
  columns: 2;
  column-gap: 20px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  padding: 10px;
}

.data-list li {
  margin-bottom: 8px;
  position: relative;
  padding-left: 20px;
  break-inside: avoid;
}

.data-list li:before {
  content: "→";
  color: #e65100;
  position: absolute;
  left: 0;
  font-weight: bold;
}

.assignment-note {
  background-color: #fff3e0;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-top: 12px;
  border: 1px dashed #ffcc80;
}

.assignment-note p {
  margin: 0;
  color: #5d4037;
}

.assignment-note strong {
  color: #d32f2f;
  font-weight: 600;
}

/* Chat container */
.chat-container {
  flex: 1;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 30px);
  overflow: hidden;
  position: relative;
}

header {
  padding: 20px;
  background: linear-gradient(135deg, #4a69bd, #3949ab);
  color: white;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  will-change: transform;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
}

#newChatButton {
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.9rem;
}

#newChatButton:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

#newChatButton:active {
  transform: translateY(0);
}

.chat-messages {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  background-color: #f8fafc;
  display: flex;
  flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #c9d1e0;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #a3afc2;
}

.message {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 85%;
  word-wrap: break-word;
  position: relative;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: messageAppear 0.3s ease forwards;
}

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

.user-message {
  background-color: #e3f2fd;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  color: #0d47a1;
}

.assistant-message {
  background-color: #f5f5f5;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: #333;
}

.chat-input-container {
  padding: 15px;
  display: flex;
  border-top: 1px solid #e0e0e0;
  background-color: white;
}

#messageInput {
  flex-grow: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 24px;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#messageInput:focus {
  outline: none;
  border-color: #4a69bd;
  box-shadow: 0 0 0 2px rgba(74, 105, 189, 0.2);
}

#sendButton {
  padding: 12px 20px;
  margin-left: 10px;
  background-color: #4a69bd;
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#sendButton:hover {
  background-color: #3a559c;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#sendButton:active {
  transform: translateY(0);
}

.message-time {
  font-size: 0.7em;
  color: #888;
  display: block;
  margin-top: 5px;
  text-align: right;
}

.user-message .message-time {
  color: #5b97f3;
}

.error-message {
  background-color: #fdecea;
  color: #c62828;
  border-left: 3px solid #c62828;
  align-self: center;
  max-width: 90%;
  padding: 10px 15px;
  border-radius: 6px;
  margin: 10px 0;
}

footer {
  padding: 12px 20px;
  background-color: #f9f9f9;
  border-top: 1px solid #eee;
  border-radius: 0 0 12px 12px;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

/* Tips box */
.tips-box {
  background-color: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-left: 4px solid #4caf50;
  border-radius: 8px;
  padding: 16px;
  margin-top: 25px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.tips-box h3 {
  color: #2e7d32;
  margin-top: 0;
  font-size: 1.1rem;
  border-bottom: 1px solid #c8e6c9;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.tips-box h3 i {
  margin-right: 6px;
}

.tips-list {
  list-style-type: none;
  padding-left: 0;
}

.tips-list li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 10px;
  color: #37474f;
}

.tips-list li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #4caf50;
  font-weight: bold;
}

.assignment-box h3 i,
.sidebar-content h3 i,
footer i,
header h1 i,
#newChatButton i,
#sendButton i {
  margin-right: 6px;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  opacity: 0;
  visibility: hidden;
  transform: scale(1.1);
  transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
  overflow: hidden;
}

.modal.show {
  opacity: 1;
  visibility: visible;
  transform: scale(1.0);
  transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  max-width: 90%;
  width: 600px;
  border-radius: 12px;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px;
  background: linear-gradient(135deg, #4a69bd, #3949ab);
  color: white;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #e0e0e0;
  text-align: center;
  background-color: white;
}

.modal-button {
  padding: 12px 24px;
  background-color: #4a69bd;
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: inline-block;
  min-width: 200px;
}

.modal-button:hover {
  background-color: #3a559c;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.modal-open {
  overflow: hidden;
}

/* Help button */
.help-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.25);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  margin-right: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: relative;
  /* animation: pulse 2s infinite; */
}

.help-button:hover {
  background-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

.help-button:active {
  transform: translateY(0);
}

/* Make sidebar collapsible on mobile */
.sidebar-content.expanded {
  display: block;
}

/* Responsive adjustments */
@media screen and (max-width: 992px) {
  .app-container {
    padding: 10px;
  }
  
  .sidebar {
    flex: 0 0 320px;
  }
}

@media screen and (max-width: 768px) {
  .app-container {
    flex-direction: column;
    height: auto;
    padding: 0;
    margin: 0;
    max-width: 100%;
  }
  
  .sidebar {
    display: none; /* Hide sidebar completely on mobile */
  }
  
  .chat-container {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    border-radius: 0;
    width: 100%;
    position: relative;
  }
  
  .chat-messages {
    flex: 1;
    padding: 70px 20px 80px 20px; /* Top padding for header + standard padding */
    min-height: calc(100vh - 120px); /* Account for header and input */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  header {
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
  }
  
  footer {
    border-radius: 0;
  }
  
  .data-list {
    columns: 1;
  }
  
  header h1 {
    font-size: 1.2rem;
  }
  
  .message {
    max-width: 90%;
  }
  
  #sendButton {
    padding: 12px 16px;
  }
  
  .modal-content {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px; /* Make room for the button */
  }
  
  .modal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 10;
  }
  
  /* Custom CSS variable for viewport height */
  :root {
    --vh: 1vh;
  }
  
  body.modal-open .app-container {
    filter: blur(3px);
  }
}

@media screen and (max-width: 480px) {
  .app-container {
    padding: 0;
  }
  
  .sidebar-content.expanded {
    max-height: 400px;
  }
  
  header {
    padding: 15px;
  }
  
  header h1 {
    font-size: 1.1rem;
  }
  
  .chat-input-container {
    padding: 10px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: none; /* Prevent animations when keyboard appears */
  }
  
  #messageInput {
    padding: 10px;
    font-size: 0.9rem;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 24px;
    z-index: 11;
  }
  
  #sendButton {
    padding: 10px;
    min-width: 44px;
    width: 44px;
    z-index: 11;
  }
  
  footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    opacity: 0;
    visibility: hidden;
  }
  
  #sendButton i {
    margin-right: 0;
  }
  
  .chat-container {
    height: 100svh; /* Use svh for better mobile viewport handling */
    min-height: 100svh;
  }
  
  .message {
    padding: 10px 12px;
    max-width: 95%;
    font-size: 0.95rem;
  }
  
  .course-info h2 {
    font-size: 1.1rem;
  }
  
  .assignment-box h3 {
    font-size: 1rem;
  }
  
  footer {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
  
  footer p:first-child {
    margin-bottom: 3px;
  }
  
  .modal-header h2 {
    font-size: 1.2rem;
  }
  
  .modal-button {
    width: 100%;
    padding: 14px;
  }
}