/* /public/css/layout/sidebar-core.css */
/* Core sidebar: container, logo, scroll area, nav groups, links, footer, collapse toggle */

/* --- 1. Main Sidebar Container --- */
.dashboard-sidebar {
    width: var(--sidebar-width, 240px);
    background-color: var(--sidebar-bg, #ffffff);
    border-right: 1px solid var(--sidebar-border, #e5e7eb);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1040;
    position: sticky;
    /* Offset below any fixed banners (hellobar, impersonation bar) via JS-set variable */
    top: var(--header-offset, 0px);
    height: calc(100vh - var(--header-offset, 0px));
    transition: width var(--sidebar-transition, 200ms ease);
    overflow: hidden;
}

/* Collapsed sidebar state (JS toggle + FOUC body class) */
.dashboard-sidebar.is-collapsed,
body.sidebar-is-collapsed .dashboard-sidebar {
    width: var(--sidebar-width-collapsed, 56px);
}

/* --- 3. Scrollable Area --- */
.sidebar-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
/* Light scrollbar for sidebar */
.sidebar-scroll-area::-webkit-scrollbar { width: 4px; }
.sidebar-scroll-area::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
.sidebar-scroll-area::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* --- 4. Navigation Groups (Inline Expansion) --- */
.sidebar-group {
    position: relative;
    margin-bottom: 0;
}

/* Subtle divider between consecutive groups */
.sidebar-group + .sidebar-group {
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.06));
}

/* Group Header (clickable to expand/collapse) */
.sidebar-group-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    color: var(--sidebar-text, #6b7280);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    user-select: none;
    background-color: transparent;
}

.sidebar-group-trigger:hover {
    background-color: rgba(79, 70, 229, 0.06);
    color: #1f2937;
}

/* Expanded state (group is open) */
.sidebar-group-trigger.is-expanded {
    color: #1f2937;
}

/* Group icon (left side — stays stationary) */
.sidebar-group-trigger .sidebar-group-icon {
    font-size: 0.8rem;
    width: 18px;
    text-align: center;
    color: rgba(55, 65, 81, 0.4);
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.sidebar-group-trigger:hover .sidebar-group-icon {
    color: rgba(55, 65, 81, 0.65);
}

.sidebar-group-trigger.is-expanded .sidebar-group-icon {
    color: #6366f1;
}

/* Group title text (fills available space) */
.sidebar-group-trigger span {
    flex: 1;
    min-width: 0;
}

/* Chevron rotation (right side — only targets the chevron, not the group icon) */
.sidebar-group-trigger .sidebar-group-chevron {
    font-size: 0.6rem;
    color: rgba(55, 65, 81, 0.3);
    transition: transform 200ms ease, color 150ms ease;
    flex-shrink: 0;
}

.sidebar-group-trigger:hover .sidebar-group-chevron {
    color: rgba(55, 65, 81, 0.5);
}

.sidebar-group-trigger.is-expanded .sidebar-group-chevron {
    transform: rotate(90deg);
    color: var(--sidebar-text, #6b7280);
}

/* Grouped flyout: hidden until group trigger is expanded.
   Items live inside .sidebar-group-flyout, which is a sibling of the trigger. */
.sidebar-group-flyout {
    display: none;
}

.sidebar-group-trigger.is-expanded ~ .sidebar-group-flyout {
    display: block;
}

/* Flyout label (group title inside flyout) — hidden in expanded sidebar */
.sidebar-group-flyout-label {
    display: none;
}

/* --- 4b. Standalone Link (Top-level, no collapsible group) --- */
.sidebar-standalone-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 8px;
    color: #4338ca;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 2px;
}
.sidebar-standalone-link i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    color: #6366f1;
    flex-shrink: 0;
    transition: color 0.15s ease;
}
.sidebar-standalone-link:hover {
    background-color: rgba(79, 70, 229, 0.08);
    color: #4338ca;
    text-decoration: none;
}
.sidebar-standalone-link.is-active {
    background-color: rgba(79, 70, 229, 0.12);
    color: #4338ca;
}
.sidebar-standalone-link.is-active i {
    color: #4f46e5;
}

/* Divider between standalone link and the first group below it */
.sidebar-standalone-link + .sidebar-group {
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid var(--sidebar-border, rgba(0, 0, 0, 0.06));
}

/* --- 4c. Quick Action Row (Earn Credits / New Campaign) --- */
.sidebar-action-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--sidebar-border, #e5e7eb);
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 36px;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.sidebar-action-btn i {
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-action-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-action-btn--primary {
    background-color: #4f46e5;
    color: #ffffff;
    border: 1px solid #4f46e5;
}

.sidebar-action-btn--primary:hover {
    background-color: #4338ca;
    border-color: #4338ca;
    color: #ffffff;
    text-decoration: none;
}

.sidebar-action-btn--secondary {
    background-color: #1e293b;
    color: #ffffff;
    border: 1px solid #1e293b;
}

.sidebar-action-btn--secondary i {
    color: #fbbf24;
}

.sidebar-action-btn--secondary:hover {
    background-color: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
    text-decoration: none;
}

.sidebar-action-btn--secondary:hover i {
    color: #fbbf24;
}

/* --- 5. Links (Inline Navigation Items) --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    height: 40px;
    border-radius: 8px;
    color: var(--sidebar-text, #6b7280);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    border: none;
    border-left: 3px solid transparent;
    line-height: 1.2;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 1px;
}

.sidebar-link i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(55, 65, 81, 0.4);
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-link span {
    padding-right: 4px;
    overflow: visible;
    text-overflow: clip;
}

.sidebar-link:hover {
    background-color: rgba(79, 70, 229, 0.06);
    color: #1f2937;
    text-decoration: none;
}
.sidebar-link:hover i { color: rgba(55, 65, 81, 0.7); }

.sidebar-link.is-active {
    background-color: rgba(79, 70, 229, 0.1);
    color: #4338ca;
    font-weight: 600;
    border-left-color: transparent;
}
.sidebar-link.is-active i { color: #6366f1; }

.sidebar-link.is-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background-color: transparent;
}

/* Red Danger Link (Logout) — sidebar */
.sidebar-link.text-danger {
    color: #f87171;
}
.sidebar-link.text-danger i {
    color: #f87171;
}
.sidebar-link.text-danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}
.sidebar-link.text-danger:hover i {
    color: #fca5a5;
}

/* Red Danger Link (Logout) — mobile (stays light theme) */
.mobile-nav-link.text-danger {
    color: #ef4444;
}
.mobile-nav-link.text-danger i {
    color: #ef4444;
}
.mobile-nav-link.text-danger:hover {
    background-color: #fef2f2;
    color: #dc2626;
}
.mobile-nav-link.text-danger:hover i {
    color: #dc2626;
}

/* --- 6. Badges --- */
.sidebar-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    padding: 0 6px;
    height: 16px;
    border-radius: 4px;
    min-width: 0;
}

.sidebar-badge--new  { background-color: #e0e7ff; color: #4338ca; }
.sidebar-badge--hot  { background-color: #fee2e2; color: #dc2626; }
.sidebar-badge--soon { background-color: #f3f4f6; color: #9ca3af; }
.sidebar-badge--info { background-color: #e0e7ff; color: #4338ca; }

/* --- 1c. Logo Row (Desktop Sidebar) --- */
.sidebar-logo-row {
    height: var(--header-height, 56px);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border, #e5e7eb);
}

.sidebar-logo-link {
    display: inline-block;
    line-height: 0;
}

.sidebar-logo-img {
    height: 28px;
    width: auto;
    max-width: 160px;
    display: block;
}

/* Favicon-only logo — hidden in expanded mode, shown when collapsed */
.sidebar-logo-link--favicon {
    display: none;
    line-height: 0;
}

.sidebar-favicon-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    display: block;
}

.dashboard-sidebar.is-collapsed .sidebar-logo-link--favicon,
body.sidebar-is-collapsed .dashboard-sidebar .sidebar-logo-link--favicon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Usage Bars (rendered inside .sidebar-footer-widget) --- */
.sidebar-usage-link {
    display: block;
    text-decoration: none;
    border-radius: 4px;
    margin: 0 -4px;
    padding: 2px 4px;
    transition: background 0.15s;
}
.sidebar-usage-link:hover {
    background: rgba(255,255,255,0.06);
}
.sidebar-usage-link:hover .sidebar-usage-label {
    color: #4338ca;
}

.sidebar-usage-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.sidebar-usage-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: #6b7280;
}

.sidebar-usage-count {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: #f97316;
}

.sidebar-usage-count--green {
    color: #22c55e;
}

.sidebar-usage-count--credits {
    color: #6366f1; /* Indigo — stands out against dark sidebar */
}

.sidebar-usage-count.is-warning {
    color: #fb923c;
}

.sidebar-usage-count.is-full {
    color: #ef4444;
}

.sidebar-usage-count.is-full.sidebar-usage-count--green {
    color: #ef4444;
}

.sidebar-usage-bar-track {
    width: 100%;
    height: 5px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.sidebar-usage-bar-fill {
    height: 100%;
    background: #f97316;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.sidebar-usage-bar-fill--green {
    background: #22c55e;
}

.sidebar-usage-bar-fill.is-warning {
    background: #fb923c;
}

.sidebar-usage-bar-fill.is-full {
    background: #ef4444;
}

/* --- 7. Sticky Footer --- */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border, #e5e7eb);
    background-color: transparent;
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-plan-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-plan-card:hover {
    transform: translateY(-2px);
    text-decoration: none;
}

.sidebar-plan-card--free-compact {
    background-color: #ffffff;
    border: 1px solid var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.15);
    padding: 12px 14px;
    gap: 0;
}

.sidebar-plan-card--free-compact:hover {
    box-shadow: 0 8px 20px rgba(67, 56, 202, 0.25);
    border-color: #3730a3;
}

.plan-card-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.plan-name-compact {
    font-size: 0.75rem;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.plan-upgrade-pill {
    background-color: #e0e7ff;
    color: var(--color-primary-dark);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.05em;
}

.plan-usage-row { margin-bottom: 6px; }

.plan-usage-text {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    display: block;
}

.plan-usage-meter-compact { width: 100%; }

.plan-usage-meter-compact .meter-track {
    background-color: #f1f5f9;
    height: 6px;
    border-radius: 99px;
    overflow: hidden;
}

.meter-fill { height: 100%; transition: width 0.3s ease; border-radius: 99px; }
.meter-fill.is-safe    { background-color: #10b981; }
.meter-fill.is-warning { background-color: #fbbf24; }
.meter-fill.is-danger  { background-color: #ef4444; }

.sidebar-plan-card--paid-zen {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    align-items: center;
    justify-content: center;
}
.sidebar-plan-card--paid-zen:hover { border-color: #cbd5e1; background-color: #f1f5f9; }
.sidebar-plan-card--paid-zen .plan-info-name { font-size: 0.8rem; font-weight: 700; color: #334155; }
.sidebar-plan-card--paid-zen .plan-info-status { font-size: 0.7rem; color: #16a34a; font-weight: 600; margin-left: auto; display: flex; gap: 4px; align-items: center; }

/* =========================================================
   SIDEBAR FOOTER WIDGET (Plan name + usage bars combined)
   ========================================================= */

.sidebar-footer-widget {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex-shrink: 0;
}

/* Plan name row (e.g. "FREE PLAN" + "Upgrade" pill, or "PRO PLAN" + "Active") */
.sidebar-footer-plan-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.sidebar-footer-plan-name {
    font-size: var(--font-size-xs);
    font-weight: 800;
    color: #374151;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    line-height: 1;
}

/* Upgrade pill (free users) */
.sidebar-footer-upgrade-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: #e0e7ff;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 5px;
    color: #4338ca;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sidebar-footer-upgrade-pill:hover {
    background: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.5);
    text-decoration: none;
    color: #3730a3;
}

.sidebar-footer-upgrade-pill i {
    font-size: 0.8em;
}

/* Active badge (paid users) */
.sidebar-footer-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #16a34a;
}

.sidebar-footer-active-badge i {
    font-size: 0.8em;
}

/* Thin divider between plan row and usage bars */
.sidebar-footer-widget-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 1px 0;
}

/* Subtle upgrade text link (for Growth/Pro users — less aggressive than pill) */
.sidebar-footer-upgrade-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}
.sidebar-footer-upgrade-link:hover {
    color: #4338ca;
    text-decoration: none;
}
.sidebar-footer-upgrade-link i {
    font-size: 0.8em;
    transition: transform 0.15s ease;
}
.sidebar-footer-upgrade-link:hover i {
    transform: translateX(2px);
}

/* Contextual nudge when usage bars hit 100% */
.sidebar-footer-limit-nudge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #7c3aed;
    text-decoration: none;
    margin-top: 2px;
    transition: color 0.15s ease;
}
.sidebar-footer-limit-nudge:hover {
    color: #6d28d9;
    text-decoration: none;
}
.sidebar-footer-limit-nudge i {
    font-size: 0.8em;
}

/* =========================================================
   10. COLLAPSE TOGGLE BUTTON
   ========================================================= */
.sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--sidebar-text-heading, #64748b);
    font-family: inherit;
    font-size: var(--font-size-2xs, 0.6875rem);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.sidebar-collapse-toggle:hover {
    background-color: rgba(79, 70, 229, 0.06);
    color: var(--sidebar-text, #6b7280);
}

.sidebar-collapse-toggle i {
    font-size: 0.65rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 200ms ease;
}
