@media (max-width: 700px) {
    .btn-icon-mobile .rz-button-text {
        display: none;
    }
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

:root {
    font-size: var(--rz-root-font-size);
}

body {
    font-family: var(--rz-text-font-family);
    color: var(--rz-text-color);
    font-size: var(--rz-body-font-size);
    line-height: var(--rz-body-line-height);
    background-color: var(--rz-body-background-color);
}

.rz-body {
    --rz-body-padding: 0;
}

a {
    color: var(--rz-link-color);
}

a:hover,
a:focus {
    color: var(--rz-link-hover-color);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA9ificando.png);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ===========================
   Manage Company Users Styling
   =========================== */

.manage-users-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(var(--rz-primary-rgb, 0, 123, 255), 0.02) 0%, transparent 50%);
    min-height: 100vh;
}

/* Page Header */
.page-header {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    border-left: 4px solid var(--rz-primary, #0d6efd);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-title {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 250px;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Users Section */
.users-section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 250px;
}

.search-box {
    max-width: 400px;
    width: 100%;
    padding-left: 2.75rem !important;
    border-radius: 8px !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    transition: all 0.3s ease !important;
}

.search-box:focus {
    border-color: var(--rz-primary, #0d6efd) !important;
    box-shadow: 0 0 0 3px rgba(var(--rz-primary-rgb, 0, 123, 255), 0.1) !important;
}

/* Users Card */
.users-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
}

.users-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Modern Table */
.users-table-wrapper {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.modern-table thead {
    background: linear-gradient(135deg, rgba(var(--rz-primary-rgb, 0, 123, 255), 0.08) 0%, rgba(var(--rz-primary-rgb, 0, 123, 255), 0.04) 100%);
    border-bottom: 2px solid rgba(var(--rz-primary-rgb, 0, 123, 255), 0.2);
}

.modern-table thead th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-weight: 600;
    color: var(--rz-text-color, #333);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.modern-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.modern-table tbody tr:last-child {
    border-bottom: none;
}

.modern-table tbody .user-row {
    cursor: pointer;
}

.modern-table tbody .user-row:hover {
    background: linear-gradient(90deg, rgba(var(--rz-primary-rgb, 0, 123, 255), 0.04) 0%, transparent 100%);
    transform: translateX(2px);
}

.modern-table tbody td {
    padding: 1.25rem 1.25rem;
    vertical-align: middle;
    color: var(--rz-text-color, #333);
}

.user-cell {
    display: flex;
    align-items: center;
    font-weight: 500;
}

.user-name {
    color: var(--rz-primary, #0d6efd);
    font-weight: 500;
}

.roles-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.no-roles {
    color: var(--rz-text-disabled-color, #999);
    font-style: italic;
    font-size: 0.875rem;
}

.actions-column {
    width: 180px;
    text-align: center;
}

.actions-cell {
    text-align: center;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
}

.action-buttons .rz-button {
    min-width: 36px;
    transition: all 0.2s ease;
}

.action-buttons .rz-button:hover {
    transform: translateY(-2px);
}

/* Pagination Info */
.pagination-info {
    padding: 1rem 1.25rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

/* ===========================
   Company Subscriptions Styling
   =========================== */

/* This section uses the same styling as Manage Company Users */
/* The .manage-users-container, .page-header, .users-section, */
/* .users-card, and .modern-table styles are shared */

/* Additional subscription-specific enhancements */
.subscription-badge-cell {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Ensure badges in subscription table match the style */
.modern-table .rz-badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    letter-spacing: 0.025em;
}

/* Date column styling */
.modern-table td span[style*="font-weight: 500"] {
    color: var(--rz-text-color, #333);
}

/* Responsive adjustments for company subscriptions */
@media (max-width: 768px) {
    .modern-table thead th:nth-child(2),
    .modern-table tbody td:nth-child(2) {
        display: none; /* Hide end date on mobile */
    }
}

@media (max-width: 576px) {
    .modern-table thead th:nth-child(3),
    .modern-table tbody td:nth-child(3) {
        display: table-cell !important; /* Keep status visible */
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .manage-users-container {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .manage-users-container {
        padding: 1rem;
    }

    .page-header {
        padding: 1.25rem 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-title {
        min-width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .header-actions .rz-button {
        flex: 1;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .section-title {
        min-width: 100%;
    }

    .search-box {
        max-width: 100%;
    }

    .modern-table {
        font-size: 0.875rem;
    }

    .modern-table thead th,
    .modern-table tbody td {
        padding: 0.875rem 0.75rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .actions-column {
        width: 120px;
    }
}

@media (max-width: 576px) {
    .manage-users-container {
        padding: 0.75rem;
    }

    .page-header {
        padding: 1rem;
        border-radius: 8px;
    }

    .users-card {
        border-radius: 8px;
    }

    .modern-table thead th {
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem;
    }

    .modern-table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    /* Stack table on very small screens */
    .modern-table thead {
        display: none;
    }

    .modern-table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        padding: 0.75rem;
    }

    .modern-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .modern-table tbody td:last-child {
        border-bottom: none;
    }

    .modern-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }

    .actions-cell {
        flex-direction: column;
    }

    .action-buttons {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Mobile overrides for ManageCompanyUsers component - global (for immediate testing) */
@media (max-width: 700px) {
  /* Ensure table transforms into cards */
  .users-card .users-table-wrapper .modern-table { width: 100% !important; border-collapse: separate !important; }
  .users-card .users-table-wrapper .modern-table thead { display: none !important; }
  .users-card .users-table-wrapper .modern-table tbody { display: block !important; }

  .users-card .users-table-wrapper .modern-table tbody tr.user-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important; /* center children horizontally */
    padding: 0.75rem !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
    border-radius: 8px !important;
    margin-bottom: 0.75rem !important;
    min-height: 88px !important;
    box-sizing: border-box !important;
    text-align: center !important; /* center text by default */
  }

  /* Make each cell normally take full width, but we'll override first/last below */
  .users-card .users-table-wrapper .modern-table tbody tr.user-row td {
    display: block !important;
    width: 100% !important;
    padding: 0.35rem 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    color: inherit !important;
    text-align: center !important;
  }

  /* For mobile, place First Name and Last Name side-by-side: columns 2 and 3 */
  .users-card .users-table-wrapper .modern-table tbody tr.user-row td:nth-child(2),
  .users-card .users-table-wrapper .modern-table tbody tr.user-row td:nth-child(3) {
    display: inline-block !important;
    width: 46% !important;
    vertical-align: top !important;
    padding: 0.35rem 1% !important;
    box-sizing: border-box !important;
    text-align: center !important;
  }

  /* Small visual spacing between the two name columns */
  .users-card .users-table-wrapper .modern-table tbody tr.user-row td:nth-child(2) { margin-right: 2% !important; }

  /* Username and icon should still be centered and full width */
  .users-card .users-table-wrapper .user-cell { display: flex !important; align-items: center !important; gap: 0.5rem !important; justify-content: center !important; font-weight: 600 !important; }
  .users-card .users-table-wrapper .user-name { max-width: 70% !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; display: inline-block !important; }

  /* Roles wrap nicely */
  .users-card .users-table-wrapper .roles-cell { display: flex !important; flex-wrap: wrap !important; gap: 0.25rem !important; margin-top: 0.25rem !important; justify-content: center !important; }

  /* Action buttons: force horizontal layout on phones */
  .users-card .users-table-wrapper .actions-cell { display: block !important; margin-top: 0.5rem !important; width: 100% !important; }
  .users-card .users-table-wrapper .action-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
    justify-content: center !important; /* center the buttons under the person */
    align-items: center !important;
    margin-top: 0.5rem !important;
    flex-wrap: nowrap !important;
  }

  /* Force Radzen button internals to be compact and inline */
  .users-card .users-table-wrapper .action-buttons .rz-button { display: inline-flex !important; align-items: center !important; justify-content: center !important; height: auto !important; padding: 0.25rem 0.5rem !important; min-width: 36px !important; }
  .users-card .users-table-wrapper .action-buttons .rz-button .rz-button-icon { margin: 0 !important; }

  /* Badges visible and inline */
  .users-card .users-table-wrapper .rz-badge { display: inline-flex !important; align-items: center !important; justify-content: center !important; }

  /* If content is long, expand row height */
  .users-card .users-table-wrapper .modern-table tbody tr.user-row.long-names { min-height: 120px !important; }
}

/* Print Styles */
@media print {
    .page-header {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .header-actions,
    .search-box,
    .action-buttons {
        display: none;
    }

    .users-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .modern-table tbody .user-row:hover {
        background: none;
        transform: none;
    }
}

/* Accessibility Improvements */
.rz-button:focus-visible,
.search-box:focus-visible {
    outline: 2px solid var(--rz-primary, #0d6efd);
    outline-offset: 2px;
}

/* Animation for loading states */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.users-section {
    animation: fadeIn 0.4s ease-out;
}

.users-section:nth-child(2) {
    animation-delay: 0.1s;
}

.users-section:nth-child(3) {
    animation-delay: 0.2s;
}

/* Company link: make it look like normal gray text (no underline, no bright colors) */
.company-link {
    color: var(--rz-text-color, #666);
    text-decoration: none;
    font-weight: 500;
}

.company-link:visited {
    color: var(--rz-text-color, #666);
}

.company-link:hover,
.company-link:focus {
    color: var(--rz-text-color, #666);
    text-decoration: none;
    outline: none;
    cursor: pointer;
}