/**
 * Dashboard Layout Styles
 * Global styles for role-based dashboard panels (Fee Clerk, Admin, etc.)
 *
 * These styles are global (not scoped) to ensure they work with Blazor components.
 * CSS isolation doesn't work well with nested child elements.
 */

/* =============================================================================
   DASHBOARD BODY
   ============================================================================= */

.rd-body {
    min-height: 100vh;
    background: var(--bg-primary);
}

/* =============================================================================
   TOP NAVIGATION (Dashboard)
   ============================================================================= */

.dashboard-nav.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    max-height: 64px;
    background: var(--card-gradient);
    border-bottom: 1px solid var(--border);
    z-index: var(--z-fixed, 1030);
    padding: 0 1.25rem;
    overflow: visible;
    box-sizing: border-box;
}

.dashboard-nav .nav-container {
    height: 100%;
    max-height: 64px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
    padding: 0;
}

.dashboard-nav .nav-container > * {
    max-height: none;
}

.dashboard-nav .nav-left {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    padding-left: 0;
}

/* Navbar logo - always visible */
.dashboard-nav .nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.dashboard-nav .nav-logo:hover {
    text-decoration: none;
    opacity: 0.9;
}

.dashboard-nav .nav-logo-img {
    height: 100px;
    width: auto;
    object-fit: contain;
}

/* Light theme: show light logo, hide dark logo */
.dashboard-nav .nav-logo-light {
    display: block;
}

.dashboard-nav .nav-logo-dark {
    display: none;
}

/* Dark theme: show dark logo, hide light logo */
[data-theme="dark"] .dashboard-nav .nav-logo-light {
    display: none;
}

[data-theme="dark"] .dashboard-nav .nav-logo-dark {
    display: block;
}

.dashboard-nav .nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
    max-height: 64px;
    overflow: visible;
    margin-right: 0.5rem;
}

.dashboard-nav .nav-actions > * {
    max-height: 56px;
    flex-shrink: 0;
}

/* Compact icon buttons for dashboard navbar */
.dashboard-nav .btn-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
    padding: 0;
}

.dashboard-nav .btn-icon:hover {
    transform: none;
}

/* =============================================================================
   SHELL CONTAINER
   ============================================================================= */

.rd-shell {
    display: flex;
    margin-top: 64px;
    min-height: calc(100vh - 64px);
    position: relative;
    z-index: 1; /* Keep below navbar (z-index: 1030) */
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */

.rd-sidebar {
    width: 200px;
    background: var(--card-gradient);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 64px;
    bottom: 0;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: var(--z-sticky, 1020);
}

.rd-sidebar.collapsed {
    width: 50px;
}

/* Sidebar Header (collapse button only) */
.rd-sidebar__header {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.rd-sidebar__header .btn-icon {
    flex-shrink: 0;
}

.rd-sidebar__header .sidebar-collapse {
    transition: transform 0.3s ease;
}

.rd-sidebar.collapsed .sidebar-collapse {
    transform: rotate(180deg);
}

.rd-sidebar.collapsed .rd-sidebar__header {
    justify-content: center;
}

/* =============================================================================
   SIDEBAR ROLE SWITCH
   ============================================================================= */

.rd-sidebar__role-switch {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.rd-sidebar__label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.rd-sidebar__role-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    background: var(--brand-blue-alpha, rgba(59, 130, 246, 0.1));
    border-radius: var(--radius-md);
    color: var(--brand-blue, var(--brand-primary));
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
}

.rd-sidebar__switch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.rd-sidebar__switch-btn:hover {
    background: var(--brand-blue, var(--brand-primary));
    color: var(--text-inverse, white);
    border-color: var(--brand-blue, var(--brand-primary));
    text-decoration: none;
}

/* Sidebar Collapsed States */
.rd-sidebar.collapsed .rd-sidebar__role-switch span,
.rd-sidebar.collapsed .rd-sidebar__label {
    display: none;
}

.rd-sidebar.collapsed .rd-sidebar__role-badge,
.rd-sidebar.collapsed .rd-sidebar__switch-btn {
    justify-content: center;
    padding: 0.35rem;
}

/* =============================================================================
   SIDEBAR MENU
   ============================================================================= */

.rd-sidebar__menu {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

/* =============================================================================
   SIDEBAR SECTIONS & LINKS
   ============================================================================= */

.rd-sidebar__section {
    margin-bottom: 0.25rem;
}

.rd-sidebar__label--collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.rd-sidebar__label--collapsible:hover {
    background: var(--bg-secondary);
}

.rd-sidebar__toggle-icon {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.rd-sidebar__toggle-icon.rotated {
    transform: rotate(180deg);
}

.rd-sidebar__links {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.rd-sidebar__links.collapsed {
    max-height: 0;
    opacity: 0;
}

.rd-sidebar__links.expanded {
    max-height: 500px;
    opacity: 1;
}

.rd-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem 0.4rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.rd-sidebar__link:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.rd-sidebar__link.active {
    background: var(--brand-blue-alpha, rgba(59, 130, 246, 0.1));
    color: var(--brand-blue, var(--brand-primary));
    border-left-color: var(--brand-blue, var(--brand-primary));
    font-weight: 600;
}

.rd-sidebar__link i {
    width: 1rem;
    text-align: center;
    font-size: 0.75rem;
}

.rd-sidebar__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Collapsed - hide text */
.rd-sidebar.collapsed .rd-sidebar__section .rd-sidebar__label--collapsible span:first-child,
.rd-sidebar.collapsed .rd-sidebar__toggle-icon,
.rd-sidebar.collapsed .rd-sidebar__text {
    display: none;
}

.rd-sidebar.collapsed .rd-sidebar__link {
    justify-content: center;
    padding: 0.5rem;
}

.rd-sidebar.collapsed .rd-sidebar__link i {
    font-size: 0.9rem;
}

/* =============================================================================
   SIDEBAR FOOTER (User Info & Logout)
   ============================================================================= */

.rd-sidebar__footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.rd-sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    margin-bottom: 0.4rem;
}

.rd-sidebar__user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-blue, var(--brand-primary));
    color: var(--text-inverse, white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.rd-sidebar__user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rd-sidebar__user-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rd-sidebar__user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rd-sidebar__logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.35rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rd-sidebar__logout-btn:hover {
    background: var(--color-error-alpha, rgba(239, 68, 68, 0.1));
    border-color: var(--color-error, #ef4444);
    color: var(--color-error, #ef4444);
}

/* Sidebar Footer Collapsed States */
.rd-sidebar.collapsed .rd-sidebar__user-info {
    display: none;
}

.rd-sidebar.collapsed .rd-sidebar__user {
    justify-content: center;
    padding: 0;
    margin-bottom: 0.25rem;
}

.rd-sidebar.collapsed .rd-sidebar__logout-btn span {
    display: none;
}

.rd-sidebar.collapsed .rd-sidebar__logout-btn {
    padding: 0.35rem;
    width: auto;
    margin: 0 auto;
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.rd-main {
    flex: 1;
    margin-left: 200px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.rd-sidebar.collapsed ~ .rd-main {
    margin-left: 50px;
}

.rd-content {
    flex: 1;
    padding: 0.75rem;
}

.rd-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: center;
}

/* =============================================================================
   BUTTON ICONS (Dashboard)
   ============================================================================= */

.rd-body .btn-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rd-body .btn-icon:hover {
    background: var(--bg-secondary);
}

/* Mobile Toggle */
.rd-body .nav-toggle {
    display: none;
}

/* =============================================================================
   MOBILE RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .rd-sidebar {
        transform: translateX(-100%);
    }

    .rd-sidebar.mobile-open {
        transform: translateX(0);
    }

    .rd-main {
        margin-left: 0;
    }

    .dashboard-nav .nav-toggle {
        display: flex;
    }

    .mobile-only {
        display: flex !important;
    }

    /* Show navbar logo on mobile */
    .dashboard-nav .nav-logo--mobile {
        display: flex;
    }
}

/* =============================================================================
   COMPACT DASHBOARD STYLES (Data-Dense Areas)
   ============================================================================= */

/* Global compact form styling for dashboards */
.rd-body input[type="text"],
.rd-body input[type="number"],
.rd-body input[type="email"],
.rd-body input[type="password"],
.rd-body input[type="date"],
.rd-body input[type="search"],
.rd-body select,
.rd-body textarea {
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-primary);
    line-height: 1.4;
}

.rd-body input:focus,
.rd-body select:focus,
.rd-body textarea:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 2px var(--brand-blue-alpha);
}

/* Compact buttons */
.rd-body .btn,
.rd-body button:not(.btn-icon) {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.rd-body .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.rd-body .btn-lg {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Compact tables */
.rd-body table {
    font-size: 0.8125rem;
    border-collapse: collapse;
    width: 100%;
}

.rd-body table th,
.rd-body table td {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.rd-body table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.rd-body table tr:nth-child(even) {
    background: var(--bg-secondary);
}

.rd-body table tr:hover {
    background: var(--brand-blue-alpha);
}

/* Compact cards */
.rd-body .card,
.rd-body .panel {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.rd-body .card-header,
.rd-body .panel-header {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
}

.rd-body .card-body,
.rd-body .panel-body {
    padding: 0.75rem;
}

.rd-body .card-footer,
.rd-body .panel-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Compact form groups */
.rd-body .form-group {
    margin-bottom: 0.5rem;
}

.rd-body label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
    color: var(--text-secondary);
}

/* Compact grid spacing */
.rd-body .row {
    margin-left: -0.375rem;
    margin-right: -0.375rem;
}

.rd-body .row > [class*="col"] {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
}

/* Page title styling */
.rd-body h1,
.rd-body .page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
}

.rd-body h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.rd-body h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.35rem 0;
    color: var(--text-primary);
}

/* Compact badge styling */
.rd-body .badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Alert compact styling */
.rd-body .alert {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

/* Compact pagination */
.rd-body .pagination {
    gap: 0.25rem;
}

.rd-body .pagination .page-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Compact dropdowns */
.rd-body .dropdown-menu {
    font-size: 0.8125rem;
    padding: 0.25rem 0;
    border-radius: var(--radius-sm);
}

.rd-body .dropdown-item {
    padding: 0.35rem 0.75rem;
}

/* Compact modal styling */
.rd-body .modal-header {
    padding: 0.75rem 1rem;
}

.rd-body .modal-body {
    padding: 1rem;
}

.rd-body .modal-footer {
    padding: 0.75rem 1rem;
}

/* Status badges */
.rd-body .status-paid,
.rd-body .status-success {
    background: var(--color-success-alpha);
    color: var(--color-success);
}

.rd-body .status-pending,
.rd-body .status-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

.rd-body .status-unpaid,
.rd-body .status-error {
    background: var(--color-error-alpha);
    color: var(--color-error);
}

/* Compact text utilities */
.rd-body .text-sm {
    font-size: 0.75rem;
}

.rd-body .text-xs {
    font-size: 0.6875rem;
}

.rd-body .text-muted {
    color: var(--text-muted);
}

/* Compact spacing utilities */
.rd-body .mb-1 { margin-bottom: 0.25rem; }
.rd-body .mb-2 { margin-bottom: 0.5rem; }
.rd-body .mb-3 { margin-bottom: 0.75rem; }
.rd-body .mb-4 { margin-bottom: 1rem; }
.rd-body .mt-1 { margin-top: 0.25rem; }
.rd-body .mt-2 { margin-top: 0.5rem; }
.rd-body .mt-3 { margin-top: 0.75rem; }
.rd-body .mt-4 { margin-top: 1rem; }
.rd-body .p-1 { padding: 0.25rem; }
.rd-body .p-2 { padding: 0.5rem; }
.rd-body .p-3 { padding: 0.75rem; }
.rd-body .p-4 { padding: 1rem; }

/* Compact gap utilities */
.rd-body .gap-1 { gap: 0.25rem; }
.rd-body .gap-2 { gap: 0.5rem; }
.rd-body .gap-3 { gap: 0.75rem; }
.rd-body .gap-4 { gap: 1rem; }
