/* Webmail Progo. Modern Gmail-inspired Dark Theme with Progonet Emerald Green accents. Mobile-first: <700 satu panel, 700-1099 daftar + pembaca, >=1100 tiga panel. */
:root {
  --bg: #090e0b;
  --card: #101912;
  --card-2: #16221a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8f0e9;
  --muted: #9db1a2;
  --faint: #7e9484;
  --accent: #3dba00;
  --on-accent: #051408;
  --danger: #ff6849;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.listbody { display: contents; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.noscript { padding: 1rem; }

/* tombol & input */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 40px; padding: 0 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card-2); font-size: 0.875rem; transition: all 0.15s ease; }
.btn:hover { background: #1f2e24; border-color: rgba(255, 255, 255, 0.15); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: #4ce000; box-shadow: 0 0 16px rgba(61, 186, 0, 0.35); }
.btn.outline { background: transparent; border-color: var(--line); color: var(--text); }
.btn.outline:hover { background: var(--card-2); border-color: var(--text); }
.btn.primary-outline { background: transparent; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn.primary-outline:hover { background: rgba(61, 186, 0, 0.15); }
.btn.icon { min-width: 40px; padding: 0; }
.btn.icon-sm { min-height: 32px; width: 32px; padding: 0; border-radius: 6px; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field > span { font-size: 0.8125rem; color: var(--muted); font-weight: 500; }
.input { min-height: 42px; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); width: 100%; min-width: 0; font-size: 0.9375rem; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 220px; resize: vertical; line-height: 1.6; }
.input::placeholder { color: var(--faint); }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at top right, rgba(61,186,0,0.1), transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.login-card h1 { margin: 0; font-size: 1.375rem; font-weight: 600; }
.login-card p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.hint { font-size: 0.875rem; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 0.65rem; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.err { color: var(--danger); font-size: 0.875rem; min-height: 1.4em; }

/* kerangka utama */
.shell { height: 100dvh; display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 600; margin-right: auto; display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-size: 1.05rem; }
.who { color: var(--muted); font-size: 0.875rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.panes { display: grid; min-height: 0; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.folders { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); background: var(--card); }
.folder { display: flex; align-items: center; gap: 0.6rem; min-height: 42px; padding: 0 0.85rem; border: 1px solid transparent; border-radius: var(--radius); background: transparent; white-space: nowrap; text-align: left; font-size: 0.9375rem; transition: background 0.15s; }
.folder:hover { background: var(--card-2); }
.folder[aria-current="true"] { background: var(--card-2); border-color: var(--line); color: var(--accent); font-weight: 600; }
.folder .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.folder .count { font: 0.8125rem var(--mono); color: var(--muted); }
.folder .count.unread { color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 0.05rem 0.5rem; font-weight: 700; }
.content { display: grid; min-height: 0; grid-template-columns: 1fr; }
.listpane, .readpane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.readpane { border-left: 1px solid var(--line); background: var(--bg); overflow-y: auto; }
.shell[data-view="list"] .readpane { display: none; }
.shell[data-view="read"] .listpane { display: none; }

/* search & filter chips */
.searchbar { display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); background: var(--card); }
.filter-chips { display: flex; gap: 0.4rem; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); overflow-x: auto; background: var(--card-2); }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.65rem; border-radius: 20px; font-size: 0.8125rem; background: var(--card); border: 1px solid var(--line); color: var(--muted); cursor: pointer; white-space: nowrap; transition: all 0.15s ease; user-select: none; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: rgba(61, 186, 0, 0.15); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* daftar surat (ala gmail) */
.msglist { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
.msg { display: grid; grid-template-columns: auto auto auto 1fr auto; gap: 0.5rem 0.65rem; align-items: center; width: 100%; padding: 0.7rem 0.85rem; min-height: 54px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; position: relative; transition: background 0.15s ease; cursor: pointer; }
.msg:hover { background: var(--card); }
.msg[aria-current="true"] { background: var(--card-2); box-shadow: inset 3px 0 0 var(--accent); }
.msg.unread { background: rgba(61, 186, 0, 0.035); }
.msg .dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.msg.unread .dot { background: var(--accent); box-shadow: 0 0 8px rgba(61,186,0,0.6); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.875rem; color: #fff; flex-shrink: 0; text-transform: uppercase; user-select: none; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.avatar.sm { width: 28px; height: 28px; font-size: 0.75rem; }

.msg .star-btn { background: transparent; border: 0; padding: 4px; color: var(--faint); cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.msg .star-btn:hover { color: #f0b429; transform: scale(1.15); }
.msg .star-btn.starred { color: #f0b429; }

.msg .from { font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.msg.unread .from { font-weight: 700; color: #fff; }

.msg .subj-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--muted); }
.msg.unread .subj-line { color: var(--text); }
.msg .subj-title { font-weight: 500; }
.msg.unread .subj-title { font-weight: 700; color: #fff; }
.msg .subj-snippet { color: var(--faint); font-weight: 400; }
.msg .att-pill { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--muted); flex-shrink: 0; }

.msg .when { font: 0.8125rem var(--mono); color: var(--muted); white-space: nowrap; text-align: right; }
.msg .hover-actions { display: none; position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px 5px; gap: 3px; box-shadow: 0 4px 14px rgba(0,0,0,0.6); z-index: 5; }
.msg:hover .hover-actions { display: flex; }
.msg .hover-actions button { background: transparent; border: 0; padding: 5px; border-radius: 5px; color: var(--muted); cursor: pointer; display: flex; }
.msg .hover-actions button:hover { background: var(--card-2); color: var(--text); }
.msg .hover-actions button.del:hover { color: var(--danger); }

.empty { padding: 3rem 1rem; color: var(--muted); text-align: center; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0.85rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }

/* pembaca surat */
.readhead { padding: 1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.75rem; background: var(--card); }
.readhead h2 { margin: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.35; }
.sender-row { display: flex; align-items: center; gap: 0.75rem; }
.sender-details { display: flex; flex-direction: column; min-width: 0; }
.sender-name { font-weight: 600; font-size: 0.95rem; color: #fff; }
.sender-email { font-size: 0.8125rem; color: var(--muted); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; font-size: 0.8125rem; color: var(--muted); margin-top: 0.25rem; }
.meta b { font-weight: 500; color: var(--faint); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* lampiran berkas (ala gmail cards) */
.attachments-section { padding: 1rem; border-top: 1px solid var(--line); background: var(--card-2); }
.attachments-header { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }
.attachments-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.75rem; }
.attachment-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; transition: all 0.2s ease; }
.attachment-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.45); }
.att-thumb { height: 115px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.35); position: relative; overflow: hidden; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb.doc-thumb { flex-direction: column; gap: 0.35rem; color: var(--accent); }
.att-thumb .ext-badge { font: 0.75rem var(--mono); font-weight: 700; background: rgba(61, 186, 0, 0.2); border: 1px solid var(--accent); padding: 2px 7px; border-radius: 4px; color: #fff; }
.att-info { padding: 0.6rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.att-name { font-size: 0.8125rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.att-size { font: 0.75rem var(--mono); color: var(--muted); }
.att-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; padding: 0.4rem 0.75rem; border-top: 1px solid var(--line); background: rgba(0,0,0,0.15); }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; background: var(--card); }
.frame { flex: 1; min-height: 300px; width: 100%; border: 0; background: #fff; }

/* quick reply box di bawah reader */
.quick-reply-card { padding: 1rem; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 0.75rem; align-items: center; }
.quick-reply-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }

/* tulis surat (compose) */
.compose { padding: 1rem; display: flex; flex-direction: column; gap: 0.85rem; overflow-y: auto; min-height: 0; }
.compose h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.format-bar { display: flex; align-items: center; gap: 0.25rem; padding: 0.35rem 0.5rem; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); flex-wrap: wrap; }
.format-btn { background: transparent; border: 0; padding: 6px 8px; border-radius: 6px; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.format-btn:hover { background: var(--card); color: var(--text); }
.compose-dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 0.5rem; transition: border-color 0.2s; }
.compose-dropzone.dragover { border-color: var(--accent); background: rgba(61, 186, 0, 0.05); }
.compose-atts-container { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.compose-att-chip { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.65rem; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; font-size: 0.8125rem; max-width: 100%; }
.compose-att-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.compose-att-chip .size { color: var(--muted); font: 0.75rem var(--mono); }
.compose-att-chip .remove { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; border-radius: 4px; font-size: 1rem; line-height: 1; }
.compose-att-chip .remove:hover { color: var(--danger); }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.placeholder { margin: auto; color: var(--muted); padding: 2rem; text-align: center; }

#toast { position: fixed; left: 0.75rem; right: 0.75rem; bottom: 0.75rem; display: flex; justify-content: center; pointer-events: none; z-index: 20; }
#toast div { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem; max-width: 520px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
#toast div.bad { border-color: var(--danger); color: #ffd6cc; }
.compose-file-input { display: none !important; }

/* modal ganti password */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100; backdrop-filter: blur(4px); }
.modal-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.modal-card h2 { margin: 0; font-size: 1.25rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }

@media (max-width: 699px) {
  .who { display: none; }
  .tb .lbl { display: none; }
  .tb { min-width: 40px; padding: 0 0.5rem; }
  .msg { grid-template-columns: auto auto 1fr auto; }
  .msg .dot { display: none; }
  .msg .from { max-width: 100px; }
}

@media (min-width: 700px) {
  .row2 { grid-template-columns: 1fr 1fr; }
  .content { grid-template-columns: minmax(320px, 400px) 1fr; }
  .shell[data-view="list"] .readpane, .shell[data-view="read"] .listpane { display: flex; }
  .btn.back { display: none; }
  .who { max-width: 28vw; }
}

@media (min-width: 1100px) {
  .panes { grid-template-columns: 240px 1fr; grid-template-rows: 1fr; }
  .folders { flex-direction: column; overflow-x: visible; overflow-y: auto; border-bottom: 0; border-right: 1px solid var(--line); padding: 0.65rem; }
  .content { grid-template-columns: minmax(360px, 440px) 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
