/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&display=swap');

/* HorseMail - Styles */
:root {
  --primary: #8B4513;
  --primary-dark: #654321;
  --primary-light: #A0522D;
  --secondary: #D2691E;
  --accent: #CD853F;
  --success: #4CAF50;
  --error: #f44336;
  --bg: #FFF8DC;
  --bg-light: #FFFAED;
  --text: #3E2723;
  --text-light: #5D4037;
  --border: #DEB887;
  --shadow: rgba(139, 69, 19, 0.15);
}

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

body {
  font-family: 'Nunito', 'Segoe UI', 'Roboto', 'Ubuntu', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.3px;
}

strong, b {
  font-weight: 700;
}

.tagline {
  font-weight: 600;
}


/* Logo */
.logo {
  font-size: 2.5em;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.logo-small {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.horse-icon {
  display: inline-block;
  animation: gallop 2s ease-in-out infinite;
}

@keyframes gallop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(5deg); }
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.9em;
}

.btn-block {
  width: 100%;
  display: block;
}

/* Homepage */
.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-light) 100%);
  padding: 40px 20px;
  text-align: center;
}

.hero-content {
  max-width: 600px;
}

.tagline {
  font-size: 1.8em;
  color: var(--primary);
  margin: 20px 0 10px;
}

.subtitle {
  font-size: 1.2em;
  color: var(--text-light);
  margin-bottom: 40px;
}

.cta-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.features {
  padding: 60px 20px;
  background: white;
}

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

.features h2 {
  text-align: center;
  font-size: 2em;
  color: var(--primary);
  margin-bottom: 40px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.feature-card {
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px var(--shadow);
}

.feature-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.feature-card h3 {
  color: var(--primary);
  margin-bottom: 10px;
}

footer {
  background: var(--primary);
  color: white;
  text-align: center;
  padding: 20px;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-light) 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: white;
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 10px 30px var(--shadow);
  text-align: center;
}

.login-box h2 {
  color: var(--primary);
  margin: 20px 0 30px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.error-message {
  color: var(--error);
  background: #ffebee;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 0.9em;
  border: 1px solid #ffcdd2;
}

.login-footer {
  margin-top: 20px;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9em;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Navbar */
.navbar {
  background: white;
  border-bottom: 3px solid var(--border);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-name {
  color: var(--primary);
  font-weight: 600;
}

/* Inbox Page */
.inbox-container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
}

.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.inbox-header h2 {
  color: var(--primary);
}

.email-list {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.email-item {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease;
}

.email-item:hover {
  background: var(--bg-light);
}

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

.email-item.unread {
  background: #FFF5E6;
  font-weight: 600;
}

.email-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.email-from {
  color: var(--primary);
  font-weight: 600;
}

.email-date {
  color: var(--text-light);
  font-size: 0.9em;
}

.email-subject {
  font-size: 1.1em;
  margin-bottom: 5px;
  color: var(--text);
}

.unread-dot {
  color: var(--primary);
  margin-right: 5px;
}

.email-preview {
  color: var(--text-light);
  font-size: 0.9em;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 4em;
  margin-bottom: 20px;
}

.empty-state p {
  color: var(--text-light);
  margin: 10px 0;
}

.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-light);
}

/* Email Detail View */
.email-detail-view {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 30px;
}

.detail-header {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
}

.thread-subject-header {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.thread-subject-header h2 {
  color: var(--primary);
  margin-bottom: 5px;
}

/* Thread message cards - each email in the thread */
.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.thread-message-card {
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  transition: box-shadow 0.2s ease;
}

.thread-message-card:hover {
  box-shadow: 0 2px 8px var(--shadow);
}

/* Sent messages have a slightly different style */
.thread-message-card.sent-message {
  background: #E8F5E9;
  border-color: #A5D6A7;
}

.thread-message-card.sent-message .message-sender strong {
  color: #2E7D32;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sent-message .message-header {
  border-bottom-color: #A5D6A7;
}

.message-sender {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-sender strong {
  color: var(--primary);
  font-size: 1.05em;
}

.sender-email {
  color: var(--text-light);
  font-size: 0.9em;
  font-weight: normal;
}

.message-date {
  color: var(--text-light);
  font-size: 0.9em;
  white-space: nowrap;
}

.message-body {
  line-height: 1.8;
  color: var(--text);
}

.message-body img {
  max-width: 100%;
  height: auto;
}

.email-detail {
  max-width: 800px;
}

.email-meta {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.email-subject h2 {
  color: var(--primary);
  margin-bottom: 15px;
}

.email-info {
  color: var(--text-light);
  font-size: 0.95em;
}

.email-info div {
  margin: 5px 0;
}

.email-body {
  line-height: 1.8;
  color: var(--text);
}

.email-body img {
  max-width: 100%;
  height: auto;
}

/* Compose Page */
.compose-container {
  max-width: 900px;
  margin: 30px auto;
  padding: 0 20px;
}

.compose-box {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 30px;
}

.compose-box h2 {
  color: var(--primary);
  margin-bottom: 30px;
}

.editor-toolbar {
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 10px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.editor-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 0.9em;
}

.editor-btn:hover {
  background: var(--bg);
}

.toolbar-separator {
  color: var(--border);
  margin: 0 5px;
}

.html-editor {
  min-height: 300px;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: 0 0 8px 8px;
  background: white;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.6;
}

.html-editor:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}

.status-message {
  padding: 12px;
  border-radius: 6px;
  margin-top: 15px;
  font-weight: 600;
}

.status-message.success {
  background: #e8f5e9;
  color: var(--success);
}

.status-message.error {
  background: #ffebee;
  color: var(--error);
}

.status-message.info {
  background: #e3f2fd;
  color: #1976d2;
}

/* Thread styling */
.thread-count {
  color: var(--text-light);
  font-size: 0.85em;
  font-weight: normal;
  margin-left: 5px;
}

#threadContainer {
  max-width: 900px;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 15px;
  }
  
  .inbox-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
  
  .cta-buttons {
    flex-direction: column;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn-block {
    width: 100%;
  }
  
  .message-header {
    flex-direction: column;
    gap: 8px;
  }
  
  .message-date {
    align-self: flex-start;
  }
  
  .email-item-header {
    flex-wrap: wrap;
  }
  
  .email-date {
    min-width: fit-content;
    white-space: nowrap;
  }
}
