/**
 * FABIQ 管理面板样式
 * Admin Dashboard Styles
 * Version 1.0
 * 复用 newquote 样式体系
 */

/* ===== CSS Variables ===== */
:root {
    /* Primary Colors */
    --primary-color: #1a2b4a;
    --primary-light: #2d4a7c;
    --primary-dark: #0f1a2e;
    
    /* Accent Colors */
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #60a5fa;
    
    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Neutral Colors */
    --bg-color: #f0f4f8;
    --bg-dark: #e2e8f0;
    --card-bg: #ffffff;
    --sidebar-bg: #1a2b4a;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #ffffff;
    
    /* Border */
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    
    /* Spacing */
    --sidebar-width: 240px;
    --header-height: 64px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent-color); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--accent-hover); }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }

/* ===== Layout ===== */
.app-container { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg); color: var(--text-light);
    display: flex; flex-direction: column; z-index: 1000;
    transition: var(--transition);
}
.sidebar-header {
    padding: 20px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo-img { height:44px; width:auto; object-fit:contain; }
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
    padding: 0 20px; margin-bottom: 8px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.4);
}
.nav-item {
    display: flex; align-items: center; padding: 12px 20px;
    color: rgba(255,255,255,0.7); transition: var(--transition-fast); cursor: pointer; gap: 12px;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: var(--text-light); }
.nav-item.active {
    background: rgba(59,130,246,0.2); color: var(--accent-light);
    border-right: 3px solid var(--accent-color);
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item span { flex: 1; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-color); display: flex; align-items: center;
    justify-content: center; font-weight: 600;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* ===== Main Content ===== */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

/* ===== Header ===== */
.main-header {
    height: var(--header-height); background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.mobile-menu-btn { display: none; padding: 8px; font-size: 20px; color: var(--text-secondary); background: transparent; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-btn {
    padding: 8px 12px; background: transparent; color: var(--text-secondary);
    border-radius: var(--border-radius); transition: var(--transition-fast); position: relative;
}
.header-btn:hover { background: var(--bg-color); color: var(--text-primary); }
.user-dropdown-btn {
    display: flex; align-items: center; gap: 8px; padding: 6px 12px;
    background: var(--bg-color); border-radius: var(--border-radius);
    cursor: pointer; transition: var(--transition-fast);
}
.user-dropdown-btn:hover { background: var(--bg-dark); }

/* ===== Page Content ===== */
.page-content { flex: 1; padding: 24px; }

/* ===== Cards ===== */
.card {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }

/* ===== Stats Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    padding: 20px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--border-radius);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-icon.blue { background: rgba(59,130,246,0.1); color: var(--accent-color); }
.stat-icon.green { background: rgba(16,185,129,0.1); color: var(--success-color); }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: var(--warning-color); }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-icon.red { background: rgba(239,68,68,0.1); color: var(--danger-color); }
.stat-icon.cyan { background: rgba(6,182,212,0.1); color: var(--info-color); }
.stat-content { flex: 1; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; font-size: 14px; font-weight: 500;
    border-radius: var(--border-radius); transition: var(--transition-fast); cursor: pointer; border: none;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--accent-color); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-color); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-dark); }
.btn-success { background: var(--success-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-color); border-color: var(--text-muted); }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-label.required::after { content: '*'; color: var(--danger-color); margin-left: 4px; }
.form-control {
    width: 100%; padding: 10px 14px; font-size: 14px;
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    background: var(--card-bg); color: var(--text-primary); transition: var(--transition-fast);
}
.form-control:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg-color); cursor: not-allowed; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

/* ===== Tables ===== */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.table th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); background: var(--bg-color); }
.table tbody tr:hover { background: var(--bg-color); }
.table td.actions { white-space: nowrap; }
.table-actions { display: flex; gap: 8px; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: 20px; }
.badge-active, .badge-approved { background: rgba(16,185,129,0.1); color: var(--success-color); }
.badge-pending { background: rgba(245,158,11,0.1); color: var(--warning-color); }
.badge-disabled { background: rgba(100,116,139,0.1); color: var(--text-muted); }
.badge-deleted, .badge-rejected { background: rgba(239,68,68,0.1); color: var(--danger-color); }
.badge-SITE_OWNER { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.badge-SITE_ADMIN { background: rgba(59,130,246,0.1); color: var(--accent-color); }
.badge-ORG_ADMIN { background: rgba(6,182,212,0.1); color: var(--info-color); }
.badge-USER { background: rgba(100,116,139,0.1); color: var(--text-secondary); }

/* ===== Search ===== */
.search-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input-wrapper { position: relative; flex: 1; min-width: 250px; }
.search-input-wrapper i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrapper input { padding-left: 40px; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; }
.pagination-btn {
    padding: 8px 12px; font-size: 14px; background: var(--card-bg);
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    color: var(--text-primary); cursor: pointer; transition: var(--transition-fast);
}
.pagination-btn:hover:not(:disabled) { background: var(--bg-color); }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-btn.active { background: var(--accent-color); color: white; border-color: var(--accent-color); }
.pagination-info { font-size: 13px; color: var(--text-secondary); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 500px; max-height: 90vh;
    overflow: hidden; transform: translateY(-20px); transition: var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-lg { max-width: 800px; }
.modal-header {
    padding: 20px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--border-radius); background: transparent; color: var(--text-secondary);
    font-size: 20px; cursor: pointer;
}
.modal-close:hover { background: var(--bg-color); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; max-height: calc(90vh - 140px); }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 12px; padding: 14px 20px;
    background: var(--card-bg); border-radius: var(--border-radius); box-shadow: var(--shadow-lg);
    min-width: 300px; max-width: 450px; transform: translateX(100%); opacity: 0;
    animation: slideIn 0.3s ease forwards;
}
@keyframes slideIn { to { transform: translateX(0); opacity: 1; } }
.toast.hiding { animation: slideOut 0.3s ease forwards; }
@keyframes slideOut { to { transform: translateX(100%); opacity: 0; } }
.toast-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-success .toast-icon { background: rgba(16,185,129,0.1); color: var(--success-color); }
.toast-error .toast-icon { background: rgba(239,68,68,0.1); color: var(--danger-color); }
.toast-warning .toast-icon { background: rgba(245,158,11,0.1); color: var(--warning-color); }
.toast-info .toast-icon { background: rgba(59,130,246,0.1); color: var(--accent-color); }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-message { font-size: 13px; color: var(--text-secondary); }
.toast-close { padding: 4px; background: transparent; color: var(--text-muted); cursor: pointer; }

/* ===== Loading ===== */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.8);
    display: flex; align-items: center; justify-content: center; z-index: 2500;
}
.spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 12px; font-size: 14px; color: var(--text-secondary); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

/* ===== No Auth Banner ===== */
.no-auth-banner {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b; border-radius: var(--border-radius);
    padding: 12px 20px; margin: 0 24px 16px 24px; color: #92400e; font-size: 14px;
}
.no-auth-banner i { font-size: 18px; color: #f59e0b; }
.no-auth-banner .btn { margin-left: auto; padding: 6px 16px; font-size: 13px; }

/* ===== Dashboard Grid ===== */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.tab-item {
    padding: 12px 20px; font-size: 14px; font-weight: 500;
    color: var(--text-secondary); background: transparent; border: none; cursor: pointer;
    transition: var(--transition-fast); position: relative;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--accent-color); }
.tab-item.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
    height: 2px; background: var(--accent-color);
}

/* ===== Profile Page ===== */
.profile-layout { max-width: 800px; }
.profile-header-section {
    display: flex; align-items: center; gap: 20px;
}
.profile-meta h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-header {
    display: flex; align-items: center; gap: 24px; margin-bottom: 32px;
    padding: 24px; background: var(--card-bg); border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
}
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%; background: var(--accent-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 700; color: white; flex-shrink: 0;
}
.profile-info h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-info p { color: var(--text-secondary); font-size: 14px; }
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--border-color);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 14px; color: var(--text-secondary); }
.detail-value { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* ===== Quick Links ===== */
.quick-links {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px;
}
.quick-link-item {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 8px; border-radius: var(--border-radius);
    background: var(--bg-color); text-decoration: none; color: var(--text-primary);
    transition: var(--transition); font-size: 13px; text-align: center;
}
.quick-link-item:hover { background: var(--accent-color); color: white; }
.quick-link-item i { font-size: 24px; }

/* ===== Service Permission Toggle ===== */
.service-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.service-toggle:last-child { border-bottom: none; }
.service-toggle-info { flex: 1; }
.service-toggle-name { font-weight: 600; font-size: 14px; }
.service-toggle-desc { font-size: 12px; color: var(--text-secondary); }
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 24px; transition: var(--transition-fast);
}
.toggle-slider::before {
    content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: var(--transition-fast);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-color); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== Add button inline ===== */
.input-with-add { display: flex; gap: 8px; align-items: center; }
.input-with-add .form-control { flex: 1; }
.btn-add-inline {
    width: 38px; height: 38px; border-radius: var(--border-radius);
    background: var(--accent-color); color: white; display: flex;
    align-items: center; justify-content: center; font-size: 16px;
    cursor: pointer; border: none; transition: var(--transition-fast); flex-shrink: 0;
}
.btn-add-inline:hover { background: var(--accent-hover); }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .search-bar { flex-direction: column; }
    .search-input-wrapper { min-width: 100%; }
    .modal { margin: 20px; }
    .profile-header { flex-direction: column; text-align: center; }
    .profile-header-section { flex-direction: column; text-align: center; }
}
@media (max-width: 576px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .card-body { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
}
