/* ==============================================================================
   SMARTBOOK MAIL - STYLING SYSTEM
   Theme: Electric Blue, Clean White, and Matte Black
   ============================================================================== */

:root {
  /* Color Palette */
  --blue-primary: #0f62fe;
  --blue-hover: #0353e9;
  --blue-light: #e5f0ff;
  --blue-active: #cce3ff;
  
  --black-sidebar: #0f1115;
  --black-card: #161920;
  --black-hover: #222732;
  
  --white-bg: #ffffff;
  --light-grey-bg: #f2f4f8;
  --light-grey-hover: #e8ecf3;
  
  --border-grey: #e1e5eb;
  
  --text-dark: #12161f;
  --text-muted: #626e82;
  --text-light: #ffffff;
  
  --error-color: #da1e28;
  --success-color: #24a148;
  
  /* Fonts & Shadows */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-sm: 0 2px 8px rgba(15, 17, 21, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 17, 21, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 17, 21, 0.12);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
}

body, html {
  height: 100%;
  overflow: hidden;
  background-color: var(--light-grey-bg);
  color: var(--text-dark);
}

/* --- SCREENS CONFIG --- */
.screen {
  display: none;
  height: 100vh;
  width: 100vw;
}

.screen.active {
  display: flex;
}

/* ==================== 1. LOGIN SCREEN STYLES ==================== */
#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, rgba(15, 98, 254, 0.08) 0%, rgba(15, 17, 21, 0.02) 90%), var(--light-grey-bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--white-bg);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-grey);
  animation: fadeIn 0.4s ease-out;
}

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

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-hover));
  color: var(--text-light);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
  margin: 0 auto 16px auto;
  box-shadow: 0 8px 16px rgba(15, 98, 254, 0.25);
}

.login-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 6px;
}

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

/* Forms */
.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.input-group input[type="text"],
.input-group input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-grey);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--light-grey-bg);
  color: var(--text-dark);
  transition: var(--transition);
}

.input-group input:focus {
  border-color: var(--blue-primary);
  background: var(--white-bg);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.15);
}

/* Custom Domain Suffix Wrapper */
.input-domain-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-domain-wrapper input {
  padding-right: 170px !important;
}

.domain-suffix {
  position: absolute;
  right: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}

/* Button & Spinners */
button[type="submit"], .btn-compose, #btn-compose-send {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  background-color: var(--blue-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

button[type="submit"]:hover, .btn-compose:hover, #btn-compose-send:hover {
  background-color: var(--blue-hover);
  box-shadow: 0 4px 12px rgba(15, 98, 254, 0.2);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.alert.error {
  background-color: #fff1f1;
  color: var(--error-color);
  border: 1px solid #ffccd0;
}

.alert.success {
  background-color: #eefdf3;
  color: var(--success-color);
  border: 1px solid #ccf6df;
}

.hidden {
  display: none !important;
}

/* ==================== 2. MAIN APP SCREEN LAYOUT ==================== */
#app-screen {
  flex-direction: row;
}

/* --- SIDEBAR (MATTE BLACK) --- */
#sidebar {
  flex: 0 0 auto;
  width: 25%;
  min-width: 220px;
  max-width: 260px;
  background-color: var(--black-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-left: 8px;
}

.sidebar-header .logo {
  width: 32px;
  height: 32px;
  background-color: var(--blue-primary);
  color: var(--text-light);
  font-weight: 700;
  font-size: 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header .app-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.btn-compose {
  margin-bottom: 24px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: var(--transition);
}

.menu-item:hover {
  background-color: var(--black-hover);
  color: var(--text-light);
}

.menu-item.active {
  background-color: var(--blue-primary);
  color: var(--text-light);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.avatar {
  width: 36px;
  height: 36px;
  background-color: var(--blue-light);
  color: var(--blue-primary);
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-status {
  font-size: 11px;
  color: var(--success-color);
  font-weight: 500;
}

.btn-logout {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255,255,255,0.8);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background-color: var(--error-color);
  color: var(--text-light);
  border-color: var(--error-color);
}

/* --- MIDDLE EMAIL LIST PANE (CLEAN WHITE) --- */
#email-list-pane {
  flex: 0 0 auto;
  width: 35%;
  min-width: 280px;
  max-width: 360px;
  background-color: var(--white-bg);
  border-right: 1px solid var(--border-grey);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border-grey);
}

.pane-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--light-grey-hover);
}

.search-bar-wrapper {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-grey);
}

.search-bar-wrapper input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-grey);
  background-color: var(--light-grey-bg);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.search-bar-wrapper input:focus {
  background-color: var(--white-bg);
  border-color: var(--blue-primary);
}

#email-list-container {
  flex-grow: 1;
  overflow-y: auto;
}

/* Email Card Item */
.email-item {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-grey);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
}

.email-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--blue-primary);
  opacity: 0;
  transition: var(--transition);
}

.email-item:hover {
  background: linear-gradient(90deg, var(--light-grey-bg) 0%, var(--white-bg) 100%);
  transform: translateX(4px);
  box-shadow: -4px 0 0 rgba(15, 98, 254, 0.2);
}

.email-item.active {
  background: linear-gradient(90deg, var(--blue-light) 0%, var(--white-bg) 100%);
  transform: translateX(8px);
  box-shadow: -4px 0 0 var(--blue-primary), var(--shadow-sm);
}

.email-item.active::after {
  opacity: 0; /* Use box shadow instead for smoother scale */
}

.email-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.email-sender {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 180px;
}

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

.email-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.email-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- RIGHT DETAIL PANE --- */
#email-detail-pane {
  flex-grow: 1;
  min-width: 300px;
  background-color: var(--white-bg);
  display: flex;
  flex-direction: column;
}

.detail-empty {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.detail-empty h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

#detail-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.detail-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-grey);
}

.subject-row h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.sender-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sender-avatar {
  width: 44px;
  height: 44px;
  background-color: var(--blue-primary);
  color: var(--text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.sender-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.sender-info strong {
  font-size: 15px;
  color: var(--text-dark);
}

.date-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-secondary {
  padding: 8px 16px;
  background-color: var(--light-grey-bg);
  border: 1px solid var(--border-grey);
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

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

.detail-body {
  flex-grow: 1;
  padding: 32px;
  overflow: auto;
}

#detail-body-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

/* ==================== 3. COMPOSE MODAL STYLES ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 17, 21, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.compose-card {
  width: 100%;
  max-width: 600px;
  height: 80%;
  max-height: 600px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.compose-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-grey);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.compose-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

#compose-form {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 24px;
  overflow: hidden;
}

.compose-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-grey);
  margin-bottom: 12px;
}

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

.compose-field input {
  flex-grow: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-dark);
  background-color: transparent;
}

.compose-body-field {
  flex-grow: 1;
  display: flex;
  margin-top: 12px;
}

.compose-body-field textarea {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
}

.compose-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-grey);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-flat {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
}

.btn-flat:hover {
  background-color: var(--light-grey-bg);
  color: var(--text-dark);
}

#btn-compose-send {
  width: auto;
  padding: 10px 24px;
}

/* Loading Spinners */
.spinner, .spinner-inline, .spinner-blue {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid var(--text-light);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
}

.spinner-blue {
  border: 2px solid var(--blue-light);
  border-top: 2px solid var(--blue-primary);
  width: 24px;
  height: 24px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 12px;
}

.loading-state p {
  font-size: 13px;
}
