/* ATP Finance — Custom Styles */

/* ── Body fade-in ────────────────────────────────────────── */
body {
  font-family: 'Inter', sans-serif;
  opacity: 0;
  transition: opacity 0.1s ease-in;
}
body.theme-loaded { opacity: 1; }
.no-transition * { transition: none !important; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: #4b5563; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Sidebar active state ────────────────────────────────── */
.sidebar-link.active {
  background-color: var(--theme-50, #EEF2FF);
  color: var(--theme-600, #4F46E5);
  border-right: 3px solid var(--theme-600, #4F46E5);
}
.dark .sidebar-link.active {
  background-color: rgba(99, 102, 241, 0.12);
  color: var(--theme-400, #818CF8);
  border-right-color: var(--theme-400, #818CF8);
}

/* ── Smooth color transitions ────────────────────────────── */
* {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* ── Global loading overlay ──────────────────────────────── */
#global-loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.dark #global-loading-overlay { background: rgba(17, 24, 39, 0.55); }
#global-loading-overlay.is-active {
  display: flex;
  pointer-events: all;
}

#global-loading-card {
  width: 320px;
  max-width: calc(100vw - 40px);
  border-radius: 20px;
  padding: 22px 20px 18px;
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.dark #global-loading-card {
  background: rgba(31, 41, 55, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

#global-loading-row { display: flex; align-items: center; gap: 14px; }

#global-loading-badge {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(var(--theme-500-rgb, 99, 102, 241), 0.12);
  flex-shrink: 0;
}
.dark #global-loading-badge { background: rgba(var(--theme-500-rgb, 99, 102, 241), 0.18); }

#global-loading-spinner {
  width: 28px; height: 28px; border-radius: 9999px;
  background: conic-gradient(
    from 0deg,
    var(--theme-500, #6366F1),
    var(--theme-700, #4338CA),
    var(--theme-500, #6366F1)
  );
  animation: globalSpin 0.9s linear infinite;
  position: relative;
}
#global-loading-spinner::after {
  content: "";
  position: absolute; inset: 3px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.95);
}
.dark #global-loading-spinner::after { background: rgba(17, 24, 39, 0.88); }

#global-loading-title {
  display: block;
  font-weight: 700; font-size: 14px; line-height: 20px;
  color: #111827; letter-spacing: -0.01em;
}
.dark #global-loading-title { color: #F9FAFB; }

#global-loading-subtitle {
  display: block;
  margin-top: 2px; font-size: 12px; line-height: 16px;
  color: rgba(17, 24, 39, 0.65);
}
.dark #global-loading-subtitle { color: rgba(249, 250, 251, 0.68); }

#global-loading-shimmer {
  height: 8px; margin-top: 16px; border-radius: 9999px;
  background: rgba(var(--theme-500-rgb, 99, 102, 241), 0.12);
  position: relative; overflow: hidden;
}
.dark #global-loading-shimmer { background: rgba(var(--theme-500-rgb, 99, 102, 241), 0.18); }
#global-loading-shimmer::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(
    90deg,
    var(--theme-500, #6366F1),
    var(--theme-600, #4F46E5),
    var(--theme-700, #4338CA)
  );
  transform-origin: left;
  transform: scaleX(0);
  animation: globalFill 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

@keyframes globalSpin { to { transform: rotate(360deg); } }
@keyframes globalFill {
  0%   { transform: scaleX(0); opacity: 0.85; }
  75%  { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

/* ── Card helper ─────────────────────────────────────────── */
.atp-card {
  background: white;
  border-radius: 0.75rem;
  border: 1px solid #E5E7EB;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.dark .atp-card { background: #1f2937; border-color: #374151; }

/* ── Table ───────────────────────────────────────────────── */
.atp-table th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem; font-weight: 600;
  color: #6B7280;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid #E5E7EB;
}
.dark .atp-table th { color: #9CA3AF; border-color: #374151; }
.atp-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem; color: #111827;
  border-bottom: 1px solid #F3F4F6;
}
.dark .atp-table td { color: #F9FAFB; border-color: #374151; }

/* ── Form inputs (widget fallback) ───────────────────────── */
select.form-control, input.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: #F9FAFB;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #111827;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dark select.form-control, .dark input.form-control {
  background-color: #1F2937;
  border-color: #374151;
  color: #F9FAFB;
}
select.form-control:focus, input.form-control:focus {
  border-color: var(--theme-500, #6366F1);
  box-shadow: 0 0 0 2px rgba(var(--theme-500-rgb, 99, 102, 241), 0.2);
}

textarea.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #F9FAFB;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #111827;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
  min-height: 90px;
}
.dark textarea.form-control {
  background-color: #1F2937;
  border-color: #374151;
  color: #F9FAFB;
}
textarea.form-control:focus {
  border-color: var(--theme-500, #6366F1);
  box-shadow: 0 0 0 3px rgba(var(--theme-500-rgb, 99, 102, 241), 0.1);
}

/* ── iPad / iOS PWA keyboard fix ─────────────────────────── */
@supports (-webkit-touch-callout: none) {
  input, textarea, select, [contenteditable] {
    font-size: 16px;
  }
}

/* ── PWA tab keyboard fix ────────────────────────────────── */
input, textarea, select, [contenteditable] {
  -webkit-user-select: text !important;
  user-select: text !important;
  touch-action: manipulation;
}

/* ── Nav loading overlay pointer-events fix ──────────────── */
#nav-loading-overlay {
  pointer-events: none;
}
#nav-loading-overlay.visible {
  pointer-events: all;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem !important; line-height: 2rem !important; }
  h2 { font-size: 1.25rem !important; line-height: 1.75rem !important; }
  .group-hover\:opacity-100 { opacity: 1 !important; }
}