/* CSS variables for light & dark themes */
:root {
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  
  /* Light Theme */
  --bg-app: #f3f2f1;
  --bg-sidebar: #f3f2f1;
  --bg-panel: #ffffff;
  --bg-item-hover: #f3f2f1;
  --bg-item-selected: #edebe9;
  --border-color: #edebe9;
  
  --text-primary: #323130;
  --text-secondary: #605e5c;
  --text-on-accent: #ffffff;
  
  --accent-color: #0078d4;
  --accent-hover: #106ebe;
  --accent-light: #eff6fc;
  
  --importance-high: #a80000;
  --header-bg: #0078d4;
  --shadow: 0 2px 4px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-app: #11100f;
  --bg-sidebar: #201f1e;
  --bg-panel: #292827;
  --bg-item-hover: #323130;
  --bg-item-selected: #3b3a39;
  --border-color: #3b3a39;
  
  --text-primary: #f3f2f1;
  --text-secondary: #a19f9d;
  --text-on-accent: #ffffff;
  
  --accent-color: #2899f5;
  --accent-hover: #4fb0ff;
  --accent-light: #202d3d;
  
  --header-bg: #201f1e;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background-color: var(--bg-app);
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 48px;
  background-color: var(--header-bg);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
  z-index: 10;
  position: relative;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 16px;
}

.brand-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.search-section {
  flex: 0 1 500px;
  position: relative;
}

.search-input {
  width: 100%;
  height: 32px;
  border: none;
  border-radius: 4px;
  padding: 0 12px 0 36px;
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--text-on-accent);
  font-family: var(--font-family);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  background-color: var(--bg-panel);
  color: var(--text-primary);
  outline: none;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-input:focus::placeholder {
  color: var(--text-secondary);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 8px;
  width: 16px;
  height: 16px;
  opacity: 0.8;
  pointer-events: none;
}

.search-input:focus + .search-icon {
  filter: invert(0.5);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Main Layout */
.app-container {
  display: flex;
  height: calc(100vh - 48px);
}

/* Sidebar */
.sidebar {
  width: 230px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 24px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.folder-item:hover {
  background-color: var(--bg-item-hover);
}

.folder-item.active {
  background-color: var(--bg-item-selected);
  border-left-color: var(--accent-color);
  font-weight: 600;
}

.folder-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.folder-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.folder-item.active .folder-icon {
  color: var(--accent-color);
}

.folder-count {
  font-size: 11px;
  background-color: var(--border-color);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 10px;
}

/* Email List Pane */
.email-list-pane {
  width: 380px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pane-title {
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-scroll-area {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-item:hover {
  background-color: var(--bg-item-hover);
}

.email-item.selected {
  background-color: var(--bg-item-selected);
}

.email-item.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--accent-color);
}

.email-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.email-sender {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.email-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.email-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.email-item-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.importance-badge {
  color: var(--importance-high);
  font-weight: bold;
  font-size: 11px;
}

.attachment-badge {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
}

/* Pagination */
.pagination-controls {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-page {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-family);
}

.btn-page:hover:not(:disabled) {
  background-color: var(--bg-item-hover);
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Reading Pane */
.reading-pane {
  flex: 1;
  background-color: var(--bg-panel);
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 16px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--border-color);
}

.email-view-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-view-subject {
  font-size: 20px;
  font-weight: 600;
}

.email-meta-details {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-light);
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

.meta-text {
  flex: 1;
}

.sender-info {
  font-weight: 600;
  font-size: 14px;
}

.sender-email {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-secondary);
}

.recipient-info {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.email-view-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.email-view-actions {
  display: flex;
  gap: 12px;
}

.btn-action {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: var(--font-family);
}

.btn-action:hover {
  background-color: var(--bg-item-hover);
}

.btn-action-primary {
  background-color: var(--accent-color);
  color: var(--text-on-accent);
  border: none;
}

.btn-action-primary:hover {
  background-color: var(--accent-hover);
}

.email-view-body {
  flex: 1;
  padding: 24px;
  overflow: auto;
  position: relative;
}

.email-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff;
}

[data-theme="dark"] .email-iframe {
  filter: invert(0.9) hue-rotate(180deg);
}

.static-page {
  max-width: 800px;
  margin: 32px auto;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.static-nav {
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.static-nav a {
  color: var(--accent-color);
  text-decoration: none;
}

.static-nav a:hover {
  text-decoration: underline;
}

.static-related-pane {
  margin-top: 32px;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
}

.static-related-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.related-card {
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.related-card:hover {
  background-color: var(--bg-item-hover);
  border-color: var(--accent-color);
}

.related-sub {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}
