/* Shared styles for micro web apps */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-radius: 15px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
}

/* Authentication UI */
#auth-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  margin: 2rem auto;
}

.auth-tabs {
  display: flex;
  margin-bottom: 2rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: #f8f9fa;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-tab.active {
  background: #007bff;
  color: white;
}

.auth-tab:first-child {
  border-radius: 8px 0 0 8px;
}

.auth-tab:last-child {
  border-radius: 0 8px 8px 0;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #007bff;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: #007bff;
  color: white;
  width: 100%;
  margin-bottom: 1rem;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-google {
  background: #db4437;
  color: white;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-google:hover {
  background: #c23321;
}

/* User Profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
}

.profile-pic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.sign-out-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sign-out-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* App Content */
.app-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.app-title {
  color: #333;
  margin-bottom: 1rem;
  text-align: center;
}

/* Chat Interface */
.chat-container {
  max-width: 800px;
  margin: 0 auto;
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f8f9fa;
}

.message {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: 12px;
  max-width: 80%;
}

.message.user {
  background: #007bff;
  color: white;
  margin-left: auto;
  text-align: right;
}

.message.ai {
  background: white;
  border: 1px solid #e9ecef;
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
}

.chat-send {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.chat-send:hover {
  background: #218838;
}

.chat-send:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Study Buddy Enhanced Layout */
.study-buddy-container {
  display: flex;
  gap: 1rem;
  max-height: calc(100vh - 200px);
  min-height: 500px;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 1rem;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e9ecef;
}

.sidebar-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.1rem;
}

.btn-new-chat {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s ease;
}

.btn-new-chat:hover {
  background: #218838;
}

.chat-sessions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-session-item {
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.chat-session-item:hover {
  background: #e9ecef;
  border-left-color: #007bff;
}

.chat-session-item.active {
  background: #e3f2fd;
  border-left-color: #007bff;
}

.session-title {
  font-weight: 500;
  color: #333;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.session-preview {
  color: #666;
  font-size: 0.8rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-time {
  color: #999;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.main-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.chat-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-export,
.btn-delete {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.btn-export:hover {
  background: rgba(40, 167, 69, 0.8);
}

.btn-delete:hover {
  background: rgba(220, 53, 69, 0.8);
}

.study-tools {
  margin-top: 2rem;
  text-align: center;
}

.study-tools h3 {
  margin-bottom: 1rem;
  color: #333;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #e9ecef;
  padding: 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.tool-btn:hover {
  border-color: #007bff;
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.tool-icon {
  font-size: 1.5rem;
}

.tool-text {
  font-weight: 500;
  color: #333;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Loading states */
.loading-sessions {
  text-align: center;
  padding: 1rem;
  color: #666;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  .header-content {
    padding: 0 10px;
  }
  
  #auth-container,
  .app-content {
    margin: 1rem 10px;
    padding: 1.5rem;
  }
  
  .study-buddy-container {
    flex-direction: column;
    height: auto;
  }
  
  .sidebar {
    width: 100%;
    max-height: 200px;
    order: 2;
  }
  
  .main-chat-area {
    order: 1;
  }
  
  .chat-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .chat-messages {
    height: 300px;
  }
  
  .message {
    max-width: 90%;
  }
  
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
