/* Gmail Clone - Modern CSS Design System */
:root {
  --bg-primary: #12141c;
  --bg-secondary: #1a1d29;
  --bg-tertiary: #232738;
  --bg-hover: #2d3247;
  --bg-active: #383e58;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f3f9;
  --text-secondary: #9da6be;
  --text-muted: #656d85;
  --accent-color: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.15);
  --star-color: #f59e0b;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  --bg-active: #cbd5e1;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-color: #4338ca;
  --accent-hover: #3730a3;
  --accent-light: rgba(67, 56, 202, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 20px;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 220px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.header-search {
  flex: 1;
  max-width: 720px;
  position: relative;
  display: flex;
  align-items: center;
}

.header-search input {
  width: 100%;
  height: 44px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0 44px 0 44px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.header-search input:focus {
  background-color: var(--bg-secondary);
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 1rem;
}

.search-clear-btn {
  position: absolute;
  right: 12px;
}

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

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
}

/* Button & Icon Button Utilities */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  transition: width 0.3s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .badge,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-storage,
.sidebar.collapsed .compose-btn span {
  display: none;
}

.compose-btn-wrapper {
  margin-bottom: 20px;
}

.compose-btn {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-color), #6366f1);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.compose-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.1);
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-light);
  color: var(--accent-color);
  font-weight: 600;
}

.nav-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.nav-item.active .badge {
  background-color: var(--accent-color);
  color: white;
}

.nav-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 12px 0;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 14px;
}

.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.label-dot.work { background-color: #3b82f6; }
.label-dot.important { background-color: #ef4444; }
.label-dot.design { background-color: #a855f7; }
.label-dot.updates { background-color: #10b981; }

.sidebar-storage {
  padding: 14px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-top: 10px;
}

.storage-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.storage-bar {
  height: 6px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
}

/* Content Area */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  height: 48px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.email-count-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Email List Container */
.email-list-container {
  flex: 1;
  overflow-y: auto;
}

.email-list {
  display: flex;
  flex-direction: column;
}

.email-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.15s ease;
  gap: 14px;
}

.email-row:hover {
  background-color: var(--bg-hover);
}

.email-row.unread {
  background-color: var(--bg-secondary);
  font-weight: 600;
}

.email-row.unread .email-subject {
  color: var(--text-primary);
}

.star-btn {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}

.star-btn.starred {
  color: var(--star-color);
}

.sender-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}

.email-sender {
  width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.email-content-preview {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.email-subject {
  color: var(--text-secondary);
  font-weight: 500;
}

.email-snippet {
  color: var(--text-muted);
  font-weight: 400;
}

.email-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.email-labels {
  display: flex;
  gap: 4px;
}

.tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: 6px;
}

/* Email Detail View */
.email-detail-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 30px;
  background-color: var(--bg-secondary);
}

.detail-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

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

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

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.detail-actions-right {
  display: flex;
  gap: 10px;
}

.detail-subject {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.detail-sender-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sender-details {
  display: flex;
  flex-direction: column;
}

.sender-name {
  font-weight: 700;
  color: var(--text-primary);
}

.sender-email-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-body-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Compose Modal Window */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 20px;
  z-index: 100;
}

.compose-window {
  width: 560px;
  height: 520px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compose-header {
  height: 48px;
  background-color: var(--bg-tertiary);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border-color);
}

.compose-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.form-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 0;
}

.form-field label {
  width: 70px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-field input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
}

.text-area-field {
  flex: 1;
  border-bottom: none;
  padding-top: 12px;
}

.text-area-field textarea {
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  resize: none;
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.draft-status-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Alias Generator Modal */
.alias-window {
  height: auto;
  max-height: 580px;
}

.alias-btn {
  gap: 8px;
  background-color: var(--accent-light);
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
}

.alias-btn:hover {
  background-color: var(--accent-color);
  color: white;
}

.alias-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.alias-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.generated-box {
  display: flex;
  gap: 10px;
}

.generated-box input {
  flex: 1;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.alias-actions {
  display: flex;
  gap: 10px;
}

.alias-history h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.alias-history ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.alias-history li {
  font-size: 0.85rem;
  padding: 6px 10px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
}

.alias-history li button {
  background: none;
  border: none;
  color: var(--accent-color);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
