/* Bound Investment - Admin Theme */
:root {
    --bi-navy: #0B1F3A;
    --bi-navy-dark: #071528;
    --bi-teal: #0D9488;
    --bi-teal-dark: #0F766E;
    --bi-bg: #F3F5F8;
    --bi-white: #FFFFFF;
    --bi-border: #E2E8F0;
    --bi-text: #1E293B;
    --bi-muted: #64748B;
    --bi-danger: #DC2626;
    --bi-success: #16A34A;
    --bi-warning: #D97706;
    --bi-info: #2563EB;
    --sidebar-width: 260px;
    --header-height: 64px;
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--bi-text);
    background: var(--bi-bg);
}

a {
    text-decoration: none;
    color: var(--bi-teal);
}

a:hover {
    color: var(--bi-teal-dark);
}

/* Auth Layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(145deg, #0B1F3A 0%, #0D3B4C 45%, #0D9488 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bi-white);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 16px 40px rgba(11, 31, 58, 0.25);
}

.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}

.auth-brand h1 {
    margin: 0 0 6px;
    font-size: 24px;
    color: var(--bi-navy);
}

.auth-brand p {
    margin: 0;
    color: var(--bi-muted);
    font-size: 13px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border: 0;
}

.auth-tabs .nav-link {
    border: 1px solid var(--bi-border);
    border-radius: 8px;
    color: var(--bi-muted);
    background: #F8FAFC;
    font-weight: 600;
    padding: 10px 12px;
}

.auth-tabs .nav-link:hover {
    color: var(--bi-navy);
    background: #EEF2F7;
}

.auth-tabs .nav-link.active {
    color: #fff;
    background: var(--bi-navy);
    border-color: var(--bi-navy);
}

/* Admin Shell */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bi-navy);
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    gap: 10px;
}

.sidebar-brand span,
.sidebar-brand-text {
    color: #FFFFFF;
}

.sidebar-brand-text span {
    color: var(--bi-teal);
}

.sidebar-logo {
    max-height: 36px;
    max-width: 180px;
    width: auto;
    object-fit: contain;
}

.auth-logo {
    max-height: 56px;
    max-width: 220px;
    margin: 0 auto 10px;
    display: block;
    object-fit: contain;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 12px 0 24px;
    flex: 1;
}

.sidebar-group {
    margin-bottom: 2px;
}

.sidebar-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: #94A3B8;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    cursor: pointer;
}

.sidebar-group-toggle:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-group-toggle .group-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sidebar-group-toggle .group-chevron {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.sidebar-group.is-open .group-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0 0 6px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 28px;
    color: #94A3B8;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-menu li a i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(13, 148, 136, 0.12);
    color: #FFFFFF;
    border-left-color: var(--bi-teal);
}

.sidebar-section-label {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748B;
}

.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-header {
    height: var(--header-height);
    background: var(--bi-white);
    border-bottom: 1px solid var(--bi-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

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

.sidebar-toggle {
    display: none;
    border: 1px solid var(--bi-border);
    background: var(--bi-white);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--bi-navy);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-name {
    font-weight: 600;
    color: var(--bi-navy);
    font-size: 13px;
}

.btn-logout {
    border: 1px solid var(--bi-border);
    background: var(--bi-white);
    color: var(--bi-danger);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.btn-logout:hover {
    background: #FEF2F2;
}

.admin-content {
    padding: 24px;
    flex: 1;
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--bi-muted);
    font-size: 13px;
    flex-wrap: wrap;
}

.page-breadcrumb a {
    color: var(--bi-muted);
}

.page-breadcrumb .current {
    color: var(--bi-navy);
    font-weight: 600;
}

/* Cards */
.card-panel {
    background: var(--bi-white);
    border: 1px solid var(--bi-border);
    border-radius: 10px;
    margin-bottom: 20px;
}

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

.card-panel-header h2,
.card-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--bi-navy);
}

.card-panel-body {
    padding: 20px;
}

/* Stats */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1 1 200px;
    background: var(--bi-white);
    border: 1px solid var(--bi-border);
    border-radius: 10px;
    padding: 18px 20px;
    min-width: 180px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--bi-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--bi-navy);
}

.stat-card.accent {
    border-top: 3px solid var(--bi-teal);
}

/* Forms */
.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--bi-navy);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--bi-border);
    font-size: 14px;
    padding: 8px 12px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bi-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.invalid-feedback,
.error {
    color: var(--bi-danger);
    font-size: 12px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.filter-form .form-group {
    margin: 0;
    min-width: 160px;
}

.filter-form .form-group.grow {
    flex: 1 1 200px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
    font-size: 13px;
}

.table thead th {
    background: #F8FAFC;
    color: var(--bi-navy);
    font-weight: 600;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

/* Badges */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active,
.badge-verified,
.badge-approved,
.badge-processed,
.badge-credited,
.badge-resolved,
.badge-sent {
    background: #DCFCE7;
    color: #166534;
}

.badge-pending,
.badge-submitted,
.badge-open,
.badge-draft {
    background: #FEF3C7;
    color: #92400E;
}

.badge-inactive,
.badge-blocked,
.badge-rejected,
.badge-cancelled,
.badge-closed,
.badge-failed {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-in_progress,
.badge-approved,
.badge-matured {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-withdrawn,
.badge-premature_closed {
    background: #E2E8F0;
    color: #334155;
}

/* Buttons */
.btn-primary {
    background: var(--bi-teal);
    border-color: var(--bi-teal);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--bi-teal-dark);
    border-color: var(--bi-teal-dark);
}

.btn-outline-primary {
    color: var(--bi-teal);
    border-color: var(--bi-teal);
}

.btn-outline-primary:hover {
    background: var(--bi-teal);
    border-color: var(--bi-teal);
}

.btn-sm {
    font-size: 12px;
}

.action-dropdown .dropdown-item {
    font-size: 13px;
}

/* Action icon buttons */
.action-icons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.action-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--bi-border);
    background: #FFFFFF;
    color: var(--bi-navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    line-height: 1;
}

.action-icon-btn:hover {
    background: #F1F5F9;
    color: var(--bi-teal);
    border-color: var(--bi-teal);
}

.action-icon-btn.action-delete {
    color: var(--bi-danger);
}

.action-icon-btn.action-delete:hover {
    background: #FEF2F2;
    border-color: #FECACA;
    color: var(--bi-danger);
}

.action-icon-btn.action-view:hover,
.action-icon-btn.action-review:hover {
    color: var(--bi-info);
    border-color: #BFDBFE;
    background: #EFF6FF;
}

.action-icon-btn.action-restore:hover {
    color: var(--bi-success);
    border-color: #BBF7D0;
    background: #F0FDF4;
}

/* Status switch */
.status-switch-wrap {
    display: inline-flex;
    align-items: center;
}

.status-switch .form-check-input {
    width: 2.4em;
    height: 1.25em;
    cursor: pointer;
    background-color: #CBD5E1;
    border-color: #CBD5E1;
}

.status-switch .form-check-input:checked {
    background-color: var(--bi-teal);
    border-color: var(--bi-teal);
}

.status-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.status-switch-wrap.is-disabled {
    opacity: 0.55;
}

/* Settings page */
.settings-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

.settings-side-nav {
    display: flex;
    flex-direction: column;
}

.settings-side-nav a {
    padding: 12px 16px;
    color: var(--bi-muted);
    border-left: 3px solid transparent;
    font-weight: 600;
    font-size: 13px;
}

.settings-side-nav a:hover,
.settings-side-nav a.active {
    color: var(--bi-navy);
    background: #F8FAFC;
    border-left-color: var(--bi-teal);
}

.brand-upload-box {
    height: 110px;
    border: 1px dashed var(--bi-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F8FAFC;
    overflow: hidden;
    padding: 10px;
}

.brand-upload-dark {
    background: var(--bi-navy);
}

.brand-upload-favicon {
    width: 110px;
}

.brand-preview {
    max-width: 100%;
    max-height: 90px;
    object-fit: contain;
}

.favicon-preview {
    max-height: 48px;
    max-width: 48px;
}

.brand-placeholder {
    color: var(--bi-muted);
    font-size: 12px;
}

.color-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-row .form-control-color {
    width: 46px;
    height: 38px;
    padding: 4px;
}

.theme-preview-swatch {
    display: flex;
    height: 42px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--bi-border);
}

.theme-preview-swatch span {
    flex: 1;
}

@media (max-width: 991px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        position: static;
    }

    .settings-side-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Permission groups */
.permission-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.permission-group {
    flex: 1 1 220px;
    border: 1px solid var(--bi-border);
    border-radius: 8px;
    padding: 12px 14px;
    background: #F8FAFC;
}

.permission-group h5 {
    font-size: 13px;
    margin: 0 0 10px;
    color: var(--bi-navy);
    text-transform: capitalize;
}

/* Ticket thread */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-reply {
    border: 1px solid var(--bi-border);
    border-radius: 8px;
    padding: 14px 16px;
    background: #F8FAFC;
}

.ticket-reply.internal {
    background: #FFF7ED;
    border-color: #FED7AA;
}

.ticket-reply .meta {
    font-size: 12px;
    color: var(--bi-muted);
    margin-bottom: 6px;
}

/* Detail grid */
.detail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.detail-item {
    flex: 1 1 220px;
}

.detail-item .label {
    font-size: 12px;
    color: var(--bi-muted);
    margin-bottom: 4px;
}

.detail-item .value {
    font-weight: 600;
    color: var(--bi-navy);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--bi-muted);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 31, 58, 0.45);
    z-index: 1035;
}

.admin-shell.sidebar-open .sidebar-overlay {
    display: block;
}

/* Responsive */
@media (max-width: 991px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

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

    .admin-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .admin-content {
        padding: 16px;
    }
}

@media (max-width: 575px) {
    .auth-card {
        padding: 28px 20px;
    }

    .stat-card .stat-value {
        font-size: 18px;
    }

    .card-panel-body {
        padding: 14px;
    }
}

/* Print-friendly report tables */
@media print {
    .admin-sidebar,
    .admin-header,
    .filter-form,
    .no-print {
        display: none !important;
    }

    .admin-main {
        margin-left: 0;
    }
}
