/* Familia AI Frontend Styles */

:root {
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --bg-color: #f8f9fa;
  --text-color: #333;
  --card-bg: #ffffff;
  --border-color: #dee2e6;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Authentication Styles */
#auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#login-form, #register-form {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

h2 {
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  text-align: center;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #0056b3;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Chat Section Styles */
#chat-section {
  display: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
  color: var(--primary-color);
  font-size: 1.5rem;
}

#user-info {
  display: flex;
  gap: 1rem;
  align-items: center;
}

#user-name, #user-role, #message-count {
  font-weight: bold;
}

#logout-button {
  background-color: var(--danger-color);
}

#logout-button:hover {
  background-color: #c82333;
}

/* Chat Container */
.chat-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  height: 70vh;
}

#chat-sidebar {
  background: var(--card-bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#new-chat-button {
  background-color: var(--success-color);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

#new-chat-button:hover {
  background-color: #218838;
}

#chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.3s;
}

.chat-item:hover {
  background-color: #f0f0f0;
}

.chat-date {
  font-size: 0.8rem;
  color: var(--secondary-color);
  float: right;
}

/* Chat Main */
#chat-main {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#chat-history {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  padding: 1rem;
  border-radius: 8px;
  max-width: 70%;
  animation: fadeIn 0.3s ease-in;
}

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

.message.ai {
  background-color: #e9ecef;
  color: var(--text-color);
  align-self: flex-start;
  border-bottom-left-radius: 0;
}

.message.error {
  background-color: var(--danger-color);
  color: white;
  align-self: center;
}

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

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

#message-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
}

#send-button {
  padding: 0.75rem 2rem;
}

/* Admin Panel Styles */
#admin-panel {
  display: none;
  margin-top: 2rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
  border-bottom: none;
}

.admin-users {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.user-item:last-child {
  border-bottom: none;
}

select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  #chat-sidebar {
    order: 2;
    height: 300px;
  }
  
  #chat-main {
    order: 1;
    height: 50vh;
  }
  
  .message {
    max-width: 90%;
  }
}