/* src/static/css/styles.css */

/* ---------------- Tokens ---------------- */

:root,
[data-theme="light"] {
  color-scheme: light;

  --brand-green: #35cd35;
  --brand-green-dark: #2faf2f;
  --brand-green-soft: #e9f9e9;
  --brand-navy: #0f2744;
  --brand-orange: #ff7a00;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f5f7fb;

  --border: #e7e7e7;
  --border-strong: #cfcfcf;

  --text: #111111;
  --text-heading: #0f172a;
  --text-link: #0f172a;
  --muted: rgba(17, 17, 17, 0.75);

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 16px;

  --header-h: 74px;

  /* Sidebar sizing */
  --sidebar-w: 280px;
  --sidebar-w-collapsed: 78px;
  --sidebar-rail-w: 40px;

  /* Alert/message tints */
  --msg-success-bg: rgba(34, 197, 94, 0.10);
  --msg-success-border: rgba(34, 197, 94, 0.35);
  --msg-success-text: #14532d;
  --msg-error-bg: rgba(220, 38, 38, 0.10);
  --msg-error-border: rgba(220, 38, 38, 0.40);
  --msg-error-text: #7f1d1d;
  --msg-warning-bg: rgba(245, 158, 11, 0.12);
  --msg-warning-border: rgba(245, 158, 11, 0.45);
  --msg-warning-text: #7c2d12;
  --msg-info-bg: rgba(59, 130, 246, 0.10);
  --msg-info-border: rgba(59, 130, 246, 0.40);
  --msg-info-text: #1e3a8a;

  --wordmark-fin: #174776;
  --overlay-bg: rgba(0, 0, 0, 0.20);
  --sidebar-rail-bg: #f6f6f6;
}

[data-theme="dark"] {
  color-scheme: dark;

  --brand-green: #35cd35;
  --brand-green-dark: #2faf2f;
  --brand-navy: #0f2744;
  --brand-orange: #ff7a00;
  --brand-green-soft: rgba(53, 205, 53, 0.16);

  --bg: #0b1220;
  --surface: #141c2b;
  --surface-elevated: #1a2436;
  --surface-muted: #101827;

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);

  --text: #e8edf5;
  --text-heading: #f1f5f9;
  --text-link: #93c5fd;
  --muted: rgba(232, 237, 245, 0.72);

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  --msg-success-bg: rgba(34, 197, 94, 0.14);
  --msg-success-border: rgba(74, 222, 128, 0.35);
  --msg-success-text: #bbf7d0;
  --msg-error-bg: rgba(220, 38, 38, 0.14);
  --msg-error-border: rgba(248, 113, 113, 0.40);
  --msg-error-text: #fecaca;
  --msg-warning-bg: rgba(245, 158, 11, 0.14);
  --msg-warning-border: rgba(251, 191, 36, 0.45);
  --msg-warning-text: #fde68a;
  --msg-info-bg: rgba(59, 130, 246, 0.14);
  --msg-info-border: rgba(96, 165, 250, 0.40);
  --msg-info-text: #bfdbfe;

  --wordmark-fin: #7eb8e8;
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --sidebar-rail-bg: #101827;
}

/* Brand wordmarks (footers, sidebars) */
.wordmark-hanis{
  color: var(--text);
  font-weight: 800;
}
.wordmark-capital{
  color: var(--brand-green);
  font-weight: 800;
}
.wordmark-fin{
  /* Slightly brighter than --brand-navy so “FiN” reads as blue on white at small sizes */
  color: var(--wordmark-fin);
  font-weight: 800;
  letter-spacing: 0.03em;
}
.wordmark-hub{
  color: var(--brand-green);
  font-weight: 800;
  letter-spacing: 0.03em;
}
.wordmark-powered-lead{
  color: var(--muted);
  font-weight: 600;
}

/* ---------------- Base ---------------- */

*{ box-sizing: border-box; }

html,
body{
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body{
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a{ color: inherit; }

a.link{
  color: var(--text-link);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* ---------------- Layout shell ---------------- */

.app-header{
  width: 100%;
  height: var(--header-h);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  overflow: visible;
}

.header-right,
.profile-menu {
  overflow: visible;
}

.profile-circle--photo {
  background: transparent;
  padding: 0;
  display: block;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(53, 205, 53, 0.22);
}

.profile-circle__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  border-radius: 50%;
  clip-path: circle(50% at 50% 50%);
  pointer-events: none;
}

.app-header .profile-circle,
.app-header .profile-circle--photo {
  position: relative;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
}

.app-header .profile-circle__img {
  border-radius: 50%;
  clip-path: circle(50% at 50% 50%);
}

.app-header .profile-btn > .profile-circle {
  align-self: center;
}

.header-left{
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-right{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
  overflow: visible;
}

.app-shell{
  position: relative;
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* ---------------- Sidebar container ---------------- */

.sidebar{
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
  height: 100%;
  flex: 0 0 var(--sidebar-w);
}

/* Overlay for mobile drawer */
.sidebar-overlay{
  position: fixed;
  inset: 0;
  top: var(--header-h);
  z-index: 5900;
  background: var(--overlay-bg);
  display: none;
}

body.sidebar-open .sidebar-overlay{ display: block; }

/* ---------------- Main ---------------- */

.app-main{
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  background-color: var(--bg);
}

.messages-wrap{
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.app-content{
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  padding: 18px 18px 28px;
  background-color: var(--bg);
  color: var(--text);
}

/* Desktop: fixed shell, scroll inside main content */
@media (min-width: 981px){
  body{
    overflow: hidden;
  }

  .app-main{
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-left: var(--sidebar-rail-w);
  }

  .app-content{
    overflow-y: auto;
    overflow-x: hidden;
  }
}

/* Cards */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

/* ---------------- Header branding + buttons ---------------- */

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(53, 205, 53, .12);
  padding: 6px;
}

.brand-text{ display: grid; gap: 2px; }

.brand-name{
  font-weight: 900;
  font-size: 20px;
  color: var(--text-heading);
  line-height: 1.1;
}

.brand-sub{
  font-size: 14px;
  color: var(--muted);
  line-height: 1.1;
}

/* Icon buttons */
.icon-btn{
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 6px 14px rgba(0,0,0,.04);
}

.icon-btn:hover{ border-color: var(--border-strong); }

.mobile-nav-toggle{
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 6px 14px rgba(0,0,0,.04);
  color: var(--text-heading);
}

.mobile-nav-toggle:hover{ border-color: var(--border-strong); }

.mobile-nav-toggle__icon{
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
}

/* Optional shell buttons if used elsewhere */
.sidebar-toggle-fab{
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 12px;
  z-index: 6100;
  display: none !important;
}

.sidebar-collapse-fab{
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  width: var(--sidebar-rail-w);
  z-index: 6100;

  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;

  background: var(--sidebar-rail-bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);

  border-radius: 0;
  box-shadow: none;

  font-size: 18px;
  font-weight: 900;
  color: var(--text-heading);
}

/* Show or hide by breakpoint */
@media (max-width: 980px){
  .mobile-nav-toggle{
    display: inline-flex;
  }

  .sidebar-toggle-fab{ display: none !important; }
  .sidebar-collapse-fab{ display: none !important; }

  .sidebar{
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    z-index: 6000;
    transform: translateX(-110%);
    transition: transform .18s ease;
  }

  body.sidebar-open .sidebar{ transform: translateX(0); }

  html,
  body{
    height: auto;
    min-height: 100%;
  }

  body{
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell{
    height: auto;
    min-height: calc(100vh - var(--header-h));
    min-height: calc(100dvh - var(--header-h));
    overflow: visible;
  }

  .app-main{
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: calc(100vh - var(--header-h));
    min-height: calc(100dvh - var(--header-h));
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .app-content{
    flex: 1 1 auto;
    overflow: visible;
    padding: 14px 14px 22px;
  }
}

@media (min-width: 981px){
  .mobile-nav-toggle{
    display: none !important;
  }

  .sidebar-toggle-fab{ display: none !important; }
  .sidebar-collapse-fab{ display: none !important; }
}

/* ---------------- Profile dropdown ---------------- */

.profile-menu{
  position: relative;
  display: flex;
  align-items: center;
  overflow: visible;
}

.profile-btn{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  line-height: 1.2;
  max-width: 100%;
  overflow: visible;
}

.profile-circle{
  position: relative;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  background: rgba(53, 205, 53, .18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  overflow: hidden;
  flex-shrink: 0;
  line-height: 1;
  isolation: isolate;
}

.profile-meta{
  display: grid;
  gap: 2px;
  text-align: left;
}

.profile-name{
  font-weight: 800;
  font-size: 14px;
  color: var(--text-heading);
}

.profile-role{
  font-size: 12px;
  color: var(--muted);
}

.profile-caret{
  color: var(--muted);
  font-size: 12px;
}

.profile-dropdown{
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  z-index: 9999;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);

  padding: 8px;
  display: none;
}

.profile-menu.is-open .profile-dropdown,
.profile-menu[data-open="1"] .profile-dropdown{
  display: block;
}

.menu-item{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-heading);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.menu-item:hover{ background: var(--brand-green-soft); }

.menu-divider{
  height: 1px;
  background: var(--border);
  margin: 8px 6px;
}

.menu-item.danger{ color: #f87171; }
.menu-item.danger:hover{ background: rgba(185,28,28,.15); }

.menu-form{ margin: 0; }

/* ---------------- Messages ---------------- */

.messages-wrap{
  width: 100%;
  max-width: 100%;
  margin: 10px 0 0 0;
  padding: 0 18px;
}

.messages{ display: grid; gap: 8px; }

.message{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--text);
}

.message-success{
  border-color: var(--msg-success-border);
  background: var(--msg-success-bg);
  color: var(--msg-success-text);
}

.message-error{
  border-color: var(--msg-error-border);
  background: var(--msg-error-bg);
  color: var(--msg-error-text);
}

.message-warning{
  border-color: var(--msg-warning-border);
  background: var(--msg-warning-bg);
  color: var(--msg-warning-text);
}

.message-info{
  border-color: var(--msg-info-border);
  background: var(--msg-info-bg);
  color: var(--msg-info-text);
}

/* ---------------- Auth pages ---------------- */

.auth-page .app-header{ display: none; }

.auth-page .app-shell{
  margin-top: 0;
  height: 100vh;
}

body.auth-page .auth-content{ padding: 0; }

/* ---------------- Page helpers ---------------- */

.page-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title{
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.02em;
  color: var(--text-heading);
}

.page-actions{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn:disabled{
  cursor: not-allowed;
}

.btn:hover{ border-color: var(--border-strong); }

.btn-primary{
  background: var(--brand-green);
  border-color: rgba(47, 175, 47, 0.55);
  color: #ffffff;
}

.btn-primary:hover{
  background: var(--brand-green-dark);
  border-color: var(--brand-green-dark);
}

.btn-ghost{
  background: transparent;
  box-shadow: none;
}

.pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--brand-green-soft);
  font-weight: 800;
}

.muted{
  margin-top: 10px;
  color: var(--muted);
}

/* ---------------- Desktop collapsed helpers ---------------- */

body.sidebar-collapsed{ --sidebar-w: var(--sidebar-w-collapsed); }

body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .side-section,
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .side-caret,
body.sidebar-collapsed .side-sub,
body.sidebar-collapsed .side-children{
  display: none;
}

body.sidebar-collapsed .side-link,
body.sidebar-collapsed .side-sublink{
  justify-content: center;
  padding: 10px 8px;
}

body.sidebar-collapsed .sidebar-collapse-fab{
  left: var(--sidebar-w);
}

/* Smaller padding for main on narrow screens */
@media (max-width: 860px){
  .quick-links{ grid-template-columns: 1fr; }
}