/* ================================================================
   İcon Mail Paneli — Dark Mode CSS
   ================================================================ */

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

:root {
  /* Corporate Theme Defaults (Light) */
  --bg-base:       #f8fafc;
  --bg-sidebar:    #ffffff;
  --bg-panel:      #ffffff;
  --bg-detail:     #f8fafc;
  --bg-hover:      #f1f5f9;
  --bg-active:     #e2e8f0;
  --bg-card:       #ffffff;
  --bg-modal:      #ffffff;

  --border:        #e2e8f0;
  --border-light:  #cbd5e1;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-glow:   rgba(37, 99, 235, 0.25);

  --danger:        #ef4444;
  --danger-hover:  #dc2626;
  --success:       #10b981;
  --warning:       #eab308;

  --text-primary:  #1e293b;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;
  --text-accent:   #2563eb;

  --unread-dot:    #2563eb;

  --sidebar-w:     250px;
  --list-w:        360px;
  --header-h:      60px;

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  --shadow-sm:     0 1px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg:     0 10px 15px -3px rgba(0, 0, 0, 0.7);

  --transition:    all .2s ease;
}

html, body {
  height: 100%;
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Screen Wrapper ─────────────────────────────────────────────── */
.screen { width: 100%; height: 100vh; }
.hidden { display: none !important; }

/* ── Forbidden ──────────────────────────────────────────────────── */
#screen-forbidden {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}
.forbidden-box {
  text-align: center;
  padding: 48px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.forbidden-icon { font-size: 48px; margin-bottom: 16px; }
.forbidden-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.forbidden-box p  { color: var(--text-secondary); }

/* ── Loading ────────────────────────────────────────────────────── */
#screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}
.loading-spinner {
  text-align: center;
  color: var(--text-secondary);
}
.loading-spinner p { margin-top: 16px; font-size: 13px; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App Layout ─────────────────────────────────────────────────── */
#screen-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────── */
#app-header {
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}
.brand-icon { font-size: 20px; }
.brand-name strong { color: var(--text-accent); }
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-hamburger, .btn-mobile-back { display: none; }
.btn-mobile-back {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px 0;
  font-family: inherit;
}
.btn-compose {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-compose:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.spinning svg { animation: spin .7s linear infinite; }

/* ── Panel Container ────────────────────────────────────────────── */
.panel-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.sidebar-section { padding: 16px 0 8px; }
.sidebar-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: 0 16px 8px;
  text-transform: uppercase;
}

/* Account nav items */
.accounts-nav, .folders-nav { display: flex; flex-direction: column; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  transition: var(--transition);
  position: relative;
  width: 100%;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item-icon { font-size: 14px; flex-shrink: 0; }
.nav-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Mail List Panel ─────────────────────────────────────────────── */
.mail-list-panel {
  width: var(--list-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.mail-list-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mail-folder-title { font-size: 15px; font-weight: 600; }
.mail-count { font-size: 12px; color: var(--text-muted); }

.mail-search-box {
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.search-icon {
  position: absolute;
  left: 30px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}
.search-input {
  padding-left: 36px;
  padding-right: 30px;
  border-radius: var(--radius-md);
  border: 1px solid transparent; /* Cleaner look */
  background: var(--bg-hover);
  height: 36px;
}
.search-input:focus {
  background: var(--bg-card);
  border-color: var(--accent);
}
.btn-clear-search {
  position: absolute;
  right: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.btn-clear-search:hover { color: var(--danger); }

.mail-list {
  flex: 1;
  overflow-y: auto;
}
.mail-list::-webkit-scrollbar { width: 4px; }
.mail-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* Mail Card */
.mail-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.mail-card:hover { background: var(--bg-hover); }
.mail-card.active { background: var(--bg-active); }
.mail-card.unread .mail-sender { font-weight: 600; color: var(--text-primary); }
.mail-card.unread .mail-subject { color: var(--text-primary); }

.mail-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.mail-sender {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.mail-date {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}
.mail-subject {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}
.mail-preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unread-dot {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-page {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.btn-page:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-page:disabled { opacity: .4; cursor: not-allowed; }
#page-info { font-size: 12px; color: var(--text-muted); }

/* ── Mail Detail Panel ──────────────────────────────────────────── */
.mail-detail-panel {
  flex: 1;
  background: var(--bg-detail);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-subject {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  line-height: 1.4;
}
.detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.detail-from {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7b5cf7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.detail-from-name  { font-size: 13px; font-weight: 600; }
.detail-from-email { font-size: 12px; color: var(--text-muted); }
.detail-date { font-size: 12px; color: var(--text-muted); }
.detail-to-row {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.to-label { color: var(--text-muted); margin-right: 4px; }
span#detail-to { color: var(--text-secondary); }

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-detail-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn-detail-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-detail-action.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(224,82,82,.08); }

.attachments-bar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.att-dl-icon {
  margin-left: 2px;
  opacity: 0;
  font-size: 11px;
  transition: opacity .15s ease;
  flex-shrink: 0;
}
.attachment-chip:hover .att-dl-icon { opacity: 1; }


.attachments-bar.empty { display: none; }
.attach-remove {
  background: none; border: none; color: var(--danger); font-size: 11px;
  cursor: pointer; margin-left: 4px; padding: 2px;
}
.attach-remove:hover { color: var(--danger-hover); }

.detail-body {
  flex: 1;
  overflow: hidden;
}
#detail-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}
.empty-state span { font-size: 42px; opacity: .5; }
.empty-state p { font-size: 13px; }

/* ── Kilit Ekranı (Locked Account) ──────────────────────────────── */
.locked-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  padding: 24px;
}
.locked-icon { font-size: 42px; }
.locked-state h3 { font-size: 16px; color: var(--text-primary); margin-bottom: 4px; }
.locked-state p { font-size: 13px; color: var(--text-secondary); text-align: center; }
.locked-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; width: 220px; }
.locked-form input { 
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); 
  padding: 10px; border-radius: var(--radius-sm); text-align: center; font-size: 18px; letter-spacing: 2px;
}
.locked-form input:focus { border-color: var(--accent); outline: none; }
.locked-form button {
  background: var(--accent); color: #fff; border: none; padding: 10px; 
  border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: var(--transition);
}
.locked-form button:hover { background: var(--accent-hover); }

/* ── Compose Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
}
.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}
.btn-modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.form-input, .form-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-select option { background: var(--bg-card); }

.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.toolbar-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: inherit;
  transition: var(--transition);
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-sep { width: 1px; background: var(--border); margin: 0 4px; }

.form-editor {
  min-height: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  line-height: 1.6;
}
.form-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.btn-primary {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  animation: fadeIn .2s ease;
  white-space: nowrap;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Skeleton Loading ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-active) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-sender { height: 12px; width: 60%; margin-bottom: 8px; }
.skeleton-subject { height: 12px; width: 85%; margin-bottom: 6px; }
.skeleton-preview { height: 10px; width: 75%; }

/* ── Scrollbar Global ───────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-light) transparent; }

/* ── Responsive Mobile Update ─────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; --list-w: 280px; }
}
@media (max-width: 680px) {
  :root { --list-w: 100vw; }
  
  /* Show hamburger button */
  .btn-hamburger, .btn-mobile-back { display: flex; }
  
  /* Sidebar as mobile sliding drawer */
  .sidebar { 
    position: fixed; 
    left: -280px; 
    top: var(--header-h); 
    width: 280px; 
    height: calc(100vh - var(--header-h));
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  
  /* Detail panel sliding */
  .mail-detail-panel { 
    position: fixed;
    top: var(--header-h);
    left: 100vw;
    width: 100vw;
    height: calc(100vh - var(--header-h));
    z-index: 80;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; /* Override display:none from old code */
  }
  .mail-detail-panel.detail-open {
    left: 0;
  }
  
  /* Mail List Panel */
  .mail-list-panel { width: 100vw; border-right: none; }
  
  /* Modals */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { width: 100vw; max-width: 100vw; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

