/* ============================================================
   Coral Cove Funds — Main Stylesheet
   Brand: Garrington Private Credit Fund (blue/teal palette)
   ============================================================ */

:root {
    --blue-900: #0d2d4e;
    --blue-800: #1a4a7a;
    --blue-700: #1d6fa4;
    --blue-500: #2a9ad4;
    --blue-300: #7ec8e3;
    --blue-100: #e8f4fb;

    --teal-600: #0e8a8a;
    --teal-400: #1ab8b8;
    --teal-100: #e0f7f7;

    --green-600: #1a7a4a;
    --green-100: #e6f7ee;

    --red-600: #c0392b;
    --red-100: #fdecea;

    --gray-900: #1a1f2e;
    --gray-700: #3d4558;
    --gray-500: #6b7280;
    --gray-300: #d1d5db;
    --gray-100: #f3f4f6;
    --gray-50:  #f9fafb;
    --white:    #ffffff;

    --sidebar-width: 240px;
    --header-height: 64px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-50);
}

a { color: inherit; text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--blue-900);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0,0,0,.15);
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--white);
    padding: 3px;
    flex-shrink: 0;
}

.sidebar-app-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-300);
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: rgba(255,255,255,.65);
    font-weight: 500;
    transition: background .15s, color .15s;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: var(--white);
}

.nav-item.active {
    background: var(--blue-700);
    color: var(--white);
}

.nav-icon {
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: .8;
}

.sidebar-footer {
    padding: 12px 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--blue-700);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,.5);
    text-transform: capitalize;
}

.logout-btn {
    color: rgba(255,255,255,.4);
    font-size: 12px;
    padding: 6px;
    border-radius: 4px;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}

.logout-btn:hover {
    color: var(--white);
    background: rgba(255,255,255,.1);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 28px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-300);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 20px;
}

.form-card .card-body { padding: 24px; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-icon--blue   { background: var(--blue-100);  color: var(--blue-700); }
.stat-icon--teal   { background: var(--teal-100);  color: var(--teal-600); }
.stat-icon--green  { background: var(--green-100); color: var(--green-600); font-weight: 700; }
.stat-icon--purple { background: #ede9fe; color: #6d28d9; }

.stat-body { display: flex; flex-direction: column; }

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ── Dashboard Grid ──────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ── Quick Actions ───────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.quick-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, border-color .15s, color .15s;
    text-align: center;
}

.quick-action-item:hover {
    background: var(--blue-100);
    border-color: var(--blue-300);
    color: var(--blue-700);
}

.qa-icon {
    font-size: 22px;
}

/* ── Tables ──────────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-100);
    white-space: nowrap;
}

.table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: middle;
}

.table--hover tbody tr:hover td {
    background: var(--gray-50);
}

.table--perf th, .table--perf td {
    text-align: center;
    padding: 9px 8px;
    font-size: 12.5px;
}

.table--perf .fund-col,
.table--perf .fund-name-cell {
    text-align: left;
    min-width: 160px;
    font-weight: 600;
}

.table--perf .month-col { min-width: 58px; }
.table--perf .ytd-col   { min-width: 65px; font-weight: 600; }

.perf-table-wrap { overflow-x: auto; }

.perf-pos  { color: var(--green-600); background: var(--green-100); }
.perf-neg  { color: var(--red-600);   background: var(--red-100); }
.perf-empty { color: var(--gray-300); }

.text-green { color: var(--green-600); font-weight: 500; }
.text-red   { color: var(--red-600);   font-weight: 500; }
.text-center { text-align: center; }
.text-muted  { color: var(--gray-500); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge--green  { background: var(--green-100); color: var(--green-600); }
.badge--gray   { background: var(--gray-100);  color: var(--gray-500); }
.badge--blue   { background: var(--blue-100);  color: var(--blue-700); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--blue-700);
    color: var(--white);
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: var(--blue-800);
    box-shadow: 0 2px 6px rgba(29,111,164,.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-500);
}

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group--full {
    grid-column: 1 / -1;
}

.form-group--inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(42,154,212,.15);
}

.form-group textarea { resize: vertical; }

.required { color: var(--red-600); }

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 8px;
}

.filter-form { width: 100%; }

.filter-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

/* ── Detail List ─────────────────────────────────────────── */
.detail-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px 16px;
}

.detail-list dt {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-top: 2px;
}

.detail-list dd {
    font-size: 14px;
    color: var(--gray-900);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    align-items: start;
}

/* ── Links ───────────────────────────────────────────────── */
.link {
    color: var(--blue-700);
    text-decoration: none;
}

.link:hover { text-decoration: underline; }
.link--strong { font-weight: 600; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: .3;
}

.empty-state p { margin-bottom: 16px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--red-100);
    color: var(--red-600);
    border: 1px solid #f5c6c2;
}

/* ── Login Page ──────────────────────────────────────────── */
.login-body {
    background: var(--blue-900);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: var(--shadow-md);
}

.login-logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--gray-100);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }

.modal-body {
    padding: 22px 22px 18px;
}

.modal-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
    align-items: baseline;
}

.modal-dl dt {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    white-space: nowrap;
}

.modal-dl dd {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-footer {
    padding: 14px 22px 18px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-top: 1px solid var(--gray-100);
}

.no-perm-msg {
    font-size: 13px;
    color: var(--red-600);
    margin: 0;
}

/* ── Chips (ticker / class / currency badges) ────────────── */
.chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.chip--gold  { background: #fef3c7; color: #92400e; }
.chip--amber { background: #ffedd5; color: #9a3412; }
.chip--usd   { background: var(--blue-100);  color: var(--blue-700); }
.chip--cad   { background: #fee2e2; color: #991b1b; }

/* ── Date input with icon ────────────────────────────────── */
.date-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.date-input-wrap:focus-within {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(42,154,212,.15);
}

.date-icon {
    padding: 0 10px;
    color: var(--gray-500);
    font-size: 15px;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-300);
    height: 100%;
    display: flex;
    align-items: center;
}

.date-input-wrap input[type="date"] {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    flex: 1;
}

/* ── Create button ───────────────────────────────────────── */
.btn-create {
    min-width: 160px;
    justify-content: center;
    font-size: 15px;
    padding: 10px 24px;
}

/* ── 2FA ─────────────────────────────────────────────────── */
.totp-manual-code {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 4px;
}

.totp-secret-display {
    display: block;
    text-align: center;
    font-family: monospace;
    font-size: 15px;
    letter-spacing: 0.12em;
    color: var(--blue-800);
    word-break: break-all;
    margin-top: 4px;
}

/* ── Percentage input ────────────────────────────────────── */
.pct-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.pct-input-wrap:focus-within {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(42,154,212,.15);
}

.pct-input-wrap input {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    flex: 1;
    min-width: 0;
}

.pct-suffix {
    padding: 0 10px;
    background: var(--gray-50);
    color: var(--gray-500);
    font-size: 14px;
    border-left: 1px solid var(--gray-300);
    height: 100%;
    display: flex;
    align-items: center;
}

/* ── Field hint ─────────────────────────────────────────── */
.field-hint {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 3px;
}

/* ── Table foot ─────────────────────────────────────────── */
.table tfoot td {
    border-top: 2px solid var(--gray-300);
    padding-top: 10px;
    background: var(--gray-50);
}

/* ── Multiselect dropdown ────────────────────────────────── */
.ms-wrap {
    position: relative;
    min-width: 160px;
}

.ms-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px 7px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    background: var(--white);
    font-size: 13.5px;
    color: var(--gray-700);
    gap: 8px;
    user-select: none;
    transition: border-color .15s, box-shadow .15s;
}

.ms-toggle:hover,
.ms-wrap.open .ms-toggle {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(42,154,212,.12);
}

.ms-toggle-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ms-toggle-arrow {
    font-size: 9px;
    color: var(--gray-500);
    transition: transform .15s;
    flex-shrink: 0;
}

.ms-wrap.open .ms-toggle-arrow { transform: rotate(180deg); }

.ms-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    z-index: 300;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.ms-wrap.open .ms-dropdown { display: block; }

.ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    transition: background .1s;
}

.ms-option:hover { background: var(--blue-100); }

.ms-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--blue-700);
    flex-shrink: 0;
    cursor: pointer;
}

.ms-option-label { line-height: 1.3; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-app-name, .nav-item span:last-child, .user-details { display: none; }
    .sidebar-header { justify-content: center; padding: 16px 10px; }
    .main-content { margin-left: 60px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
