@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ===== CSS Custom Properties (Variables) ===== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    
    --header-bg: #ffffff;
    --header-height: 64px;
    --header-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    
    --body-bg: #f1f5f9;
    --page-bg: #dfe5ed; /* behind the cards - darker than --body-bg so white cards stand out */
    --card-bg: #ffffff;
    --card-border: #cbd5e1;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.08);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-sm: 4px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

/* ===== Base Styles ===== */
html, body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--page-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* ===== Links & Buttons ===== */
a, .btn-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover, .btn-link:hover {
    color: var(--primary-hover);
}

.btn {
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: none;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.25);
}

.btn-outline-primary {
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-success { background-color: var(--success-color); border-color: var(--success-color); }
.btn-warning { background-color: var(--warning-color); border-color: var(--warning-color); }
.btn-danger { background-color: var(--danger-color); border-color: var(--danger-color); }
.btn-info { background-color: var(--info-color); border-color: var(--info-color); }

/* ===== Layout Structure ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width var(--transition-normal);
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--header-height);
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0.5rem 1.5rem;
    margin-top: 0.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.nav-item {
    margin: 0.125rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    text-decoration: none;
    font-weight: 500;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-link span {
    white-space: nowrap;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0; /* Critical: without this, wide content (tables/grids) expands the flex item past the viewport instead of scrolling inside its own container */
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.top-header {
    background: var(--header-bg);
    height: var(--header-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--header-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background-color: var(--body-bg);
    color: var(--text-primary);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.content-wrapper {
    padding: 1.5rem;
    flex: 1;
    min-height: 0; /* Critical for flex children to shrink */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Page header should not grow */
.content-wrapper > .page-header {
    flex-shrink: 0;
}

/* Card fills remaining space */
.content-wrapper > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Card that should NOT expand to fill space */
.content-wrapper > .card.card-auto-height {
    flex: 0 0 auto;
}

.content-wrapper > .card > .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Grid fills the card body */
.content-wrapper .e-grid {
    flex: 1;
    min-height: 0;
}

/* Tab component fills remaining space */
.content-wrapper > .e-tab {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > .e-tab > .e-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > .e-tab > .e-content > .e-item.e-active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > .e-tab > .e-content > .e-item.e-active > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > .e-tab > .e-content > .e-item.e-active > .card > .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tab card that should NOT expand/clip — normal document flow, page scrolls instead
   (the tab-context counterpart of .card-auto-height above) */
.content-wrapper > .e-tab > .e-content > .e-item.e-active > .card.card-auto-height {
    flex: 0 0 auto;
}

.content-wrapper > .e-tab > .e-content > .e-item.e-active > .card.card-auto-height > .card-body {
    flex: none;
    min-height: auto;
    display: block;
    overflow: visible;
}

.content-wrapper > .e-tab > .e-content > .e-item.e-active > .card > .card-header {
    flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    font-weight: 600;
    font-size: 1rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--body-bg);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ===== Form Elements ===== */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.625rem 0.875rem;
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: var(--success-color);
}

.invalid {
    outline: none;
    border-color: var(--danger-color);
}

.validation-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ===== Badges ===== */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
    border-radius: 9999px;
}

.badge.bg-success { background-color: var(--success-color) !important; }
.badge.bg-danger { background-color: var(--danger-color) !important; }
.badge.bg-warning { background-color: var(--warning-color) !important; color: #1e293b !important; }
.badge.bg-info { background-color: var(--info-color) !important; }
.badge.bg-primary { background-color: var(--primary-color) !important; }

/* ===== Stats Cards / Dashboard ===== */
.stats-card {
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    background: white;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stats-icon.primary { background: var(--primary-light); color: var(--primary-color); }
.stats-icon.success { background: #d1fae5; color: var(--success-color); }
.stats-icon.warning { background: #fef3c7; color: var(--warning-color); }
.stats-icon.danger { background: #fee2e2; color: var(--danger-color); }

.stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.5rem 0 0.25rem;
}

.stats-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== Login Display ===== */
.login-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-display a, .login-display form .btn {
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.login-display a:hover, .login-display form .btn:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
}

/* ===== Error UI ===== */
#blazor-error-ui {
    background: #fef2f2;
    border-top: 2px solid var(--danger-color);
    bottom: 0;
    display: none;
    left: 0;
    padding: 1rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.25rem;
}

/* ===== Dialog / Modal ===== */
.dialog-container {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    animation: dialog-container-entry 0.2s ease-out;
}

@keyframes dialog-container-entry {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.dialog {
    background-color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    align-self: center;
    margin: auto;
    width: 700px;
    max-width: 90vw;
    max-height: calc(100% - 3rem);
    border-radius: var(--border-radius-lg);
    animation: dialog-entry 0.3s ease-out;
}

@keyframes dialog-entry {
    0% {
        transform: translateY(20px) scale(0.98);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.dialog-title {
    background: linear-gradient(135deg, var(--sidebar-bg), #334155);
    color: white;
    padding: 1.25rem 1.5rem;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.dialog-title h2 {
    color: white;
    font-size: 1.25rem;
    margin: 0;
    font-weight: 600;
}

.dialog-body {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.dialog-buttons {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: var(--body-bg);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    border-top: 1px solid var(--border-color);
}

.dialog-body > div {
    display: flex;
    margin-top: 1rem;
    align-items: center;
}

.dialog-body label {
    text-align: right;
    width: 200px;
    margin: 0 1.5rem;
    color: var(--text-secondary);
}

.dialog-body input, .dialog-body select {
    flex-grow: 1;
    width: unset;
}

/* ===== Page Headers ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ===== Tables ===== */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.table td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: var(--body-bg);
}

/* ===== Loading States ===== */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 0.875rem 1rem;
}

.alert-success { background-color: #d1fae5; color: #065f46; }
.alert-warning { background-color: #fef3c7; color: #92400e; }
.alert-danger { background-color: #fee2e2; color: #991b1b; }
.alert-info { background-color: #e0f2fe; color: #075985; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        /* Use the dynamic viewport height so the sidebar fits between the
           browser toolbars (100vh sits behind the mobile Safari bottom bar,
           hiding the last menu items). */
        height: 100dvh;
        overflow-y: auto;
        /* Keep scrolling contained to the sidebar instead of chaining through
           to the page underneath when reaching the top/bottom. */
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* Scroll buffer below the last menu item so it can always be scrolled up
       clear of the mobile browser's bottom toolbar / home indicator, even when
       100dvh doesn't fully account for the toolbar (an iOS position:fixed quirk).
       Placed on the scrolling content — WebKit can ignore bottom padding on the
       scroll container itself. */
    .sidebar-nav {
        padding-bottom: calc(env(safe-area-inset-bottom) + 6rem);
    }

    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* ===== Utility Classes ===== */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-success-light { background-color: #d1fae5 !important; }
.bg-warning-light { background-color: #fef3c7 !important; }
.bg-danger-light { background-color: #fee2e2 !important; }

.rounded-lg { border-radius: var(--border-radius-lg) !important; }
.shadow-sm { box-shadow: var(--card-shadow) !important; }
.shadow-md { box-shadow: var(--card-shadow-hover) !important; }

/* ===== Quick Actions Grid ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition-normal);
}

.quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.quick-action-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    background: var(--body-bg);
    transition: all var(--transition-normal);
}

.quick-action-card:hover .quick-action-icon {
    background: var(--primary-light);
    color: var(--primary-color);
}

.quick-action-label {
    font-weight: 500;
    text-align: center;
}

/* ===== Identity/Authentication Pages ===== */
.auth-container {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.auth-container > .row {
    width: 100%;
}

.auth-card {
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.auth-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: white;
    font-size: 2rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.auth-card .form-floating > label {
    color: var(--text-secondary);
}

.auth-card .form-floating > .form-control:focus ~ label,
.auth-card .form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary-color);
}

.auth-card .form-control {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 0.875rem;
    transition: all var(--transition-fast);
}

.auth-card .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.auth-card .btn-primary {
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.auth-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

/* ===== Account Management Pages ===== */
.account-management-container {
    max-width: 1200px;
}

.account-header-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.account-nav-card {
    position: sticky;
    top: 1rem;
    overflow: hidden;
}

.account-nav-header {
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background-color: var(--body-bg);
    border-bottom: 1px solid var(--border-color);
}

.account-nav {
    display: flex !important;
    flex-direction: column !important;
    padding: 0;
    margin: 0;
    list-style: none;
}

.account-nav-link {
    display: flex !important;
    align-items: center;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.account-nav-link:last-child {
    border-bottom: none;
}

.account-nav-link:hover {
    background-color: var(--body-bg);
    color: var(--primary-color);
    text-decoration: none;
}

.account-nav-link.active {
    background-color: var(--primary-light);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.account-nav-link i {
    width: 24px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.account-nav-link span {
    white-space: nowrap;
}

.manage-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.manage-section .form-floating > .form-control {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
}

.manage-section .form-floating > .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.auth-method-card {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    transition: all var(--transition-fast);
}

.auth-method-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.auth-method-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.25rem;
}

/* Status Message Styling */
.manage-section .alert,
.auth-card .alert {
    border: none;
    border-radius: var(--border-radius);
}

.manage-section .alert-success {
    background-color: #ecfdf5;
    color: #065f46;
}

.manage-section .alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
}

.manage-section .alert-warning {
    background-color: #fffbeb;
    color: #92400e;
}

.manage-section .alert-info {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

/* ===== Grid Container Fixes ===== */
/* Grid styling */
.card .e-grid {
    border: none;
}

.e-grid .e-gridcontent {
    overflow: auto;
}

/* ===== Users page height ===== */
/* The Users list is wrapped in #user-list-section (for the list/edit toggle), which breaks the
   default ".content-wrapper > .card" flex-fill chain. Re-establish it so the grid fills the
   viewport and scrolls internally instead of pushing the page past the bottom of the screen.
   ":not([hidden])" keeps the hidden section collapsed when the edit view is shown. */
.content-wrapper > #user-list-section:not([hidden]) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > #user-list-section > .page-header {
    flex-shrink: 0;
}

.content-wrapper > #user-list-section > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-wrapper > #user-list-section > .card > .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Grid wrapper inside the UserList component fills the remaining card-body height */
.user-grid-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ===== Dashboard cards ===== */
/* Platform tiles are links; keep the tile styling and drop the anchor defaults. Each tile fills
   its column so a tile with a sub-line (Blocked IPs) does not sit taller than its neighbours. */
a.stats-card {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

a.stats-card:hover {
    color: inherit;
}

.stats-sub {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.dashboard-card .card-header {
    padding: 0.875rem 1.25rem;
}

.dashboard-card .card-body {
    padding: 1.25rem;
}

.dashboard-card .card-footer {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
}

.dashboard-card .card-header a,
.dashboard-card .card-footer a {
    font-weight: 500;
    text-decoration: none;
}

/* Compact KPI row inside a card */
.mini-stat {
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    background: var(--body-bg);
    border: 1px solid var(--border-color);
}

.mini-stat-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Headline figure with supporting lines (remittance card) */
.dashboard-metric-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dashboard-metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.25rem 0;
    line-height: 1.2;
}

.dashboard-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
}

.dashboard-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    min-width: 0;
}

.dashboard-list li:first-child {
    border-top: 0;
}

.dashboard-list .item-primary {
    font-weight: 500;
    color: var(--text-primary);
}

.dashboard-list .item-secondary {
    color: var(--text-secondary);
}

.dashboard-list .item-amount {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ===== Feature Flags: by customer / by user views ===== */
.ff-picker-list {
    max-height: 60vh;
    overflow-y: auto;
}

.ff-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    transition: background-color var(--transition-fast);
}

.ff-picker-item:hover:not(:disabled) {
    background: var(--body-bg);
}

.ff-picker-item.active {
    background: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.ff-picker-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.ff-picker-item:disabled {
    cursor: not-allowed;
}

.ff-picker-text {
    min-width: 0;
}

.ff-picker-name,
.ff-picker-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ff-picker-name {
    font-weight: 500;
}

.ff-picker-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ff-picker-counts {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.ff-count {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.ff-count-on {
    background: #d1e7dd;
    color: #0f5132;
}

.ff-count-off {
    background: #f8d7da;
    color: #842029;
}

.ff-detail-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ff-flag-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ff-flag-filter input {
    flex: 1 1 200px;
}

.ff-flag-table td {
    padding: 0.625rem 0.75rem;
}

.ff-flag-table tbody tr.ff-group-row td,
.ff-flag-table tbody tr.ff-group-row:hover {
    background: var(--body-bg);
}

.ff-flag-table tbody tr.ff-group-row td {
    padding: 0.4rem 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ff-group-count {
    font-weight: 400;
    color: var(--text-secondary);
}

.ff-state {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.ff-state-on {
    background: #198754;
    color: #fff;
}

.ff-state-off {
    background: #dc3545;
    color: #fff;
}

.ff-state-on-soft {
    background: #d1e7dd;
    color: #0f5132;
}

.ff-state-off-soft {
    background: #e9ecef;
    color: #495057;
}

.ff-state-mixed {
    background: #fff3cd;
    color: #664d03;
}

.ff-source {
    margin-top: 0.15rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

@media (max-width: 991.98px) {
    .ff-picker-list {
        max-height: 40vh;
    }
}
