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

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

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
}

.modal-content h2 {
  margin-bottom: 24px;
  color: #333;
  text-align: center;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content input {
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s;
}

.modal-content input:focus {
  border-color: #667eea;
}

.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s;
}

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

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
}

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

header h1 {
  margin: 0;
  font-size: 32px;
}

.logout-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.3s;
}

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

.search-section {
  display: flex;
  gap: 10px;
}

#tagInput {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
}

button {
  padding: 12px 24px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
  font-weight: 600;
}

button:hover:not(:disabled) {
  background: #45a049;
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

.refresh-btn {
  background: #2196f3;
}

.refresh-btn:hover:not(:disabled) {
  background: #0b7dda;
}

.main-content {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: calc(100vh - 200px);
  min-height: 500px;
}

.email-list-panel {
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.panel-header h2 {
  font-size: 20px;
  color: #333;
}

.count-badge {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s;
}

.email-item:hover {
  background: #f8f9fa;
}

.email-item.active {
  background: #e8eaf6;
  border-left: 4px solid #667eea;
}

.email-item .from {
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.email-item .subject {
  color: #666;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-item .timestamp {
  font-size: 12px;
  color: #999;
}

.email-detail-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.email-detail {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

.email-header {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.email-header h2 {
  color: #333;
  margin-bottom: 16px;
  font-size: 24px;
}

.email-meta {
  display: grid;
  gap: 10px;
}

.meta-row {
  display: flex;
  gap: 10px;
}

.meta-label {
  font-weight: 600;
  color: #666;
  min-width: 80px;
}

.meta-value {
  color: #333;
}

.email-content {
  line-height: 1.6;
}

.tab-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 16px;
  background: #f0f0f0;
  color: #666;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn.active {
  background: #667eea;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.html-content {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 20px;
  background: white;
}

.text-content {
  white-space: pre-wrap;
  font-family: "Courier New", monospace;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 16px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.error {
  background: #ffebee;
  color: #c62828;
  padding: 16px;
  border-radius: 6px;
  margin: 20px;
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .email-list-panel {
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
}
