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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
  overflow: hidden;
}

/* Login view */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: #333;
}

.login-card p {
  color: #666;
  margin-bottom: 32px;
}

.btn-signin {
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 12px 32px;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-signin:hover {
  background: #106ebe;
}

/* App layout */
#app-view {
  display: none;
  height: 100vh;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #0078d4;
  color: #fff;
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right .user-name {
  font-size: 13px;
  opacity: 0.9;
}

.btn-header {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.btn-header:hover {
  background: rgba(255,255,255,0.25);
}

/* Search bar */
.search-bar {
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}

.search-bar input:focus {
  border-color: #0078d4;
}

.search-bar button {
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

/* Main content area */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 200px;
  background: #fafafa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: #eee;
}

.sidebar-item.active {
  background: #e3f2fd;
  border-left-color: #0078d4;
  font-weight: 500;
}

.sidebar-item .unread-count {
  background: #0078d4;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* Message list */
.message-list {
  width: 360px;
  min-width: 280px;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.message-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  gap: 12px;
}

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

.message-item.unread {
  background: #f0f7ff;
}

.message-item.unread .msg-subject {
  font-weight: 600;
}

.msg-content {
  flex: 1;
  min-width: 0;
}

.msg-from {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.msg-subject {
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-preview {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-meta {
  text-align: right;
  flex-shrink: 0;
  min-width: 80px;
}

.msg-date {
  font-size: 12px;
  color: #888;
}

.msg-attachment {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.load-more {
  padding: 16px;
  text-align: center;
}

.load-more button {
  background: none;
  border: 1px solid #ddd;
  padding: 8px 24px;
  border-radius: 4px;
  cursor: pointer;
  color: #0078d4;
  font-size: 13px;
}

.load-more button:hover {
  background: #f5f5f5;
}

/* Right pane (reader or compose) */
.right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  min-width: 0;
}

#empty-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* Message reader */
#reader-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* Selected message highlight */
.message-item.selected {
  background: #e3f2fd;
  border-left: 3px solid #0078d4;
}

.reader-header {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.reader-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.reader-toolbar button {
  background: #f0f0f0;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.reader-toolbar button:hover {
  background: #e0e0e0;
}

.reader-toolbar .btn-delete {
  color: #d32f2f;
}

.reader-subject {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.reader-meta {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

.reader-meta strong {
  color: #333;
}

.reader-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.reader-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Compose view */
#compose-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.compose-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.compose-header h2 {
  font-size: 16px;
  font-weight: 500;
}

.compose-actions {
  display: flex;
  gap: 8px;
}

.btn-send {
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-send:hover {
  background: #106ebe;
}

.btn-discard {
  background: #f0f0f0;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.compose-fields {
  padding: 0 16px;
  flex-shrink: 0;
}

.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
  padding: 8px 0;
}

.compose-field label {
  width: 60px;
  font-size: 13px;
  color: #666;
  flex-shrink: 0;
}

.compose-field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 4px 0;
}

.compose-body {
  flex: 1;
  padding: 16px;
  overflow: auto;
}

.compose-body textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.6;
}

/* Loading / empty states */
.loading, .empty-state {
  padding: 48px;
  text-align: center;
  color: #888;
  font-size: 14px;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-top-color: #0078d4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeIn 0.3s;
}

.toast.error {
  background: #d32f2f;
}

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

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .sidebar-item {
    padding: 10px 8px;
    font-size: 12px;
    justify-content: center;
  }

  .sidebar-item .folder-name {
    display: none;
  }

  .sidebar-item .unread-count {
    font-size: 10px;
  }
}
