/* ---------------------------------------------------
   GLOBAL THEME VARIABLES
   Change these to update your entire colour scheme
--------------------------------------------------- */
:root {
    --navy: #1f3c88;
    --light-blue: #e8f1fa;
    --terracotta: #d36b3d;
    --white: #ffffff;
    --grey: #f5f5f5;
    --mint: #d9f5d3;
    --olive: #a3b18a;
    --radius: 10px;
    --shadow: 0 2px 6px rgba(0,0,0,0.1);
    --max-width: 900px;
}


/* ---------------------------------------------------
   GLOBAL PAGE LAYOUT
--------------------------------------------------- */
html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--grey);
    color: var(--navy);
}

/* MAIN CONTAINER — MUST ALWAYS FILL HEIGHT */
.container {
    flex: 1; /* pushes footer to bottom */
    width: 90%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0;
    
}

/* FIX NESTED CONTAINERS */
.container .container {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* REMOVE LAST GAP ABOVE FOOTER */
.container > *:last-child,
.page-section:last-child {
    margin-bottom: 0 !important;
}

/* FOOTER */
.site-footer {
    margin: 0;
    padding: 15px 0;
    background: var(--mint);
    color: var(--navy);
    border-radius: 0;
    text-align: center;
    width: 100%;
    margin: 0 auto;
    
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    background: var(--terracotta);
    color: var(--white);
    padding: 8px 12px;
    border: none;
    cursor: pointer;
    border-radius:6px;
}

.dropdown-btn:hover {
    background:var(--navy);
    color:var(--white);
}

.dropdown-content {
    display: none;
    position: absolute;
    background: var(--white);
    color:var(--navy);
    min-width: 160px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.dropdown-content a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #333;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* ---------------------------------------------------
   MOBILE BEHAVIOUR
--------------------------------------------------- */
@media (max-width: 600px) {

    /* Full-width header, navbar, footer */
    .site-header,
    .navbar,
    .site-footer {
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        border-radius: 0;
    }

    /* IMPORTANT: container must STILL fill height */
    .container {
        flex: 1;
        width: 100%;
        max-width: 100%;
        padding: 0 10px;
    }
}

/* Section wrapper */
.page-section {
    background: var(--light-blue);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.page-section h2:hover {
        color: var(--terracotta);
    }

*,
*::before,
*::after {
    box-sizing: border-box;
}
/* ---------------------------------------------------
   HEADINGS
--------------------------------------------------- */
h1, h2, h3, h4 {
    color: var(--navy);
    margin-top: 0;
}

/* ---------------------------------------------------
   CARDS (SMALL + BIG)
--------------------------------------------------- */

.small-card {
    display: block;               /* ensures full-card click */
    text-decoration: none;        /* remove underline */
    color: inherit;               /* inherit card text colour */
    background: var(--light-blue);
    border: 2px solid var(--navy);
    border-radius: var(--radius);
    padding: 0.6rem;
    text-align: center;
    cursor: pointer;
    transition: 0.25s ease;
     box-shadow: 
        0 8px 18px rgba(0,0,0,0.12),
        0 3px 6px rgba(0,0,0,0.08);
}

.small-card:hover {
    background: var(--terracotta);
    color: var(--white);          /* ensures text turns white on hover */
    border-color: var(--navy);
    transform: translateY(-4px);
    box-shadow: 
        0 12px 24px rgba(0,0,0,0.16),
        0 4px 10px rgba(0,0,0,0.10);
}

.small-card h1,
.small-card h2,
.small-card h3 {
    margin: 0;
    color: inherit;   /* ensures headings follow card colour */
}


.big-card {
    background: var(--white);
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    gap: 0.5rem;
    margin: 0.8rem;
}


/* ---------------------------------------------------
   GRID LAYOUT (for dashboards, lists)
--------------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

/* ---------------------------------------------------
   BUTTONS
--------------------------------------------------- */

button,
.button-primary,
.button-secondary,
.button-danger {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    margin-top: 0.5rem;
}

.button-primary {
    background: var(--navy);
    color: var(--white);
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.25s ease;
    margin-right: 0.5rem;
}

.button-primary:hover {
    background: var(--terracotta);
    color:var(--white);
}

.button-secondary {
    background: var(--light-blue);
    color: var(--navy);
    padding: 0.7rem 1.2rem;
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    cursor: pointer;
    margin-right: 0.5rem;
}

.button-secondary:hover {
    background: var(--olive);
    border: none;
    color:var(--white);
}

.button-danger {
    background: #b00020;
    color: var(--white);
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    margin-right: 0.5rem;
}

.button-danger:hover {
    background: var(--navy);
}

/* ---------------------------------------------------
   FORMS (GLOBAL STYLING)
--------------------------------------------------- */
form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

form label {
    font-weight: bold;
    color: var(--navy);
}

form input,
form select,
form textarea {
    padding: 0.8rem;
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    background: var(--light-blue);
    font-size: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    resize: vertical; /* prevents sideways stretching */
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--terracotta);
    background: var(--white);
}

/* ---------------------------------------------------
   EXPANDABLE CARDS (for investments, loans, etc.)
--------------------------------------------------- */
.expand-card {
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
    background: var(--light-blue);
}

.expand-header {
    background: var(--navy);
    color: var(--white);
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
}

.expand-header:hover {
    background: var(--terracotta);
}

.expand-body {
    display: none;
    padding: 1rem;
    background: var(--white);
}

/* ---------------------------------------------------
   TABLES (for lists)
--------------------------------------------------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

table th {
    background: var(--navy);
    color: var(--white);
    padding: 0.8rem;
    text-align: left;
}

table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--light-blue);
}

table td,
table th {
    max-width:80px;
    overflow:hidden;
    text-overflow: ellipsis;

}

table td:hover {
    position:relative;
    z-index:10;
}

table tr:hover {
    background: var(--light-blue);
}

/* ---------------------------------------------------
   MOBILE RESPONSIVENESS
--------------------------------------------------- */
@media (max-width: 600px) {
    .container {
        width: 95%;
    }

    .big-card {
        padding: 1.2rem;
    }

    .button-primary,
    .button-secondary,
    .button-danger {
        width: 100%;
    }

    table th, table td {
        padding: 0.6rem;
    }
    
}


/* ---------------------------------------------------
   DASHBOARD GRID (for small cards)
--------------------------------------------------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.2rem;
    margin-top: 1.5rem;
}

/* Make small cards clickable blocks */
.small-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ---------------------------------------------------
   SMALL SCREEN OPTIMISATION
--------------------------------------------------- */

/* Very small screens (<400px): 2 columns */
@media (max-width: 400px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
}

/* Small screens (400px–480px): 3 columns */
@media (min-width: 400px) and (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }
}

/* Prevent overflow */
.dashboard-grid > * {
    min-width: 0;
}

/* ---------------------------------------------------
   CARD STYLING
--------------------------------------------------- */
.dashboard-grid .small-card {
    padding: 0.6rem;                     /* balanced padding */
    border-width: 1px;
    border-radius: var(--radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    background: var(--light-blue);
    text-align: center;
    transition: 0.25s ease;
}

/* Hover effect */
.dashboard-grid .small-card:hover {
    background: var(--terracotta);
    color: var(--white);
    border-color: var(--navy);
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* ---------------------------------------------------
   TYPOGRAPHY (no text smaller than 1rem)
--------------------------------------------------- */
.dashboard-grid .small-card h1 {
    font-size: 1.4rem;       /* primary metric */
    line-height: 1.25;
    margin: 0.2rem 0;
    font-weight: 600;
}

.dashboard-grid .small-card h2 {
    font-size: 1.1rem;         /* label */
    line-height: 1.25;
    margin: 0.15rem 0;
    font-weight: 500;
}



/* ---------------------------------------------------
   TOGGLE BUTTONS (for expandable cards)
--------------------------------------------------- */
.investment-toggle,
.toggle-button {
    width: 100%;
    background: var(--navy);
    color: var(--white);
    padding: 0.9rem 1rem;
    border: none;
    border-radius: var(--radius);
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.25s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Hover effect */
.investment-toggle:hover,
.toggle-button:hover {
    background: var(--terracotta);
}

/* Optional: add a chevron icon rotation */
.toggle-icon {
    transition: transform 0.25s ease;
}

.toggle-icon.open {
    transform: rotate(180deg);
}

.investment-details {
    
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--navy);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------------------------------------------------
   FORM PAGE LAYOUT
--------------------------------------------------- */
.form-page {
    width: 90%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 0;
}

.form-card {
    background: var(--white);
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-top: 1.5rem;
}

/* ---------------------------------------------------
   FORM ELEMENTS
--------------------------------------------------- */
form {
    display: flex;
    flex-direction: column;
    gap: 0;
    
}

form label {
    font-weight: bold;
    color: var(--navy);
    margin-bottom: 0.8rem;
}

form p {
    margin: 0 0 0.5rem 0;
    padding:0;
}

.form-card label {
    margin-bottom: 0.5rem;
}


form input,
form select,
form textarea {
    padding: 0.8rem;
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    background: var(--light-blue);
    font-size: 1rem;
    width: 100%;
    margin-bottom: 0;

}

.form-card input,
.form-card select,
.form-card textarea {
    margin-bottom: 0.5rem;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--terracotta);
    background: var(--white);
}

/* ---------------------------------------------------
   FORM BUTTONS
--------------------------------------------------- */
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* ---------------------------------------------------
   MOBILE RESPONSIVENESS
--------------------------------------------------- */
@media (max-width: 600px) {
    .form-card {
        padding: 1.2rem;
    }

    .form-actions {
        flex-wrap: wrap;        /* allow wrapping */
    }

    .form-actions button,
    .form-actions a {
        flex: 1 1 45%;          /* two per row */
    }
}

/* ---------------------------------------------------
   SMALL BUSINESS-CARD STYLE (for members, contacts, etc.)
--------------------------------------------------- */
.small-business-card {
    background: var(--light-blue);
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    line-height: 1.4rem;
    transition: 0.25s ease;
}

.small-business-card:hover {
    border-color: var(--terracotta);
    transform: translateY(-3px);
}

.small-business-card h3,
.small-business-card p {
    margin: 0.2rem 0;
}

.small-business-card span {
    display: block;
    text-align: center;
}

/* ---------------------------------------------------
   ACTION LINKS (Update / Remove / View)
--------------------------------------------------- */
a {
    text-decoration: none;
    color: inherit;
}

a:hover {
    color: var(--terracotta);
}

.action-link {
    color: var(--navy);
    font-weight: 500;
    text-decoration: none;
    margin-right: 1rem;
    transition: 0.25s ease;
}

.action-link:hover {
    color: var(--terracotta);
    text-decoration: underline;
}

/* Danger link (Remove/Delete) */
.action-link-danger {
    color: #b00020;
    font-weight: 600;
}

.action-link-danger:hover {
    color: var(--terracotta);
}

.page-section {
    width: 100%;
    overflow-x: auto;     /* allows horizontal scroll if absolutely needed */
    padding: 10px;
}

.page-section table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;  /* forces cells to shrink instead of overflow */
}

.page-section th,
.page-section td {
    padding: 8px 10px;
    border: 1px solid #ddd;
    word-wrap: break-word;   /* breaks long text */
    white-space: normal;     /* allows wrapping */
    font-size: 0.9rem;       /* slightly smaller for tight tables */
}

.page-section th {
    background:var(--navy);
    font-weight: 600;
}

.page-section p {
    padding: 0.75rem 1rem;
    background: var(--light-blue);
    border: 1px solid var(--navy);
    border-radius: var(--radius);
    margin: 0.75rem 0;
}

.small-business-card p {
    padding: 0.75rem 1rem;
    background: var(--light-blue);
    border: 2px solid var(--navy);
    border-radius: var(--radius);
    margin: 0.75rem 0;
}


button,
.button,
.btn {
    display: inline-block;      /* prevents full-width expansion */
    width: auto;                /* ensures natural width */
    max-width: max-content;     /* shrink to fit text */
    white-space: nowrap;        /* keeps text on one line */
    margin-bottom: 0.5rem;
}


#portfolioChart {
    width: 100% !important;
    height: auto !important;
}

.chart-container {
    max-width: 350px;      /* mobile size */
    margin: 0 auto 2rem;
    padding: 1rem 0;
    height:auto;
}



.charts-wrapper {
    display: flex;
    flex-direction: column;   /* mobile default */
    gap: 20px;
}

.charts-wrapper .chart-container {
    width: 90%;   /* mobile */
    max-width: none;
}

/*Chart formatting separate*/
.chart-legend {
    display:grid;
    grid-template-columns: repeat(4,1fr);
    gap:2px 24px;
    list-style: none;
    padding: 0;
    margin-top: 12px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size:0.8rem;
    justify-content: center;
}

.chart-legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 8px;
}

/* Larger screens: place charts side by side */
@media (min-width: 600px) {
    .charts-wrapper {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    .chart-container {
        flex: 1;
        max-width: none;      /* override the 350px */
        width: 48%;           /* allow side-by-side */
    }
}

/* FULL-WIDTH FILTER BAR */
.filter-container {
  width: 100%;
  background: #ffffff;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* TWO-COLUMN GRID FOR FIELDS */
.filter-container form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);   /* 2 per row */
  gap: 1rem 1.5rem;
  align-items: end;
}

/* BUTTON ROW (side by side) */
.filter-buttons {
  flex-direction: row;
}

/* INPUTS */
.filter-container input,
.filter-container select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

/* MOBILE STACK */
@media (max-width: 600px) {
  .filter-container form {
    grid-template-columns: 1fr;
  }

  .filter-buttons {
    flex-direction: column;
  }
}
/*----------Upgrading the nav-bar---------*/

/* Make header blend with page */
.site-header {
    background: var(--mint);
    color: var(--navy);
    text-align: center;
    padding: 10px 0;
}

.site-header,
.site-header * {
    color: var(--navy);
}

/* NAVBAR */
.navbar {
    background: var(--navy);
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    max-height: 50px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    position: sticky;
    top: 60px;
    z-index: 1000;
}
.nav-link {
    color: var(--white);
    text-decoration: none;
    margin-right: 12px;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--terracotta);
}

/* SIDEBAR BELOW NAVBAR */
.sidebar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    background: none; /* ⭐ No background */
    padding: 0;
}

/* TERRACOTTA BUTTONS */
.sidebar-btn {
    background: var(--terracotta);
    color: var(--white);
    padding: 6px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 1rem;
    white-space: nowrap;
}

.sidebar-btn:hover {
    background: var(--navy);
    color: var(--terracotta)
}

/* CONTENT */
.layout-content {
    padding: 10px 0;
}

/*alerts*/
.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.alert-success {
    background: #e6ffed;
    border: 1px solid #8fd19e;
    color: #276738;
}

.alert-error {
    background: #ffecec;
    border: 1px solid #e09a9a;
    color: #8a1f1f;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-buttons a {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    white-space: nowrap;
}

/* On small screens, stack or wrap nicely */
@media (max-width: 600px) {
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
}

/* auto-detect dark-mode */
@media(prefers-color-scheme: dark) {

    :root {
        --navy: #0d1b2a;
        --light-blue: #212d40;
        --terracotta: #e07a5f;
        --white: #e0e0e0;
        --grey: #2e2e2e;
        --mint: #63a57d;
        --olive: #5c6b50;
        --shadow: 0 2px 6px rgba(0,0,0,0.4);
    }

    body {
        background: var(--navy);
        color: var(--white);  
    }

    .site-header,
    .site-footer {
        background: var(--olive);
        color: var(--white);
    }

    .container {
        background: var(--navy);
        color: var(--white);  
    }

    .container h1, 
    .container h2, 
    .container h3,
    .container h4 {
        color: var(--white);
    }

    .page-section {
        background:var(--navy);
        color: var(--white);
    }

    .page-section h2:hover {
        color: var(--terracotta);
    }

    .small-business-card {
        background: var(--light-blue);
        color: var(--white);
    }

    .page-section .small-business-card {
        background: var(--navy);
    }


    .small-business-card h1, 
    .small-business-card h2,
    .small-business-card h3 {
        color: var(--white);
    }

    .card,
    .panel,
    .content-box {
        background: var(--light-blue);
        color: var(--white);
        border-color: var(--grey);
        box-shadow: var(--shadow);
    }

    .form-card {
        background: var(--navy);
        border: 1px solid var(--light-blue);
    }

    form label {
        color: var(--white);
    }
    
    input,
    select,
    textarea {
        background: var(--grey);
        color: var(--white);
        border: 1px solid var(--mint);
    }

    form input:focus,
    form select:focus,
    form textarea:focus {
        outline: none;
        border-color: var(--terracotta);
        background: var(--navy);
    }


    .button-primary {
        background:var(--mint);
        color: var(--navy);
    }

    .button-primary:hover {
        background:var(--terracotta);
        color: var(--navy);
    }

    .button-secondary {
        background:var(--olive);
        color: var(--white);
        border: none;
    }

    .button-secondary:hover {
        background:var(--terracotta);
        color: var(--navy);
    }

    .sidebar-btn {
        background: var(--terracotta);
        color: var(--navy);
    }

    .sidebar-btn:hover {
    background: var(--light-blue);
    color: var(--terracotta)
    }

    table {
        background: var(--light-blue);
        color: var(--white);
        border: 3px solid var(--white);
        border-collapse: separate;
        border-spacing: 0;
    }

    table tr:nth-child(even) {
        background: var(--grey);
    }

    table tr:nth-child(odd) {
        background: var(--light-blue);
    }

    table tr:hover {
        background: var(--olive);
    }


    .action-link {
        color: var(--mint);
        font-weight: 500;
    }

    .action-link-danger {
        color:var(--terracotta);
        font-weight: 500;
    }

    .action-link:hover {
        color: var(--terracotta);
        text-decoration: underline;
    }

     .action-link-danger:hover {
        color: var(--mint);
        text-decoration: underline;
    }

    .big-card {
        background: var(--navy);
    }

    .small-business-card p {
        background: var(--navy);
    
    }

    .dropdown-content{
        background: var(--navy);
        color:var(--white);
    }

    .dropdown-content a{
        color:var(--white);
    }

    .dropdown-content a:hover{
        color:var(--terracotta);

    }

}
