/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Roboto', sans-serif; color: #202124; background: #fff; overflow: hidden; }
a { text-decoration: none; color: inherit; }
h1, h2, h3 { font-family: 'Google Sans', 'Roboto', sans-serif; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 100;
  background: #fff; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; padding: 0 8px;
}
.hamburger { display: none; background: none; border: none; padding: 8px; cursor: pointer; color: #5f6368; border-radius: 50%; }
.hamburger:hover { background: #e8eaed; }
.topbar-logo { font-family: 'Google Sans', sans-serif; font-size: 22px; color: #202124; padding: 0 16px; white-space: nowrap; }
.topbar-search { flex: 1; max-width: 720px; margin: 0 auto; position: relative; }
.topbar-search form { display: flex; align-items: center; position: relative; }
.topbar-search .search-icon { position: absolute; left: 16px; color: #5f6368; font-size: 20px; pointer-events: none; }
.topbar-search input {
  width: 100%; height: 46px; background: #eaf1fb; border: none; border-radius: 28px;
  padding: 0 16px 0 48px; font-size: 16px; outline: none;
}
.topbar-search input:focus { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.topbar-right { display: flex; align-items: center; gap: 8px; padding-right: 8px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #1a73e8; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500;
}
.topbar-avatar-img { width: 32px; height: 32px; border-radius: 50%; }
.topbar-logout { color: #5f6368; padding: 8px; border-radius: 50%; display: flex; }
.topbar-logout:hover { background: #e8eaed; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 64px; left: 0; width: 256px; height: calc(100vh - 64px);
  background: #f6f8fc; overflow-y: auto; padding: 8px 12px; z-index: 90;
}
.compose-btn {
  display: flex; align-items: center; gap: 12px; background: #c2e7ff; color: #001d35;
  border: none; border-radius: 16px; height: 56px; padding: 0 24px;
  font-family: 'Google Sans', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; margin-bottom: 16px; white-space: nowrap;
}
.compose-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sidebar-item {
  display: flex; align-items: center; height: 32px; padding: 0 12px 0 24px;
  border-radius: 0 16px 16px 0; cursor: pointer; font-size: 14px; color: #202124; gap: 16px;
}
.sidebar-item:hover { background: #e8eaed; }
.sidebar-item.active { background: #d3e3fd; font-weight: 500; }
.sidebar-item .material-icons-outlined { font-size: 20px; width: 24px; text-align: center; }
.sidebar-item .badge { margin-left: auto; font-size: 12px; font-weight: 500; }
.sidebar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-divider { height: 1px; background: #e0e0e0; margin: 8px 0; }
.sidebar-section-title { font-size: 12px; color: #5f6368; padding: 8px 24px; text-transform: uppercase; letter-spacing: .5px; }
.sidebar-label .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.inbox-item { height: 28px; font-size: 13px; }

/* ===== MAIN CONTENT ===== */
.app-container { display: flex; margin-top: 64px; }
.main-content { flex: 1; margin-left: 256px; min-height: calc(100vh - 64px); overflow-y: auto; height: calc(100vh - 64px); }

/* ===== TOOLBAR ===== */
.toolbar {
  position: sticky; top: 0; z-index: 50; background: #fff;
  height: 48px; display: flex; align-items: center; padding: 0 8px;
  border-bottom: 1px solid #e0e0e0;
}
.toolbar-checkbox { padding: 4px 16px; }
.toolbar-checkbox input { cursor: pointer; }
.toolbar-actions { display: flex; gap: 2px; }
.toolbar-btn {
  background: none; border: none; padding: 8px; border-radius: 50%; cursor: pointer;
  color: #5f6368; display: flex; align-items: center; justify-content: center;
}
.toolbar-btn:hover { background: #e8eaed; }
.toolbar-pagination { margin-left: auto; font-size: 12px; color: #5f6368; display: flex; align-items: center; gap: 4px; }
.toolbar-pagination button {
  background: none; border: none; padding: 4px 8px; cursor: pointer; color: #5f6368; border-radius: 50%;
}
.toolbar-pagination button:hover { background: #e8eaed; }
.toolbar-pagination button:disabled { opacity: .3; cursor: default; }

/* ===== EMAIL LIST ===== */
.email-list { list-style: none; }
.email-row {
  display: flex; align-items: center; height: 40px; padding: 0 8px;
  border-bottom: 1px solid #f1f3f4; cursor: pointer; color: inherit;
}
.email-row:hover { background: #f5f5f5; box-shadow: inset 3px 0 0 #1a73e8; }
.email-row.unread { background: #f2f6fc; }
.email-row.unread .sender { font-weight: 700; }
.email-row.unread .subject { font-weight: 700; }
.email-row .checkbox { padding: 0 8px; flex-shrink: 0; display: flex; align-items: center; }
.email-row .checkbox input { cursor: pointer; }
.email-row .star { padding: 0 4px; flex-shrink: 0; color: #dadce0; cursor: pointer; display: flex; }
.email-row .star:hover { color: #5f6368; }
.email-row .star.active { color: #f4b400; }
.email-row .star .material-icons-outlined { font-size: 20px; }
.email-row .sender { width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; padding: 0 8px; }
.email-row .subject-preview { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; min-width: 0; }
.email-row .subject-preview .subject { color: #202124; }
.email-row .subject-preview .preview { color: #5f6368; font-weight: 300; }
.email-row .date { flex-shrink: 0; font-size: 12px; color: #5f6368; padding: 0 16px; white-space: nowrap; }

/* ===== MAIL VIEW ===== */
.mail-view { padding: 24px; max-width: 900px; }
.mail-back { display: inline-flex; align-items: center; gap: 4px; color: #5f6368; padding: 8px 0; cursor: pointer; font-size: 14px; }
.mail-back:hover { color: #202124; }
.mail-subject { font-size: 22px; font-family: 'Google Sans', sans-serif; font-weight: 400; color: #202124; margin: 8px 0 16px; }
.mail-meta { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-bottom: 1px solid #e0e0e0; }
.sender-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 18px; color: #fff; flex-shrink: 0;
}
.sender-info { flex: 1; min-width: 0; }
.sender-info .sender-name { font-weight: 500; font-size: 14px; }
.sender-info .sender-email { font-size: 12px; color: #5f6368; }
.mail-date { font-size: 12px; color: #5f6368; white-space: nowrap; }
.mail-body { padding: 16px 0; }
.mail-body iframe { width: 100%; border: none; min-height: 200px; }
.mail-body pre { white-space: pre-wrap; word-wrap: break-word; font-family: 'Roboto', sans-serif; font-size: 14px; line-height: 1.6; }
.mail-actions { display: flex; gap: 8px; padding: 16px 0; border-top: 1px solid #e0e0e0; flex-wrap: wrap; }
.action-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border: 1px solid #e0e0e0; border-radius: 18px; font-size: 14px; cursor: pointer;
  background: #fff; color: #202124;
}
.action-btn:hover { background: #f6f8fc; }
.action-btn .material-icons-outlined { font-size: 18px; }

/* ===== ATTACHMENTS ===== */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.attachment-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid #e0e0e0; border-radius: 8px; font-size: 13px; color: #202124;
}
.attachment-item:hover { background: #f6f8fc; }
.attachment-size { color: #5f6368; font-size: 11px; }

/* ===== COMPOSE MODAL ===== */
.compose-modal {
  position: fixed; bottom: 0; right: 24px; width: 500px; background: #fff;
  border-radius: 8px 8px 0 0; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: none; flex-direction: column; z-index: 200; max-height: 80vh;
}
.compose-modal.open { display: flex; }
.compose-header {
  height: 40px; background: #404040; color: #fff; display: flex; align-items: center;
  padding: 0 12px; border-radius: 8px 8px 0 0; font-size: 14px; flex-shrink: 0;
}
.compose-header .close-btn { margin-left: auto; background: none; border: none; color: #fff; cursor: pointer; font-size: 18px; padding: 4px; }
.compose-fields { padding: 4px 12px; flex-shrink: 0; }
.compose-field { display: flex; align-items: center; padding: 4px 0; font-size: 14px; border-bottom: 1px solid #f1f3f4; }
.compose-field label { width: 60px; color: #5f6368; flex-shrink: 0; font-size: 13px; }
.compose-field input, .compose-field select { flex: 1; border: none; outline: none; font-size: 14px; padding: 4px; }
.compose-subject { padding: 8px 12px; border-bottom: 1px solid #e0e0e0; flex-shrink: 0; }
.compose-subject input { width: 100%; border: none; outline: none; font-size: 14px; }
.compose-body { flex: 1; min-height: 200px; overflow: hidden; }
.compose-body textarea { width: 100%; height: 100%; border: none; outline: none; resize: none; padding: 12px; font-size: 14px; }
.compose-footer { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid #e0e0e0; flex-shrink: 0; }
.compose-send-btn { background: #1a73e8; color: #fff; border: none; border-radius: 18px; padding: 8px 24px; font-size: 14px; font-weight: 500; cursor: pointer; }
.compose-send-btn:hover { background: #1557b0; }
.compose-draft-btn { background: none; border: 1px solid #e0e0e0; border-radius: 18px; padding: 8px 16px; font-size: 13px; cursor: pointer; color: #5f6368; }

/* ===== CONTACTS ===== */
.contacts-page { padding: 24px; max-width: 900px; }
.contacts-page h1 { font-family: 'Google Sans', sans-serif; font-size: 22px; margin-bottom: 16px; }
.contacts-search { margin-bottom: 16px; }
.contacts-search input { width: 100%; max-width: 400px; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 14px; }
.contacts-table { width: 100%; border-collapse: collapse; }
.contacts-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid #e0e0e0; font-size: 12px; color: #5f6368; text-transform: uppercase; }
.contacts-table td { padding: 8px 12px; border-bottom: 1px solid #f1f3f4; font-size: 14px; }
.contacts-table tr:hover { background: #f6f8fc; }
.contacts-table .actions { display: flex; gap: 4px; }

/* ===== SETTINGS ===== */
.settings-page { padding: 24px; max-width: 800px; }
.settings-page h1 { font-family: 'Google Sans', sans-serif; font-size: 22px; margin-bottom: 24px; }
.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-family: 'Google Sans', sans-serif; font-size: 18px; margin-bottom: 12px; color: #202124; }
.settings-form textarea { width: 100%; min-height: 100px; border: 1px solid #e0e0e0; border-radius: 4px; padding: 8px; font-size: 14px; }
.settings-form .save-btn { margin-top: 8px; background: #1a73e8; color: #fff; border: none; border-radius: 4px; padding: 8px 24px; font-size: 14px; cursor: pointer; }
.settings-form .save-btn:hover { background: #1557b0; }

/* ===== LOGIN ===== */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f6f8fc; }
.login-card { background: #fff; border-radius: 8px; padding: 48px; box-shadow: 0 1px 3px rgba(0,0,0,.1); max-width: 400px; width: 100%; text-align: center; }
.login-card h1 { font-family: 'Google Sans', sans-serif; font-size: 24px; margin-bottom: 8px; }
.login-card p { color: #5f6368; font-size: 14px; margin-bottom: 24px; }
.login-card input { width: 100%; padding: 12px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 14px; margin: 8px 0; }
.login-card input:focus { border-color: #1a73e8; outline: none; }
.login-btn { width: 100%; padding: 12px; background: #1a73e8; color: #fff; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; margin-top: 8px; font-weight: 500; }
.login-btn:hover { background: #1557b0; }
.login-btn.discord { background: #5865f2; }
.login-btn.discord:hover { background: #4752c4; }
.login-btn.passkey { background: #202124; }
.login-btn.passkey:hover { background: #3c4043; }
.login-divider { display: flex; align-items: center; gap: 16px; margin: 16px 0; color: #5f6368; font-size: 12px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: #e0e0e0; }
.login-error { color: #d93025; font-size: 13px; margin: 8px 0; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 24px; color: #5f6368; }
.empty-state .material-icons-outlined { font-size: 64px; margin-bottom: 16px; color: #dadce0; }
.empty-state p { font-size: 16px; }

/* ===== UTILITIES ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 14px; cursor: pointer; background: #fff; }
.btn:hover { background: #f6f8fc; }
.btn-primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn-primary:hover { background: #1557b0; }
.btn-danger { color: #d93025; }
.btn-danger:hover { background: #fce8e6; }
.hidden { display: none !important; }
.reply-zone { padding: 16px 0; margin-top: 16px; border-top: 1px solid #e0e0e0; }
.reply-zone textarea { width: 100%; min-height: 100px; border: 1px solid #e0e0e0; border-radius: 4px; padding: 8px; font-size: 14px; margin-bottom: 8px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar { width: 56px; padding: 8px 4px; }
  .sidebar-text, .sidebar-section-title, .compose-btn span:not(.material-icons-outlined) { display: none; }
  .compose-btn { padding: 0; width: 48px; height: 48px; justify-content: center; border-radius: 50%; }
  .sidebar-item { padding: 0; justify-content: center; gap: 0; height: 40px; border-radius: 50%; }
  .sidebar-item .badge { display: none; }
  .sidebar-divider { margin: 4px 0; }
  .main-content { margin-left: 56px; }
}
@media (max-width: 768px) {
  .sidebar { display: none; width: 256px; padding: 8px 12px; position: fixed; z-index: 150; box-shadow: 2px 0 8px rgba(0,0,0,.2); }
  .sidebar.open { display: block; }
  .sidebar-text, .sidebar-section-title, .compose-btn span:not(.material-icons-outlined) { display: inline; }
  .compose-btn { width: auto; height: 56px; border-radius: 16px; padding: 0 24px; }
  .sidebar-item { padding: 0 12px 0 24px; justify-content: flex-start; gap: 16px; height: 32px; border-radius: 0 16px 16px 0; }
  .sidebar-item .badge { display: inline; }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; }
  .email-row .sender { width: 120px; }
  .compose-modal { width: 100%; right: 0; left: 0; border-radius: 8px 8px 0 0; }
}
.sidebar-overlay { display: none; position: fixed; top: 64px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.3); z-index: 140; }
.sidebar-overlay.open { display: block; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn .3s ease; }
