/* ═══════════════════════════════════════════════
   MPCred Panel — Styles
═══════════════════════════════════════════════ */

:root, [data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273549;
  --border: rgba(255,255,255,.07);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37,99,235,.15);
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f97316;
  --header-h: 56px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: rgba(0,0,0,.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37,99,235,.08);
  --shadow: 0 2px 12px rgba(0,0,0,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: "Segoe UI", Helvetica, Arial, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }

.hidden { display: none !important; }
.full-center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* ── Login ── */
.login-shapes { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.lshape { position: absolute; border-radius: 50%; opacity: .08; }
.s1 { width: 600px; height: 600px; background: #2563eb; top: -200px; left: -150px; animation: float1 12s ease-in-out infinite; }
.s2 { width: 400px; height: 400px; background: #7c3aed; bottom: -100px; right: -100px; animation: float2 9s ease-in-out infinite; }
.s3 { width: 280px; height: 280px; background: #0ea5e9; top: 50%; left: 60%; animation: float1 15s ease-in-out infinite reverse; }
@keyframes float1 { 0%,100%{transform:translateY(0) rotate(0)} 50%{transform:translateY(-30px) rotate(10deg)} }
@keyframes float2 { 0%,100%{transform:translateY(0) rotate(0)} 50%{transform:translateY(20px) rotate(-8deg)} }

.login-card { position: relative; z-index: 1; background: rgba(30,41,59,.92); border: 1px solid var(--border); border-radius: 18px; padding: 40px 36px; width: 340px; backdrop-filter: blur(20px); box-shadow: var(--shadow); }
[data-theme="light"] .login-card { background: rgba(255,255,255,.95); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.lb-name { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.lb-sub { font-size: .78rem; color: var(--muted); margin-top: 1px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.field input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: .95rem; outline: none; transition: border .2s; }
.field input:focus { border-color: var(--accent); }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 42px; }
.eye-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px; }
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: .95rem; font-weight: 700; cursor: pointer; margin-top: 8px; transition: background .2s; }
.btn-primary:hover { background: var(--accent-hover); }
.login-err { color: var(--red); font-size: .83rem; margin-top: 10px; min-height: 18px; }

/* ── App shell ── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.app-header { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 100; }
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-title { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.header-sub { font-size: .75rem; color: var(--muted); border-left: 1px solid var(--border); padding-left: 10px; margin-left: 4px; }
.header-actions { display: flex; gap: 4px; }

.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 7px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--accent-light); color: var(--accent); }

.app-body { padding: 20px; flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Stats ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card.highlight { border-color: var(--accent); background: var(--accent-light); }
.stat-val { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.stat-card.highlight .stat-val { color: var(--accent); }
.stat-lbl { font-size: .75rem; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Filter bar ── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-ico { color: var(--muted); flex-shrink: 0; }
.filter-group input, .filter-group select { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; padding: 7px 11px; color: var(--text); font-size: .85rem; outline: none; min-width: 160px; transition: border .2s; }
.filter-group input[type="date"] { min-width: 130px; }
.filter-group select { min-width: 140px; cursor: pointer; }
.filter-group input:focus, .filter-group select:focus { border-color: var(--accent); }
.btn-search { background: var(--accent); color: white; border: none; border-radius: 7px; padding: 8px 18px; font-size: .85rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background .2s; }
.btn-search:hover { background: var(--accent-hover); }
.btn-clear { background: none; border: 1px solid var(--border); border-radius: 7px; padding: 7px 14px; font-size: .85rem; color: var(--muted); cursor: pointer; transition: border .2s, color .2s; }
.btn-clear:hover { border-color: var(--accent); color: var(--accent); }

.results-info { font-size: .82rem; color: var(--muted); margin-bottom: 10px; padding: 0 2px; min-height: 18px; }

/* ── File table ── */
.file-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table thead th { background: var(--surface2); padding: 11px 14px; text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); }
.file-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.file-table tbody tr:last-child { border-bottom: none; }
.file-table tbody tr:hover { background: var(--accent-light); }
.file-table td { padding: 11px 14px; font-size: .88rem; vertical-align: middle; }
.loading-row { text-align: center; color: var(--muted); padding: 40px !important; }

.file-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px; font-size: 1rem; flex-shrink: 0; }
.fi-excel { background: rgba(34,197,94,.15); }
.fi-image { background: rgba(37,99,235,.15); }
.fi-pdf { background: rgba(239,68,68,.15); }
.fi-audio { background: rgba(168,85,247,.15); }
.fi-video { background: rgba(249,115,22,.15); }
.fi-doc { background: rgba(148,163,184,.12); }

.file-name { font-weight: 500; color: var(--text); word-break: break-all; }
.file-meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }

.sender-badge { display: inline-block; background: var(--accent-light); color: var(--accent); border-radius: 5px; padding: 2px 8px; font-size: .76rem; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.action-btns { display: flex; gap: 4px; }
.btn-preview { background: var(--accent-light); color: var(--accent); border: none; border-radius: 6px; padding: 5px 11px; font-size: .78rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-preview:hover { background: var(--accent); color: white; }
.btn-download { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; color: var(--muted); cursor: pointer; transition: all .15s; display: flex; align-items: center; }
.btn-download:hover { border-color: var(--green); color: var(--green); }
.btn-delete { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; color: var(--muted); cursor: pointer; transition: all .15s; display: flex; align-items: center; }
.btn-delete:hover { border-color: var(--red); color: var(--red); }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 18px 0; flex-wrap: wrap; }
.pg-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 14px; font-size: .84rem; color: var(--text); cursor: pointer; transition: all .15s; }
.pg-btn:hover { border-color: var(--accent); color: var(--accent); }
.pg-btn.active { background: var(--accent); color: white; border-color: var(--accent); font-weight: 700; }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.pg-info { color: var(--muted); font-size: .82rem; padding: 0 10px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 920px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-weight: 700; font-size: 1rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 600px; }
.modal-actions { display: flex; gap: 4px; }
.modal-body { flex: 1; overflow: auto; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Preview content types */
.preview-img { max-width: 100%; max-height: 70vh; border-radius: 8px; display: block; }
.preview-pdf { width: 100%; height: 70vh; border: none; }
.preview-video, .preview-audio { max-width: 100%; }
.preview-video { max-height: 60vh; }
.preview-audio { width: 100%; padding: 30px 20px; }
.preview-meta { padding: 24px; width: 100%; }
.preview-meta table { width: 100%; border-collapse: collapse; }
.preview-meta td { padding: 9px 14px; font-size: .9rem; border-bottom: 1px solid var(--border); }
.preview-meta td:first-child { color: var(--muted); font-weight: 600; width: 150px; }
.preview-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }

/* Excel table preview */
.sheet-tabs { display: flex; gap: 4px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--surface2); flex-shrink: 0; overflow-x: auto; }
.sheet-tab { padding: 5px 14px; border-radius: 6px; font-size: .78rem; font-weight: 600; cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: all .15s; white-space: nowrap; }
.sheet-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.excel-wrap { width: 100%; overflow: auto; padding: 16px; max-height: 65vh; }
.excel-table { border-collapse: collapse; font-size: .8rem; min-width: 100%; }
.excel-table th { background: var(--accent-light); color: var(--accent); font-weight: 700; padding: 6px 10px; border: 1px solid var(--border); position: sticky; top: 0; white-space: nowrap; }
.excel-table td { padding: 5px 10px; border: 1px solid var(--border); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.excel-table tr:hover td { background: var(--accent-light); }
.excel-info { font-size: .78rem; color: var(--muted); padding: 8px 16px; text-align: right; border-top: 1px solid var(--border); }

/* ── Webhook modal ── */
.wh-section { margin-bottom: 18px; }
.wh-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 7px; }
.wh-code { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; padding: 10px 14px; font-family: "Courier New", monospace; font-size: .8rem; word-break: break-all; line-height: 1.6; }
.wh-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.wh-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.wh-table td:first-child { width: 100px; }
.btn-copy { background: var(--accent-light); color: var(--accent); border: none; border-radius: 6px; padding: 6px 14px; font-size: .8rem; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-copy:hover { background: var(--accent); color: white; }

/* ── Spinner ── */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #e2e8f0; border: 1px solid var(--border); border-radius: 8px; padding: 10px 20px; font-size: .88rem; z-index: 9999; box-shadow: var(--shadow); pointer-events: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
  .filter-group input, .filter-group select { min-width: 0; flex: 1; }
  .app-body { padding: 12px; }
  .header-sub { display: none; }
  .file-table thead th:nth-child(3), .file-table td:nth-child(3) { display: none; }
  .modal-box { max-height: 95vh; }
}
