/* ===========================
   ACIcrm — Modern Theme
   Dark navy + green, polished.
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --aci-primary: #0f172a;
    --aci-primary-light: #1e293b;
    --aci-accent: #22c55e;
    --aci-accent-hover: #16a34a;
    --aci-accent-glow: rgba(34, 197, 94, 0.15);
    --aci-sidebar: #0f172a;
    --aci-sidebar-hover: rgba(255, 255, 255, 0.06);
    --aci-surface: #ffffff;
    --aci-surface-raised: #ffffff;
    --aci-bg: #f1f5f9;
    --aci-border: #e2e8f0;
    --aci-border-light: #f1f5f9;
    --aci-text: #0f172a;
    --aci-text-secondary: #475569;
    --aci-muted: #94a3b8;
    --aci-success: #10b981;
    --aci-danger: #ef4444;
    --aci-info: #3b82f6;
    --aci-warning: #f59e0b;
    --aci-shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
    --aci-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --aci-shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 10px 24px rgba(0,0,0,0.06);
    --aci-radius: 8px;
    --aci-radius-sm: 6px;
    --aci-radius-lg: 12px;
    --aci-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 14.5px;
    }
}

body {
    margin: 0;
    color: var(--aci-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--aci-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Refined border-radius (not killed, just consistent) --- */
.btn { border-radius: var(--aci-radius-sm) !important; }
.card { border-radius: var(--aci-radius) !important; }
.card-header:first-child { border-radius: var(--aci-radius) var(--aci-radius) 0 0 !important; }
.card-footer:last-child { border-radius: 0 0 var(--aci-radius) var(--aci-radius) !important; }
.form-control, .form-select { border-radius: var(--aci-radius-sm) !important; }
.input-group > * { border-radius: var(--aci-radius-sm) !important; }
.badge { border-radius: 9999px !important; }
.alert { border-radius: var(--aci-radius) !important; }
.dropdown-menu { border-radius: var(--aci-radius) !important; }
.modal-content { border-radius: var(--aci-radius-lg) !important; }
.offcanvas { border-radius: 0 !important; }
.table { border-radius: 0 !important; }
.form-check-input { border-radius: 4px !important; }

/* --- Primary buttons: amber accent with punch --- */
.btn {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    transition: all var(--aci-transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--aci-accent) 0%, var(--aci-accent-hover) 100%) !important;
    border-color: var(--aci-accent) !important;
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--aci-accent-hover) 0%, #15803d 100%) !important;
    border-color: var(--aci-accent-hover) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--aci-accent) !important;
    border-color: var(--aci-accent) !important;
    background: transparent !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--aci-accent-glow) !important;
    border-color: var(--aci-accent) !important;
    color: var(--aci-accent-hover) !important;
}

/* --- Secondary / outline buttons --- */
.btn-outline-secondary {
    color: var(--aci-text-secondary);
    border-color: var(--aci-border);
    background: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--aci-border-light);
    border-color: var(--aci-border);
    color: var(--aci-text);
}

/* --- Danger --- */
.btn-outline-danger {
    color: var(--aci-danger);
    border-color: var(--aci-danger);
}

.btn-outline-danger:hover {
    background-color: var(--aci-danger);
    border-color: var(--aci-danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* --- Success --- */
.btn-outline-success {
    color: var(--aci-success);
    border-color: var(--aci-success);
}

.btn-outline-success:hover {
    background-color: var(--aci-success);
    border-color: var(--aci-success);
    color: #fff;
}

/* --- Small buttons --- */
.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    font-weight: 600;
}

/* --- Cards: elevated with subtle shadow --- */
.card {
    border: 1px solid var(--aci-border);
    box-shadow: var(--aci-shadow-sm);
    background-color: var(--aci-surface);
    transition: box-shadow var(--aci-transition), transform var(--aci-transition);
}

.card-header {
    background-color: var(--aci-surface);
    border-bottom: 1px solid var(--aci-border);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--aci-text-secondary);
    padding: 0.75rem 1rem;
}

/* --- Tables --- */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--aci-muted);
    border-bottom-width: 2px;
}

.table td {
    vertical-align: middle;
    border-color: var(--aci-border-light);
}

.table-hover > tbody > tr {
    transition: background-color var(--aci-transition);
}

.table-hover > tbody > tr:hover {
    background-color: var(--aci-accent-glow);
}

.table-light {
    --bs-table-bg: var(--aci-bg) !important;
}

/* --- Badges: pill-shaped, modern --- */
.badge {
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.35em 0.8em;
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    height: 100vh;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--aci-sidebar) 0%, #1e293b 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.25rem !important;
}

.sidebar .navbar-brand {
    display: flex;
    align-items: center;
}

.sidebar-logo {
    height: 32px;
    width: auto;
}

.sidebar .nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.55rem 0.75rem;
    color: rgba(255, 255, 255, 0.55) !important;
    transition: all var(--aci-transition);
    border-radius: var(--aci-radius-sm) !important;
    position: relative;
}

.sidebar .nav-link:hover {
    background-color: var(--aci-sidebar-hover);
    color: rgba(255, 255, 255, 0.9) !important;
}

.sidebar .nav-link.active {
    background-color: var(--aci-accent-glow);
    color: var(--aci-accent) !important;
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--aci-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar .nav-link i {
    width: 1.35em;
    text-align: center;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity var(--aci-transition);
}

.sidebar .nav-link:hover i,
.sidebar .nav-link.active i {
    opacity: 1;
}

.sidebar hr {
    border-color: rgba(255, 255, 255, 0.08) !important;
    margin: 0.75rem 0;
}

@media (max-width: 767.98px) {
    .sidebar {
        display: none !important;
    }
}

/* --- Sign out button in sidebar --- */
.sidebar .btn-outline-light {
    font-size: 0.78rem;
    border-radius: var(--aci-radius-sm) !important;
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.5);
    transition: all var(--aci-transition);
}

.sidebar .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.sidebar .small.text-secondary {
    color: rgba(255, 255, 255, 0.4) !important;
    font-weight: 500;
}

/* --- Sidebar goal slots --- */
.sidebar-goals {
    padding-top: 0.25rem;
    transition: opacity var(--aci-transition);
}

.sidebar-goals:hover {
    opacity: 0.85;
}

.goal-slot {
    border-radius: var(--aci-radius-sm);
    margin-bottom: 0.25rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 36px;
}

.goal-slot-icon {
    font-size: 0.8rem;
    color: var(--aci-accent);
    opacity: 0.7;
    flex-shrink: 0;
}

.goal-slot-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-grow: 1;
    min-width: 0;
}

.goal-slot-metric {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.goal-slot-value {
    font-size: 0.78rem;
    color: var(--aci-accent);
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.goal-progress-track {
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.goal-progress-bar {
    height: 100%;
    background: var(--aci-accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* --- Offcanvas goal slots --- */
.offcanvas .sidebar-goals {
    padding-top: 0;
}

.offcanvas .goal-slot {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
}

/* --- Mobile top bar --- */
.navbar-dark.bg-dark {
    background: var(--aci-sidebar) !important;
}

.navbar-dark .navbar-brand {
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--aci-accent) !important;
}

/* --- Offcanvas mobile sidebar --- */
.offcanvas.bg-dark {
    background: linear-gradient(180deg, var(--aci-sidebar) 0%, #1e293b 100%) !important;
}

.offcanvas .offcanvas-title {
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--aci-accent) !important;
}

/* --- Form focus states --- */
.form-control, .form-select {
    border-color: var(--aci-border);
    transition: border-color var(--aci-transition), box-shadow var(--aci-transition);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 3px var(--aci-accent-glow);
    border-color: var(--aci-accent);
}

/* --- Breadcrumbs --- */
.breadcrumb {
    font-size: 0.8rem;
    background: transparent;
    padding: 0;
    margin-bottom: 0;
}

.breadcrumb-item a {
    color: var(--aci-accent);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-item a:hover {
    color: var(--aci-accent-hover);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--aci-muted);
}

/* --- Alerts --- */
.alert-success {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* --- Masquerade Banner --- */
.masquerade-banner {
    background: linear-gradient(135deg, var(--aci-danger) 0%, #dc2626 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1050;
}

.masquerade-banner .btn-light {
    color: var(--aci-danger);
}

/* --- Dashboard stat cards --- */
.stat-card {
    border-left: 4px solid var(--aci-accent) !important;
    background: var(--aci-surface);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: var(--aci-accent-glow);
    border-radius: 50%;
    pointer-events: none;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--aci-primary);
    line-height: 1;
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--aci-muted);
    font-weight: 700;
    position: relative;
    z-index: 1;
}

/* --- Page headings --- */
h2 {
    font-weight: 800;
    color: var(--aci-primary);
    font-size: 1.5rem;
}

h3 {
    font-weight: 700;
    color: var(--aci-primary);
}

/* --- Links in tables/lists --- */
a.text-decoration-none.fw-semibold {
    color: var(--aci-primary);
    transition: color var(--aci-transition);
}

a.text-decoration-none.fw-semibold:hover {
    color: var(--aci-accent);
}

/* --- Login page --- */
body.bg-light {
    background: linear-gradient(135deg, var(--aci-primary) 0%, #1e293b 50%, #334155 100%) !important;
}

/* --- Upload / drop zone --- */
.upload-zone {
    border: 2px dashed var(--aci-border);
    background: var(--aci-bg);
    padding: 2.5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--aci-transition);
    border-radius: var(--aci-radius-lg) !important;
}

.upload-zone:hover {
    border-color: var(--aci-accent);
    background: var(--aci-accent-glow);
}

.upload-zone input[type="file"] {
    display: none;
}

/* --- Smooth page transitions --- */
main {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbar styling (webkit) --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--aci-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--aci-muted);
}

/* --- Selection color --- */
::selection {
    background: var(--aci-accent);
    color: #fff;
}

/* --- Floating label tweaks --- */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- CM note content cleanup --- */
.cm-note-content ul {
    margin-bottom: 0;
    padding-left: 1.25rem;
}

.cm-note-content li {
    margin-bottom: 0.15rem;
}