/* ===========================================================
   dashboard.css — Dashboard styles for Michi Managers
   Extends the existing design tokens from style.css
   =========================================================== */

/* ── Login page enhancements ────────────────────────── */
.login-wrap--wide { max-width: 500px; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-hint {
  font-size: .78rem;
  color: var(--ink-soft);
  margin-top: .2rem;
}

.form-alert {
  padding: .75rem 1rem;
  font-size: .88rem;
  border: 1px solid #c0392b;
  background: #fdf0ef;
  color: #c0392b;
  line-height: 1.4;
}

.form-alert--success {
  border-color: var(--forest);
  background: #eef6f0;
  color: var(--forest);
}

/* ── Dashboard layout ───────────────────────────────── */
.dash-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 32px);
}

.dash-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 34px;
  padding: 0;
  margin-right: auto;
  background: transparent;
  border: 1px solid rgba(246,243,236,.28);
  cursor: pointer;
}

.dash-hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--gold-light);
  transition: transform .2s, opacity .2s;
}

.dash-hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.dash-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.dash-hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.dash-overlay {
  display: none;
}

.dash-drawer-close {
  display: none;
}

body.dash-layout-page .topbar {
  position: relative;
  z-index: 240;
}

.dash-split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.dash-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sidebar */
.dash-sidebar {
  background: var(--forest-dark);
  color: var(--cream);
  padding: 1.6rem 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}

.dash-sidebar-user {
  padding: 0 1.4rem 1.4rem;
  border-bottom: 1px solid rgba(246,243,236,.12);
  margin-bottom: .8rem;
}

.dash-sidebar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--forest-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .6rem;
}

.dash-sidebar-name {
  font-weight: 600;
  font-size: .95rem;
  color: var(--white);
}

.dash-sidebar-role {
  font-size: .78rem;
  color: rgba(246,243,236,.6);
  margin-top: .15rem;
}

.dash-nav { flex: 1; }

.dash-nav-link {
  display: flex;
  align-items: center;
  padding: .7rem 1.4rem;
  font-size: .9rem;
  color: rgba(246,243,236,.7);
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}

.dash-nav-link:hover {
  background: rgba(246,243,236,.06);
  color: var(--white);
}

.dash-nav-link.is-active {
  background: rgba(246,243,236,.08);
  color: var(--gold-light);
  border-left-color: var(--gold);
}

.dash-nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: .7;
}

.dash-nav-link.is-active svg { opacity: 1; }

.dash-nav-divider {
  border: none;
  border-top: 1px solid rgba(246,243,236,.1);
  margin: .8rem 1.4rem;
}

.dash-sidebar-footer {
  padding: .8rem 1.4rem 0;
  border-top: 1px solid rgba(246,243,236,.12);
}

.dash-logout-btn {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: rgba(246,243,236,.6);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  padding: .5rem 0;
  transition: color .15s;
}

.dash-logout-btn:hover { color: var(--gold-light); }

/* Main content */
.dash-main {
  background: var(--cream);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  overflow-y: auto;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dash-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  color: var(--forest);
  font-weight: 500;
}

.dash-breadcrumb {
  font-size: .82rem;
  color: var(--ink-soft);
}

.dash-breadcrumb a {
  color: var(--gold);
  font-weight: 600;
}

/* ── Stat cards ─────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: box-shadow .2s;
}

.stat-card:hover {
  box-shadow: 0 8px 24px rgba(16,38,29,.08);
}

.stat-card-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--forest);
  font-weight: 500;
}

.stat-card-sub {
  font-size: .78rem;
  color: var(--gold);
  font-weight: 600;
}

/* ── Dashboard panels (cards) ───────────────────────── */
.dash-panel {
  background: var(--white);
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.dash-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: .6rem;
}

.dash-panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--forest);
  font-weight: 500;
}

.dash-panel-body { padding: 1.2rem 1.5rem; }

.dash-panel-body--flush { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Data tables ────────────────────────────────────── */
.dash-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: .88rem;
}

.dash-table th {
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  padding: .85rem 1.2rem;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

.dash-table td {
  padding: .85rem 1.2rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.dash-table tr:last-child td { border-bottom: none; }

.dash-table tr:hover td { background: var(--cream); }

.dash-table .text-right { text-align: right; }
.dash-table .text-center { text-align: center; }

/* ── Badges / pills ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge--active   { background: #e8f5e9; color: #2e7d32; }
.badge--suspended{ background: #fff3e0; color: #e65100; }
.badge--inactive { background: #eceff1; color: #546e7a; }
.badge--admin    { background: #e8eaf6; color: #283593; }
.badge--user     { background: #f3e5f5; color: #6a1b9a; }
.badge--deposit  { background: #e8f5e9; color: #2e7d32; }
.badge--withdrawal { background: #ffebee; color: #c62828; }
.badge--transfer { background: #e3f2fd; color: #1565c0; }
.badge--dividend { background: #fff8e1; color: #f57f17; }
.badge--fee      { background: #fce4ec; color: #ad1457; }

/* ── Account cards ──────────────────────────────────── */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

.account-card {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 1.4rem 1.5rem;
  transition: box-shadow .2s, border-color .2s;
  cursor: pointer;
}

.account-card:hover {
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(16,38,29,.08);
}

.account-card-type {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gold);
  margin-bottom: .4rem;
}

.account-card-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--forest);
  font-weight: 500;
}

.account-card-balance {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--forest);
  margin-top: .6rem;
}

.account-card-label {
  font-size: .78rem;
  color: var(--ink-soft);
  margin-top: .15rem;
}

/* ── Buttons ────────────────────────────────────────── */
.btn-sm {
  font-size: .82rem;
  padding: .45rem .9rem;
}

.btn-danger {
  background: #c0392b;
  color: var(--white);
  border: 1px solid #c0392b;
}
.btn-danger:hover { background: #a93226; }

.btn-ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--forest); color: var(--forest); }

.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover { background: var(--gold-light); }

/* ── Forms inside panels ────────────────────────────── */
.dash-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

.dash-form-grid--full {
  grid-column: 1 / -1;
}

/* ── Activity list ──────────────────────────────────── */
.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
  margin-top: .45rem;
}

.activity-dot--login    { background: #2e7d32; }
.activity-dot--logout   { background: #78909c; }
.activity-dot--register { background: #1565c0; }
.activity-dot--error    { background: #c62828; }

.activity-content { flex: 1; min-width: 0; }

.activity-action {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}

.activity-details {
  font-size: .82rem;
  color: var(--ink-soft);
  margin-top: .15rem;
}

.activity-time {
  font-size: .75rem;
  color: var(--ink-soft);
  white-space: nowrap;
  margin-top: .1rem;
}

/* ── Notifications ──────────────────────────────────── */
.notif-item {
  display: flex;
  gap: .8rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
  cursor: pointer;
  transition: background .15s;
}

.notif-item:hover { background: var(--cream); }
.notif-item.is-unread { background: #faf8f3; }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
  margin-top: .45rem;
}

.notif-dot--read { background: var(--line); }

.notif-title {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}

.notif-msg {
  font-size: .82rem;
  color: var(--ink-soft);
  margin-top: .15rem;
  line-height: 1.5;
}

.notif-time {
  font-size: .75rem;
  color: var(--ink-soft);
  margin-top: .3rem;
}

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,38,29,.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--white);
  border: 1px solid var(--line);
  width: min(520px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(16,38,29,.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--forest);
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .8rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
}

/* ── Loading / empty states ─────────────────────────── */
.dash-loading {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--ink-soft);
  font-size: .92rem;
}

.dash-empty {
  text-align: center;
  padding: 2.5rem 2rem;
  color: var(--ink-soft);
  font-size: .92rem;
}

.dash-empty-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
  opacity: .4;
}

/* ── Spinner ────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 980px) {
  .dash-hamburger { display: flex; }

  .dash-layout {
    grid-template-columns: 1fr;
  }

  .dash-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 38, 29, .5);
    z-index: 220;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }

  .dash-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 230;
    transform: translateX(-100%);
    transition: transform .22s ease;
    padding-top: 3.2rem;
    box-shadow: none;
  }

  .dash-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(16, 38, 29, .28);
  }

  .dash-drawer-close {
    display: flex;
    position: absolute;
    top: .7rem;
    right: .7rem;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(246,243,236,.8);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
  }

  .dash-sidebar-user,
  .dash-sidebar-footer { display: block; }

  .dash-form-grid,
  .dash-split-2,
  .dash-stat-row {
    grid-template-columns: 1fr;
  }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  body.dash-drawer-open { overflow: hidden; }
}

@media (max-width: 560px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }

  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-main {
    padding: 1rem .9rem 2rem;
  }

  .dash-panel-header,
  .dash-panel-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .dash-table {
    font-size: .8rem;
  }

  .dash-table th,
  .dash-table td {
    padding: .6rem .7rem;
  }

  .modal-overlay { padding: 1rem; }

  .activity-item {
    flex-wrap: wrap;
  }

  .activity-time {
    width: 100%;
    margin-left: 1.5rem;
  }
}

/* ── Mobile Table Cards ─────────────────────────────── */
@media (max-width: 768px) {
  /* Hide table headers on mobile */
  .dash-table thead {
    display: none;
  }

  /* Remove min-width constraint */
  .dash-table {
    min-width: 0;
  }

  /* Convert table rows to cards */
  .dash-table tbody {
    display: block;
  }

  .dash-table tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--line);
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 4px;
  }

  .dash-table tr:hover {
    background: var(--white);
  }

  .dash-table tr:hover td {
    background: transparent;
  }

  .dash-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: .5rem 0;
    border-bottom: 1px solid var(--line);
    gap: 1rem;
  }

  .dash-table td:last-child {
    border-bottom: none;
  }

  /* Add labels before each cell using data attributes */
  .dash-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    flex-shrink: 0;
    min-width: 100px;
  }

  /* Special handling for text alignment classes on mobile */
  .dash-table .text-right,
  .dash-table .text-center {
    text-align: left;
    justify-content: space-between;
  }

  /* Action buttons - make them full width and stack */
  .dash-table td:has(button),
  .dash-table td:has(.btn) {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }

  .dash-table td:has(button)::before,
  .dash-table td:has(.btn)::before {
    margin-bottom: .3rem;
  }

  .dash-table td button,
  .dash-table td .btn {
    width: 100%;
    justify-content: center;
  }

  /* For cells with multiple buttons */
  .dash-table td > button + button,
  .dash-table td > .btn + .btn {
    margin-top: .4rem;
  }

  /* Handle inline button groups */
  .dash-table td[style*="white-space:nowrap"] {
    flex-direction: column;
    white-space: normal !important;
  }

  .dash-table td[style*="white-space:nowrap"] button {
    margin: .2rem 0 !important;
  }

  /* Empty and loading states */
  .dash-table td.dash-empty,
  .dash-table td.dash-loading {
    display: block;
    text-align: center;
  }

  .dash-table td.dash-empty::before,
  .dash-table td.dash-loading::before {
    display: none;
  }

  /* Badge adjustments */
  .dash-table td .badge {
    display: inline-block;
  }

  /* Flush panel body adjustments for mobile cards */
  .dash-panel-body--flush {
    padding: 1rem;
    overflow-x: visible;
  }

  /* Adjust panel borders for cards */
  .dash-panel-body--flush .dash-table tr:last-child {
    margin-bottom: 0;
  }

  /* User/Account complex cells with multiple elements */
  .dash-table td:has(strong) {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-table td strong,
  .dash-table td span[style] {
    display: block;
    margin-top: .2rem;
  }
}

/* ── Extra Small Screens ────────────────────────────── */
@media (max-width: 420px) {
  .dash-table td::before {
    min-width: 80px;
    font-size: .72rem;
  }

  .dash-table td {
    font-size: .85rem;
  }

  .dash-table tr {
    padding: .8rem;
  }

  .btn-sm {
    font-size: .78rem;
    padding: .4rem .7rem;
  }
}
