/* =====================
   Reset
   ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #222;
    overflow: hidden;
}

/* =====================
   App Shell
   ===================== */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    width: 100%;
}

.body-layout {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    height: calc(100vh - 48px);
}

/* =====================
   Top Header
   ===================== */
.top-header {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    background-color: #e8e8e8;
    border-bottom: 1px solid #d0d0d0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 0;
    z-index: 200;
    flex-shrink: 0;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    overflow: hidden;
}

.header-logo {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    flex-shrink: 0;
}

.header-logo-img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.header-app-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.header-icon-btn {
    font-size: 15px;
    color: #555;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

    .header-icon-btn:hover {
        background: rgba(0, 0, 0, 0.08);
    }

.header-divider {
    width: 1px;
    height: 20px;
    background: #ccc;
    margin: 0 4px;
    flex-shrink: 0;
}

.header-login-btn {
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: none;
    color: #444;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

    .header-login-btn:hover {
        background: rgba(0, 0, 0, 0.06);
        text-decoration: none;
    }

.header-register-btn {
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid #6b5fe6;
    background: #6b5fe6;
    color: #fff;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

    .header-register-btn:hover {
        background: #5a4fd4;
        text-decoration: none;
    }

.hamburger-btn {
    display: none !important;
    background: none !important;
    border: none !important;
    font-size: 22px !important;
    color: #444 !important;
    cursor: pointer !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

@media (max-width: 768px) {

    .hamburger-btn {
        display: flex !important;
    }

    .header-icon-btn,
    .header-divider,
    .avatar-name,
    .avatar-chevron,
    .header-login-btn,
    .header-register-btn {
        display: none !important;
    }

    .sidebar {
        position: fixed !important;
        top: 48px !important;
        left: 0 !important;
        width: 200px !important;
        max-width: 200px !important;
        height: calc(100vh - 48px) !important;
        transform: translateX(-100%) !important;
        z-index: 150 !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15) !important;
        transition: transform 0.25s ease !important;
    }

        .sidebar.mobile-open {
            transform: translateX(0) !important;
        }

    .mobile-overlay {
        display: block !important;
    }

    .sidebar-nav-item {
        flex-direction: row !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        padding: 12px 16px !important;
        min-height: unset !important;
        border-left: none !important;
    }

        .sidebar-nav-item.active {
            border-left: 3px solid #6b5fe6 !important;
        }

    .nav-text {
        font-size: 13px !important;
    }

    .page-content {
        padding: 16px !important;
    }
}

/* =====================
   Avatar Dropdown
   ===================== */
.avatar-wrapper {
    position: relative;
}

.avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    color: #444;
}

    .avatar-btn:hover {
        background: rgba(0, 0, 0, 0.06);
    }

.avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #6b5fe6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 16px;
}

.avatar-name {
    font-size: 13px;
    font-weight: 500;
    color: #444;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-chevron {
    font-size: 10px;
    color: #888;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
}

    .avatar-chevron.rotated {
        transform: rotate(180deg);
    }

.avatar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 500;
    overflow: hidden;
    animation: fadeInDown 0.15s ease;
}

.avatar-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #fafafa;
}

.avatar-dropdown-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #6b5fe6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 20px;
}

.avatar-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.avatar-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-dropdown-email {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-dropdown-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 2px 0;
}

.avatar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: #444;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
}

    .avatar-dropdown-item:hover {
        background: #f5f5f5;
        color: #222;
        text-decoration: none;
    }

    .avatar-dropdown-item.logout {
        color: #dc3545;
    }

        .avatar-dropdown-item.logout:hover {
            background: #fff5f5;
        }

.avatar-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 499;
}

/* =====================
   Role Badges
   ===================== */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.role-badge-admin {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

.role-badge-manager {
    background: rgba(255, 152, 0, 0.12);
    color: #e65100;
}

.role-badge-user {
    background: rgba(107, 95, 230, 0.12);
    color: #6b5fe6;
}

/* =====================
   Status Badges
   ===================== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge-active {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.status-badge-inactive {
    background: rgba(156, 163, 175, 0.15);
    color: #6b7280;
}

/* =====================
   Sidebar
   ===================== */
.sidebar {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0f0f0;
    border-right: 1px solid #d8d8d8;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    padding: 8px 0;
}

/* =====================
   Sidebar Nav
   ===================== */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    gap: 2px;
    width: 100%;
}

.sidebar-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 2px;
    width: 100%;
    color: #555;
    text-decoration: none;
    text-align: center;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
    min-height: 52px;
}

    .sidebar-nav-item:hover {
        background: rgba(0, 0, 0, 0.06);
        color: #222;
        text-decoration: none;
    }

    .sidebar-nav-item.active {
        background: rgba(107, 95, 230, 0.08);
        border-left: 3px solid #6b5fe6;
        color: #6b5fe6;
    }

.nav-text {
    font-size: 9px;
    line-height: 1.2;
    white-space: nowrap;
    color: inherit;
}

.sidebar-divider {
    height: 1px;
    width: 36px;
    background: #d8d8d8;
    margin: 6px auto;
}

/* =====================
   Page Content
   ===================== */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #ffffff;
    min-width: 0;
    min-height: 0;
}

/* =====================
   Landing Layout
   ===================== */
.landing-layout {
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* =====================
   Mobile Overlay
   ===================== */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
}

/* =====================
   Animations
   ===================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================
   Spinner
   ===================== */
.spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #6b5fe6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* =====================
   Blazor Error UI
   ===================== */
#blazor-error-ui {
    background: #ffcc00;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* =====================
   intl-tel-input — stretch to fill its parent container
   ===================== */
.iti {
    width: 100%;
}

/* =====================
   Override Blazor defaults
   ===================== */
.top-row {
    display: none !important;
}

.page {
    display: unset !important;
    position: unset !important;
    background-image: none !important;
}

/* =====================
   Responsive — Mobile
   ===================== */

/* =====================
   Modal Overlay
   ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 560px;
    position: relative;
    animation: fadeInDown 0.2s ease;
    max-height: none;
    overflow-y: visible;
    flex-shrink: 0;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 16px;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 1;
}

    .modal-close:hover {
        background: #f0f0f0;
        color: #333;
    }

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    text-align: center;
}

.modal-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.modal-tagline {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

    .modal-field label {
        font-size: 13px;
        font-weight: 500;
        color: #444;
    }

.modal-input {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    color: #222;
    background: #fff;
}

    .modal-input:focus {
        border-color: #6b5fe6;
        box-shadow: 0 0 0 3px rgba(107, 95, 230, 0.1);
    }

    .modal-input:disabled {
        background: #f5f5f5;
        color: #888;
    }

.modal-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.modal-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
}

    .modal-remember input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: #6b5fe6;
    }

.modal-link {
    color: #6b5fe6;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

    .modal-link:hover {
        text-decoration: underline;
    }

.modal-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    background: #6b5fe6;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 44px;
}

    .modal-submit-btn:hover {
        background: #5a4fd4;
    }

    .modal-submit-btn:disabled {
        opacity: 0.7;
        cursor: not-allowed;
    }

.modal-footer-text {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin: 0;
}

.modal-description {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin: 0;
}

.modal-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.modal-alert-danger {
    background: rgba(220, 53, 69, 0.08);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.modal-alert-success {
    background: rgba(22, 163, 74, 0.08);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.modal-success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(107, 95, 230, 0.1);
    color: #6b5fe6;
    font-size: 28px;
    margin: 0 auto;
}

@media (max-width: 480px) {
    .modal-box {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .modal-box-sm {
        min-height: 480px;
    }

    .modal-form-row {
        grid-template-columns: 1fr;
    }
}