/* ==========================================================================
   Gmail / Tuormedia Mail Design System (CSS)
   ========================================================================== */

:root {
  --bg-primary: #f6f8fc;
  --bg-surface: #ffffff;
  --bg-sidebar: #f6f8fc;
  --text-main: #202124;
  --text-muted: #5f6368;
  --border-color: #e0e0e0;
  --accent-blue: #1a73e8;
  --accent-blue-hover: #1557b0;
  --accent-red: #ea4335;
  --accent-green: #34a853;
  --accent-yellow: #fbbc04;
  --badge-hover: #e8f0fe;
  --shadow-sm: 0 1px 3px rgba(60,64,67,0.15);
  --shadow-md: 0 4px 12px rgba(60,64,67,0.15);
  --shadow-lg: 0 8px 24px rgba(60,64,67,0.2);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-pill: 24px;
}

body.dark-theme {
  --bg-primary: #1e1f22;
  --bg-surface: #2b2d30;
  --bg-sidebar: #1e1f22;
  --text-main: #e3e3e3;
  --text-muted: #9aa0a6;
  --border-color: #444746;
  --accent-blue: #8ab4f8;
  --accent-blue-hover: #aecbfa;
  --badge-hover: #3c4043;
}

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

body {
  font-family: 'Google Sans', 'Roboto', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   AUTH SCREEN (LOGIN MODAL)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-card {
  background: var(--bg-surface);
  width: 100%;
  max-width: 420px;
  padding: 36px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 24px;
  color: var(--accent-blue);
  margin-bottom: 12px;
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 500;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-group input,
.compose-row input,
.compose-editor-area textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.compose-row input:focus,
.compose-editor-area textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  cursor: pointer;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--accent-blue);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-block {
  width: 100%;
}

.error-badge {
  background: #fce8e6;
  color: var(--accent-red);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-demo-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   MAIN APP LAYOUT
   ========================================================================== */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* TOP NAVBAR */
.top-navbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  color: var(--text-main);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(60,64,67,0.08);
  color: var(--text-main);
}

/* SEARCH BAR */
.nav-center {
  flex: 1;
  max-width: 720px;
  padding: 0 16px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  padding: 4px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid transparent;
  transition: box-shadow 0.2s, background 0.2s;
}

.search-box:focus-within {
  background: #ffffff;
  box-shadow: 0 1px 6px rgba(32,33,36,0.28);
}

.search-icon {
  color: var(--text-muted);
  margin-right: 12px;
}

.search-box input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 15px;
  outline: none;
  color: var(--text-main);
}

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

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropdown-popover {
  position: absolute;
  top: 55px;
  right: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 240px;
  padding: 16px;
  z-index: 1000;
  border: 1px solid var(--border-color);
}

.popover-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-role {
  display: inline-block;
  background: #e8f0fe;
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  width: fit-content;
  margin-top: 4px;
}

.dropdown-item {
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 8px;
  color: var(--text-main);
}

.dropdown-item.danger {
  color: var(--accent-red);
}

.dropdown-item:hover {
  background: var(--bg-primary);
}

/* WORKSPACE */
.main-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

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

.btn-compose {
  background: #c2e7ff;
  color: #001d35;
  border: none;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, background 0.2s;
  margin-bottom: 16px;
}

.btn-compose:hover {
  box-shadow: var(--shadow-md);
  background: #b3e0ff;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  color: var(--text-main);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.nav-item:hover {
  background: rgba(60,64,67,0.08);
}

.nav-item.active {
  background: #d3e3fd;
  color: #041e49;
  font-weight: 700;
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  margin-right: 16px;
  color: var(--text-muted);
}

.nav-item.active .nav-icon {
  color: #041e49;
}

.nav-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}

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

.sidebar-section-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 16px;
}

.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 16px;
}
.dot-blue { background: var(--accent-blue); }
.dot-green { background: var(--accent-green); }

.storage-widget {
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  border: 1px solid var(--border-color);
}

.storage-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-bar {
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-blue);
}

/* CONTENT AREA */
.content-area {
  flex: 1;
  background: var(--bg-surface);
  margin: 8px 16px 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.list-toolbar, .detail-toolbar {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-title {
  font-size: 16px;
  font-weight: 500;
  margin-left: 12px;
}

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

.mail-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  font-size: 14px;
}

.mail-row:hover {
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60,64,67,0.3);
  background: #f2f6fc;
}

.mail-row.unread {
  font-weight: 700;
  background: var(--bg-surface);
}

.mail-star {
  color: var(--text-muted);
  margin-right: 14px;
  cursor: pointer;
}

.mail-star.starred {
  color: var(--accent-yellow);
}

.mail-sender {
  width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-subject-snippet {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 16px;
}

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

.mail-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* EMAIL ARTICLE DETAIL */
.email-article {
  padding: 24px 32px;
  overflow-y: auto;
  flex: 1;
}

.article-subject {
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 20px;
}

.article-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sender-meta {
  flex: 1;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sender-email {
  color: var(--text-muted);
  font-size: 13px;
}

.meta-date {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.sec-badge {
  background: #e6f4ea;
  color: #137333;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}

.article-body {
  font-size: 15px;
  line-height: 1.6;
  min-height: 200px;
}

/* ADMIN DASHBOARD */
#view-admin-dashboard {
  padding: 24px 32px;
  overflow-y: auto;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-primary);
  padding: 20px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-color);
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.metric-icon.blue { background: #e8f0fe; color: var(--accent-blue); }
.metric-icon.green { background: #e6f4ea; color: var(--accent-green); }
.metric-icon.purple { background: #f3e8fd; color: #a142f4; }
.metric-icon.orange { background: #feefe3; color: #e37400; }

.metric-value {
  font-size: 20px;
  font-weight: 700;
  display: block;
}

.metric-label {
  font-size: 13px;
  color: var(--text-muted);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.badge-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.badge-status.success { background: #e6f4ea; color: #137333; }

/* COMPOSE MODAL FLOATING */
.compose-modal {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 560px;
  background: var(--bg-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.compose-header {
  background: #f2f6fc;
  padding: 10px 16px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

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

.compose-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compose-row label {
  width: 60px;
  font-size: 13px;
  color: var(--text-muted);
}

.compose-editor-area textarea {
  height: 180px;
  resize: vertical;
}

/* MODAL OVERLAY & CARDS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.input-addon {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}

.input-addon input {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.addon-text {
  background: var(--bg-primary);
  color: var(--text-muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  height: 42px;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
}

/* DNS STATUS GRID */
.dns-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.dns-item {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dns-item strong {
  font-size: 13px;
  color: var(--text-muted);
}

/* PRINT MEDIA QUERY */
@media print {
  body * {
    visibility: hidden;
  }
  #view-mail-detail, #view-mail-detail * {
    visibility: visible;
  }
  #view-mail-detail {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .detail-toolbar, .article-footer-actions {
    display: none !important;
  }
}

.hidden { display: none !important; }
