/* Mail v2 — Gmail-stili tam donanım CSS */

.mail-app { display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 600px; }
.mail-topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.mail-search-input {
  flex: 1; padding: 10px 16px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 24px; background: white;
}
.mail-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(104,22,32,0.1); }
.mail-search-clear { padding: 6px 10px; background: transparent; border: none; font-size: 16px; color: var(--text-tertiary); cursor: pointer; }

.mail-shell {
  flex: 1; display: grid; grid-template-columns: 240px 380px 1fr;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; min-height: 0;
}

/* ====== Sol Sidebar ====== */
.mail-sidebar { border-right: 1px solid var(--border); overflow-y: auto; background: var(--bg); min-height: 0; }
.mail-compose-btn {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  margin: 14px 16px; background: var(--primary); color: white;
  border: none; border-radius: 24px; font-weight: 600; font-size: 14px;
  cursor: pointer; width: calc(100% - 32px); justify-content: center;
  box-shadow: 0 2px 6px rgba(104,22,32,0.2);
  transition: all 0.2s;
}
.mail-compose-btn:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(104,22,32,0.3); }
.mail-folders-nav { padding: 6px 8px; }
.mail-folder-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 0 24px 24px 0; cursor: pointer;
  font-size: 13.5px; color: var(--text); user-select: none;
  margin: 1px 0;
}
.mail-folder-item:hover { background: var(--surface-hover); }
.mail-folder-item.active { background: rgba(104,22,32,0.12); color: var(--primary); font-weight: 700; }
.mail-folder-icon { font-size: 16px; width: 22px; display: inline-block; text-align: center; }
.mail-folder-label { flex: 1; }
.mail-folder-count { font-size: 11px; color: var(--text-tertiary); }
.mail-unread-badge { background: var(--primary); color: white; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }

.mail-accounts-section { padding: 12px 8px; border-top: 1px solid var(--border); margin-top: 10px; }
.mail-section-title { font-size: 11px; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; padding: 4px 12px; letter-spacing: 0.5px; }
.mail-account-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.mail-account-item:hover { background: var(--surface-hover); }
.mail-account-item.active { background: rgba(104,22,32,0.08); }
.mail-acc-avatar {
  width: 32px; height: 32px; border-radius: 50%; color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.mail-acc-info { flex: 1; min-width: 0; }
.mail-acc-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-acc-mail { font-size: 10.5px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ====== Orta: Thread List ====== */
.mail-center { border-right: 1px solid var(--border); background: white; min-height: 0; display: flex; flex-direction: column; }
.mail-list { overflow-y: auto; flex: 1; min-height: 0; }
.mail-list-header { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.mail-list-title { font-size: 13px; font-weight: 700; color: var(--text); }
.mail-list-count { font-size: 11px; color: var(--text-tertiary); margin-left: auto; }
.mail-list-refresh { padding: 4px 10px; background: transparent; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 14px; }
.mail-list-refresh:hover { background: var(--surface-hover); }

.mail-bulk-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: linear-gradient(180deg, #fff7e6, #ffefc7);
  border-bottom: 1px solid #f0c674; font-size: 13px;
}
.bulk-actions { display: flex; gap: 4px; }
.bulk-actions button {
  padding: 6px 10px; background: white; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 14px;
}
.bulk-actions button:hover { background: var(--primary); color: white; border-color: var(--primary); }

.mail-thread-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.mail-thread-item:hover { background: #f8f8f8; }
.mail-thread-item.active { background: rgba(104,22,32,0.06); border-left: 3px solid var(--primary); padding-left: 11px; }
.mail-thread-item.cursor { background: rgba(0,0,0,0.04); }
.mail-thread-item.selected { background: #fff8e1; }
.mail-thread-item.unread .mail-thread-from,
.mail-thread-item.unread .mail-thread-subject { font-weight: 700; color: #000; }
.mail-thread-item.unread::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 60%; background: var(--primary); border-radius: 0 2px 2px 0;
}

.mail-thread-item input[type=checkbox] { margin: 0; cursor: pointer; }
.mail-star { font-size: 18px; cursor: pointer; color: #cbd5e0; transition: color 0.2s; }
.mail-star.on { color: #f5b800; }
.mail-star:hover { color: #f5b800; }

.mail-thread-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #681620, #a82d40); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.mail-thread-meta { flex: 1; min-width: 0; }
.mail-thread-top { display: flex; align-items: center; gap: 6px; }
.mail-thread-from { font-size: 13px; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-thread-count { font-size: 11px; color: var(--text-tertiary); }
.mail-thread-date { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.mail-thread-subject { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-thread-preview { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; display: flex; align-items: center; gap: 4px; }
.mail-attach-icon { font-size: 11px; }

.mail-thread-actions {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  display: none; gap: 2px; background: white; padding: 4px; border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.mail-thread-item:hover .mail-thread-actions { display: flex; }
.mail-thread-actions button { padding: 4px 8px; background: transparent; border: none; cursor: pointer; font-size: 13px; }
.mail-thread-actions button:hover { background: var(--surface-hover); }

/* ====== Sağ: Mail View ====== */
.mail-right { background: white; overflow: hidden; min-height: 0; display: flex; flex-direction: column; }
#mail-view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.mail-view-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg);
  flex-shrink: 0; overflow-x: auto;
}
.mail-view-toolbar button {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; background: white; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  font-family: inherit;
}
.mail-view-toolbar button:hover { background: var(--surface-hover); border-color: var(--primary); }
.tb-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.mail-view-header { padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.mail-view-subject { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.mail-view-meta { font-size: 12px; color: var(--text-secondary); }

.mail-view-body { flex: 1; overflow-y: auto; padding: 14px 18px; background: #fafafa; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.mail-msg { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.mail-msg.in { border-left: 3px solid var(--primary); }
.mail-msg.out { border-left: 3px solid #16a34a; background: #f9fdf6; }
.mail-msg-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.mail-msg-from { font-size: 13.5px; font-weight: 700; color: var(--text); }
.mail-msg-addr { color: var(--text-tertiary); font-weight: 400; font-size: 11px; }
.mail-msg-date { font-size: 11.5px; color: var(--text-tertiary); }
.mail-msg-to { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; }
.mail-msg-body { font-size: 13.5px; line-height: 1.55; color: var(--text); word-wrap: break-word; overflow-wrap: break-word; margin-top: 6px; }
.mail-msg-body img { max-width: 100%; height: auto; border-radius: 6px; }
.mail-msg-body a { color: var(--primary); }
.mail-msg-body table { max-width: 100%; }
.mail-msg-attachments { margin-top: 10px; padding: 8px 12px; background: var(--bg); border-radius: 6px; font-size: 12px; color: var(--text-secondary); }
.mail-msg-foot { margin-top: 10px; text-align: right; }
.mail-dl { font-size: 11.5px; color: var(--text-secondary); text-decoration: none; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px; }
.mail-dl:hover { background: var(--surface-hover); color: var(--primary); }

.mail-empty { padding: 60px 20px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.mail-spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: mailSpin 0.7s linear infinite;
}
@keyframes mailSpin { to { transform: rotate(360deg); } }

/* Skeleton loading */
.mail-thread-item.skeleton { pointer-events: none; }
.sk-box { background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%); background-size: 200% 100%; animation: skShimmer 1.2s linear infinite; border-radius: 4px; }
.sk-check { width: 16px; height: 16px; }
.sk-star { width: 16px; height: 16px; }
.sk-avatar { width: 34px; height: 34px; border-radius: 50%; }
.sk-line1 { width: 60%; height: 11px; margin-bottom: 6px; }
.sk-line2 { width: 90%; height: 9px; }
@keyframes skShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ====== Composer Modal ====== */
#mail-composer-modal { position: fixed; bottom: 0; right: 30px; z-index: 9999; }
.comp-modal {
  width: 580px; max-width: calc(100vw - 60px); height: 600px; max-height: calc(100vh - 80px);
  background: white; border: 1px solid var(--border);
  border-radius: 12px 12px 0 0; box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
}
.comp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--primary); color: white;
  border-radius: 12px 12px 0 0; flex-shrink: 0;
}
.comp-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.comp-actions-top button { background: transparent; border: none; color: white; cursor: pointer; padding: 4px 10px; font-size: 18px; }
.comp-body-wrap { padding: 8px 12px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.comp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.comp-row label { font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); min-width: 50px; }
.comp-row input, .comp-row select { flex: 1; padding: 6px 8px; border: none; outline: none; font-size: 13px; font-family: inherit; background: transparent; }
.comp-cc-toggle { padding: 4px 10px; background: transparent; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 11.5px; color: var(--text-secondary); }
#comp-body {
  flex: 1; width: 100%; padding: 12px 4px; border: none; outline: none;
  font-size: 14px; line-height: 1.55; font-family: inherit; resize: none;
  background: transparent; min-height: 200px;
}
.comp-footer {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg);
  flex-shrink: 0; flex-wrap: wrap;
}
.comp-left { display: flex; gap: 6px; align-items: center; }
.comp-right { display: flex; gap: 4px; }
.comp-send {
  padding: 8px 18px; background: var(--primary); color: white;
  border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px;
  font-family: inherit;
}
.comp-send:hover { background: var(--primary-hover); }
.comp-send:disabled { opacity: 0.6; cursor: not-allowed; }
.comp-tone { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-family: inherit; background: white; }
.comp-polish {
  padding: 8px 12px; background: #7c3aed; color: white;
  border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 12.5px;
  font-family: inherit;
}
.comp-polish:hover { background: #6d28d9; }
.comp-polish:disabled { opacity: 0.6; cursor: not-allowed; }
.comp-right button { padding: 8px 12px; background: transparent; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 14px; }
.comp-right button:hover { background: var(--surface-hover); }

/* ====== Toast ====== */
.mail-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 12px 22px; background: #323232; color: white;
  border-radius: 8px; font-size: 13px; z-index: 10000;
  opacity: 0; transition: all 0.3s; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  font-family: inherit;
}
.mail-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.mail-toast.error { background: #c62828; }
.mail-toast.info { background: #323232; }

/* ====== Mobile ====== */
@media (max-width: 1100px) {
  .mail-shell { grid-template-columns: 200px 320px 1fr; }
}
@media (max-width: 900px) {
  .mail-shell { grid-template-columns: 1fr; }
  .mail-sidebar, .mail-center { display: none; }
  .mail-shell.show-list .mail-center { display: flex; }
  .mail-shell.show-view .mail-right { display: flex; }
  #mail-composer-modal { right: 0; left: 0; }
  .comp-modal { width: 100%; max-width: 100%; border-radius: 0; }
}

/* === Composer ekleri === */
.comp-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0; }
.comp-att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-hover, #f1f5f9); border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px; padding: 4px 10px; font-size: 12px; color: var(--text-secondary, #475569);
}
.comp-att-chip small { opacity: 0.7; }
.comp-att-x {
  background: transparent; border: none; cursor: pointer; font-size: 15px;
  line-height: 1; color: var(--text-tertiary, #94a3b8); padding: 0;
}
.comp-att-x:hover { color: #dc2626; }
.comp-attach-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 16px;
  border: 1px solid var(--border, #e2e8f0); background: var(--surface, #fff);
}
.comp-attach-btn:hover { border-color: var(--primary, #681620); }

/* === Gelen ek indirme linkleri === */
.mail-msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mail-att {
  display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
  background: var(--surface-hover, #f1f5f9); border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--text-secondary, #475569);
}
.mail-att small { opacity: 0.7; }
a.mail-att:hover { border-color: var(--primary, #681620); color: var(--primary, #681620); }
.mail-att-static { opacity: 0.7; cursor: default; }

/* === Sipariş / Pazaryeri smart sekmesi === */
.mail-folder-smart { border-top: 1px solid var(--border, #e2e8f0); margin-top: 6px; padding-top: 10px; }
.mail-folder-smart.active .mail-folder-label { font-weight: 600; }
