/* UNUMS - Unified Custom Styles for Admin & Tenant (Tailwind CSS) */
/* 此文件包含总后台和租户端的统一自定义样式，与Tailwind CSS配合使用 */

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    min-width: 300px;
    padding: 1rem 1.5rem;
    border-radius: 0.375rem;
    background: #1f2937;
    color: white;
    display: none;
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.toast.show {
    display: block;
}

.toast.success {
    background: #059669;
}

.toast.error {
    background: #dc2626;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Input with Icon */
.input-group {
    position: relative;
}

.input-group .material-icons {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    font-size: 18px;
}

.input-with-icon {
    padding-left: 2.5rem !important;
}

/* Password Toggle */
.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #9ca3af;
    user-select: none;
    font-size: 20px;
}

.toggle-password:hover {
    color: #6b7280;
}

/* Button Loading State */
.btn-loading .spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Frame Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Sidebar Active State */
.sidebar-item.active {
    background-color: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}

.sidebar-item:hover {
    background-color: #f3f4f6;
}

.sidebar-item.active:hover {
    background-color: #dbeafe;
}

/* Sidebar Overlay for Mobile - Smooth Animation */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Smooth Transition */
#main-sidebar {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: 32rem;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUpModal 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpModal {
    from {
        transform: translateY(2rem);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Grid.js Table Custom Styles */
.gridjs-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.gridjs-th {
    background: #f9fafb !important;
    color: #6b7280 !important;
    font-weight: 600 !important;
    padding: 0.75rem 1rem !important;
    border-bottom: 2px solid #e5e7eb !important;
}

.gridjs-td {
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid #f3f4f6 !important;
    color: #374151 !important;
}

.gridjs-tr:hover .gridjs-td {
    background: #f9fafb !important;
}

.gridjs-pagination {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
}

.gridjs-pagination .gridjs-pages button {
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.gridjs-pagination .gridjs-pages button:hover:not(:disabled) {
    background: #f3f4f6;
}

.gridjs-pagination .gridjs-pages button.gridjs-currentPage {
    background: #2563eb !important;
    color: white !important;
    border-color: #2563eb;
}

.gridjs-pagination .gridjs-pages button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Action Icons */
.action-icon {
    cursor: pointer;
    transition: all 0.2s;
}

.action-icon:hover {
    color: #2563eb;
    transform: scale(1.1);
}

/* Reduced Border Radius for Cards */
.card-sm {
    border-radius: 0.5rem;
}

.card-md {
    border-radius: 0.75rem;
}

/* ==================== Tenant-Specific Styles ==================== */
/* 租户端顶部头像菜单 */
.tenant-avatar-menu {
    position: relative;
}

.tenant-avatar-btn {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tenant-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tenant-avatar-btn:hover .tenant-avatar-circle {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 租户信息卡片 */
.tenant-info-card {
    position: fixed;
    top: 64px;
    right: 16px;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tenant-info-card.tenant-card-show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.tenant-card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tenant-card-overlay.show {
    opacity: 1;
    visibility: visible;
}

.tenant-card-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tenant-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.tenant-card-info {
    flex: 1;
    min-width: 0;
}

.tenant-card-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tenant-card-id {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.tenant-card-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0 12px;
}

/* Sidebar Drawer */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 260px;
    background: white;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.drawer-header img {
    height: 48px;
    margin: 0 auto;
}

.drawer-nav {
    padding: 12px 0;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.2s ease;
}

.drawer-item:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.drawer-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.drawer-item .material-icons {
    font-size: 20px;
}

.drawer-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 16px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .tenant-info-card {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    
    .tenant-info-card.tenant-card-show {
        transform: translateY(0);
    }
}

/* Dashboard Stats Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px !important;
}

.stat-icon.blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.stat-icon.green { background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%); color: white; }
.stat-icon.orange { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); color: white; }
.stat-icon.purple { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); color: #6b21a8; }
.stat-icon.red { background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%); color: white; }
.stat-icon.indigo { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; }
.stat-icon.teal { background: linear-gradient(135deg, #0ba360 0%, #3cba92 100%); color: white; }
.stat-icon.pink { background: linear-gradient(135deg, #f857a6 0%, #ff5858 100%); color: white; }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 12px 0 4px 0;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

.stat-subtitle {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

/* Beta Badge */
.beta-badge {
    display: inline-block;
    padding: 2px 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ==================== Global Page Loader ==================== */
/* 全局页面加载遮罩 */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#page-loader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    position: relative;
    animation: float 3s ease-in-out infinite;
}

.loader-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.loader-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    border: 4px solid rgba(0, 0, 0, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    color: #2563eb;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.loader-subtext {
    color: #2563eb;
    font-size: 13px;
    font-weight: 400;
}

.loader-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
}

.loader-dots span {
    width: 4px;
    height: 4px;
    background: #2563eb;
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 简化版加载遮罩（用于内容区域） */
.content-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.content-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.content-loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

