* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Navbar */
.navbar {
  background-color: #2c3e50;
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.nav-menu {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  transition: opacity 0.3s;
}

.nav-link:hover {
  opacity: 0.8;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - 140px);
  padding: 2rem 0;
}

/* Footer */
.footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 3rem;
}

/* Login Page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  margin-bottom: 1.5rem;
  text-align: center;
  color: #2c3e50;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #555;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.form-control:focus {
  outline: none;
  border-color: #3498db;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background-color: #c0392b;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.alert-error {
  background-color: #fee;
  color: #c33;
  border: 1px solid #fcc;
}

/* Dashboard */
.dashboard h2 {
  margin-bottom: 2rem;
  color: #2c3e50;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
}

.stat-title {
  font-size: 0.875rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: #3498db;
}

/* Conversations Section */
.conversations-section {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.conversations-section h3 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #999;
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.conversation-card {
  border: 1px solid #e1e8ed;
  border-radius: 8px;
  padding: 1.5rem;
  transition: box-shadow 0.3s;
}

.conversation-card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.conversation-info h4 {
  margin-bottom: 0.25rem;
  color: #2c3e50;
}

.phone-number {
  color: #777;
  font-size: 0.875rem;
}

.conversation-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timestamp {
  font-size: 0.875rem;
  color: #999;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-active {
  background-color: #d4edda;
  color: #155724;
}

.badge-closed {
  background-color: #f8d7da;
  color: #721c24;
}

.conversation-preview {
  margin-bottom: 1rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 4px;
}

.conversation-preview p {
  margin: 0;
  color: #555;
  font-size: 0.9rem;
}

.conversation-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-count {
  color: #777;
  font-size: 0.875rem;
}

.conversation-actions {
  display: flex;
  gap: 0.5rem;
}

/* Conversation Detail */
.conversation-detail {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.breadcrumb {
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: #3498db;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.conversation-header-detail {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e1e8ed;
}

.conversation-header-detail h2 {
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.conversation-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: #f8f9fa;
  border-radius: 4px;
}

.stat-item {
  font-size: 0.9rem;
  color: #555;
}

.stat-item strong {
  color: #2c3e50;
  display: block;
  margin-bottom: 0.25rem;
}

/* Messages */
.messages-container {
  margin: 2rem 0;
}

.messages-container h3 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-messages {
  text-align: center;
  padding: 2rem;
  color: #999;
}

.message {
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid;
}

.message-user {
  background-color: #e3f2fd;
  border-left-color: #2196f3;
}

.message-assistant {
  background-color: #f3e5f5;
  border-left-color: #9c27b0;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.message-header strong {
  color: #2c3e50;
}

.message-time {
  font-size: 0.75rem;
  color: #999;
}

.message-content {
  color: #555;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.conversation-actions-detail {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e1e8ed;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar .container {
    flex-direction: column;
    gap: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .conversation-header {
    flex-direction: column;
    gap: 1rem;
  }

  .conversation-meta {
    text-align: left;
  }

  .conversation-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .conversation-stats {
    grid-template-columns: 1fr;
  }
}
