/* ==========================================================
   Cuentitas - Unified Stylesheet
   ========================================================== */

/* --- CSS Variables --- */
:root {
  --gradient: linear-gradient(135deg, #111827, #0f172a 35%, #2563eb);
  --shadow: 0 20px 60px rgba(0, 0, 0, .14);
  --shadow-soft: 0 10px 26px rgba(16, 24, 40, .07);
  --card-radius: 18px;
  --stroke: rgba(16, 24, 40, .10);
}

/* --- Base / Layout --- */
body {
  min-height: 100vh;
  background: var(--gradient);
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

.page-wrap {
  flex: 1 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 48px;
}

/* --- Cards --- */
.glass-card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
}

.card-app {
  border: 0;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
}
.card-app, .card-body, .list-item { min-width: 0; }

/* --- Typography helpers --- */
.muted { color: rgba(17, 24, 39, .55); }
.section-title { font-weight: 700; margin-bottom: .25rem; }

.name {
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.amount {
  font-weight: 900;
  letter-spacing: -.2px;
  font-size: 1.05rem;
  line-height: 1.1;
  white-space: nowrap;
}

/* --- Badges / Pills / Chips --- */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .32rem .6rem; border-radius: 999px;
  background: rgba(79, 70, 229, .12); color: #4338ca;
  font-weight: 700; font-size: .82rem;
}

.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .34rem .62rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700;
  background: #fff; border: 1px solid var(--stroke);
  white-space: nowrap;
}

.badge-soft {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .38rem .65rem; border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #e0e7ff; font-weight: 700; font-size: .85rem;
}

.pill-admin  { background: rgba(13, 110, 253, .10); color: #0b5ed7; border: 1px solid rgba(13, 110, 253, .18); }
.pill-member { background: rgba(108, 117, 125, .12); color: #495057; border: 1px solid rgba(108, 117, 125, .20); }
.pill-pos    { background: rgba(25, 135, 84, .12);  color: #146c43; border: 1px solid rgba(25, 135, 84, .20); }
.pill-neg    { background: rgba(220, 53, 69, .12);  color: #b02a37; border: 1px solid rgba(220, 53, 69, .20); }
.pill-zero   { background: rgba(13, 110, 253, .10); color: #0b5ed7; border: 1px solid rgba(13, 110, 253, .18); }

.pill-danger {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .32rem .6rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700;
  background: rgba(220, 53, 69, .12);
  color: #b02a37; border: 1px solid rgba(220, 53, 69, .2);
}

.pending-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  margin-left: .5rem; padding: .2rem .5rem; border-radius: 999px;
  background: rgba(239, 68, 68, .12); color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, .25);
  font-size: .75rem; font-weight: 700; white-space: nowrap;
}
.pending-badge svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
}

.pending-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  background: rgba(239, 68, 68, .12); color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, .25); white-space: nowrap;
}
.pending-pill svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
}

/* --- List items --- */
.list-item {
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: .85rem;
  max-width: 100%;
  overflow: hidden;
}

/* --- Avatar --- */
.avatar {
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--stroke);
  font-weight: 800; flex: 0 0 auto;
}

/* --- Auth pages (login, register) --- */
.auth-card {
  border: 0; border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow); max-width: 1080px; width: 100%;
}

.auth-hero {
  background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, .25), transparent 35%),
              radial-gradient(circle at 80% 10%, rgba(147, 197, 253, .28), transparent 40%),
              #0b1021;
  color: #e5e7eb;
}

.card-auth {
  max-width: 480px; width: 100%;
  border: 0; border-radius: 18px; box-shadow: var(--shadow);
}

.form-floating > label { color: #6b7280; }

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border: 0;
  box-shadow: 0 12px 28px rgba(79, 70, 229, .32);
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #4338ca); }

.btn-google {
  border: 1px solid rgba(15, 23, 42, .15);
  background: #fff; color: #111827; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .7rem 1rem;
}
.btn-google:hover { background: #f8fafc; color: #111827; }

.divider {
  display: flex; align-items: center; gap: .75rem;
  color: #9ca3af; font-size: .85rem;
}
.divider::before,
.divider::after {
  content: ""; flex: 1; height: 1px;
  background: rgba(15, 23, 42, .12);
}

/* --- App header (group_view, group_summary, payment_new) --- */
.app-header {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(16, 24, 40, .08);
}

.app-title { font-weight: 700; }
.fw-semibold { font-weight: 600 !important; }

/* --- FAB (floating action button) --- */
.fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 1040;
}
.fab .btn {
  width: 56px; height: 56px; border-radius: 18px;
  box-shadow: 0 18px 42px rgba(249, 115, 22, .38);
  font-size: 1.35rem;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f97316, #ef4444);
  border: 0; color: #fff;
}
.fab-menu {
  position: absolute; right: 0; bottom: 66px;
  display: none; width: 240px;
}
.fab-menu .card {
  border-radius: 16px; border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
}
.fab.open .fab-menu { display: block; }

/* --- Modals --- */
.modal-card {
  border: 0; border-radius: 18px;
  box-shadow: var(--shadow-soft); background: #fff;
  border: 1px solid var(--stroke);
}

.modal-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #b02a37; font-weight: 800; font-size: 1.25rem;
  border: 1px solid rgba(220, 53, 69, .25);
}

/* --- Home page --- */
.hero-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem; border-radius: 999px;
  background: #e5edff; color: #1d4ed8;
  font-weight: 700; font-size: .9rem;
}

.quick-card {
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  transition: transform .15s ease, box-shadow .15s ease;
  height: 100%;
}
.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
}

.stat-card {
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 18px; padding: 1rem;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
}
.stat-label {
  font-size: .82rem; color: rgba(15, 23, 42, .55);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.stat-value {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em;
}

.bar-row { display: flex; align-items: center; gap: .75rem; }
.bar-track {
  flex: 1; height: 8px;
  background: rgba(59, 130, 246, .12);
  border-radius: 999px; overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 999px;
}

.tag {
  font-size: .72rem; padding: .2rem .45rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(15, 23, 42, .04);
}

/* --- Groups page --- */
.groups-page .list-group-item {
  border: 1px solid rgba(15, 23, 42, .08) !important;
  border-radius: 12px !important;
  margin-bottom: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
}
.groups-page .list-group-item:hover {
  transform: translateY(-2px);
  transition: all .15s ease;
}

.more-archive,
.more-archived {
  width: 30px; height: 30px; border-radius: 10px;
  font-weight: 800; padding: 0;
}

.action-btn { position: relative; z-index: 2; pointer-events: auto; }
.groups-page .list-group-item .stretched-link { z-index: 1; }

.btn-eye {
  width: 36px; height: 36px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #4b5563;
  border-color: rgba(75, 85, 99, .35);
  background: rgba(75, 85, 99, .08);
}

.eye-svg { width: 20px; height: 20px; stroke: #4b5563; fill: none; stroke-width: 1.6; }
.eye-svg .pupil { fill: #4b5563; }
.eye-svg .slash { stroke: #4b5563; stroke-width: 1.8; stroke-linecap: round; opacity: 0; }
.eye-svg.closed .slash { opacity: 1; }

/* --- Group view: member styles --- */
.member-left { min-width: 0; }
.member-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px; font-weight: 600; color: #111827;
}
.member-item {
  flex-wrap: wrap; row-gap: .35rem; padding: .6rem .7rem;
}
.member-actions {
  margin-left: auto; flex: 0 0 auto;
  padding: .25rem .6rem; font-size: .75rem; border-radius: .6rem;
}
.member-role { font-size: .78rem; color: rgba(17, 24, 39, .55); }

/* --- Group summary --- */
.row-item {
  background: #fff; border: 1px solid var(--stroke);
  border-radius: 16px; padding: .9rem;
}
.row-main {
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}
.row-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.right { text-align: right; flex: 0 0 auto; }

details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
.details-box {
  margin-top: .6rem; padding-top: .6rem;
  border-top: 1px solid rgba(16, 24, 40, .08);
}

/* --- Personal pages --- */
canvas { max-height: 260px; }

/* --- Responsive --- */
@media (max-width: 576px) {
  .expense-row {
    flex-direction: column;
    align-items: flex-start !important;
    gap: .6rem;
  }
  .expense-row .text-end {
    text-align: left !important;
    width: 100%;
  }
  .expense-row .amount { font-size: 1rem; }
}

@media (max-width: 420px) {
  .name { max-width: 170px; }
  .amount { font-size: 1rem; }
  .chip { font-size: .78rem; padding: .32rem .55rem; }
}

/* --- Finance module --- */
.finance-breakdown .breakdown-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 0; border-bottom: 1px solid rgba(16, 24, 40, .06);
}
.finance-breakdown .breakdown-row:last-child { border-bottom: 0; }
.finance-breakdown .breakdown-total {
  font-weight: 800; font-size: 1.05rem;
  border-top: 2px solid rgba(16, 24, 40, .15);
  padding-top: .6rem; margin-top: .3rem;
}
.text-positive { color: #15803d; }
.text-negative { color: #b02a37; }
.projection-table th {
  font-size: .82rem; text-transform: uppercase;
  letter-spacing: .05em; color: rgba(15, 23, 42, .55); font-weight: 700;
}
.projection-table td { font-weight: 600; }
