/* ===== CSS Variables ===== */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;
    
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    
    --border-color: #E5E7EB;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    --sidebar-width: 260px;
    --topbar-height: 70px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.mobile-close {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item .icon {
    font-size: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--border-color);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.page-title {
    flex: 1;
}

.page-title h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.top-bar-actions {
    display: flex;
    gap: 12px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.btn-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.content-area {
    padding: 30px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-trend {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.stat-trend.up {
    color: var(--success);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ===== Card ===== */
.card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.link-btn {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.link-btn:hover {
    color: var(--primary-dark);
}

/* ===== Thread List ===== */
.thread-list {
    padding: 12px;
}

.thread-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius);
    transition: background 0.2s;
    cursor: pointer;
}

.thread-item:hover {
    background: var(--bg-secondary);
}

.thread-icon {
    font-size: 24px;
}

.thread-info {
    flex: 1;
    min-width: 0;
}

.thread-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.workspace-tag {
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-badge.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== Quick Actions ===== */
.quick-actions {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.action-btn:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.action-btn.primary {
    background: var(--primary-light);
    border-color: var(--primary);
}

.action-icon {
    font-size: 28px;
}

.action-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
}

.action-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Table ===== */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: 16px 24px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.file-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 20px;
}

.badge-pill {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pill.success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-pill.warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-pill.danger {
    background: #FEE2E2;
    color: #991B1B;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.success {
    background: var(--success);
}

.status-dot.processing {
    background: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-icon-sm {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon-sm:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.btn-icon-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Workspace Grid ===== */
.workspace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.workspace-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.workspace-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.workspace-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.workspace-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.workspace-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.workspace-badge.owner {
    background: var(--primary-light);
    color: var(--primary);
}

.workspace-badge.member {
    background: #FEE2E2;
    color: #991B1B;
}

.workspace-body {
    padding: 0 20px 20px;
    flex: 1;
}

.workspace-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.workspace-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.workspace-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.workspace-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.workspace-stat .stat-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.workspace-stat .stat-value {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.workspace-members {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.members-avatars {
    display: flex;
    margin-left: -4px;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: 2px solid var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    margin-left: -8px;
}

.member-avatar:first-child {
    margin-left: 0;
}

.member-avatar.more {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.members-count {
    font-size: 13px;
    color: var(--text-secondary);
}

.workspace-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.btn-workspace {
    flex: 1;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-workspace:hover {
    background: var(--primary-dark);
}

.workspace-card.create-new {
    border: 2px dashed var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workspace-card.create-new:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.create-new-content {
    text-align: center;
    padding: 40px 20px;
}

.create-new-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.create-new-content h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.create-new-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 72px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 400px;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary-large {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary-large:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-text {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    transition: all 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.btn-text:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-text:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
}

.icon-selector,
.color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.icon-option,
.color-option {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-option:hover,
.color-option:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.icon-option.selected,
.color-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: white;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 5000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success {
    background: var(--success);
}

.toast.toast-error {
    background: var(--danger);
}

.toast.toast-warning {
    background: var(--warning);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Contacts List ===== */
.contacts-list {
    display: flex;
    flex-direction: column;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.contact-item:hover {
    background: var(--bg-secondary);
}

.contact-item:last-child {
    border-bottom: none;
}

.contact-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.contact-email {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.contact-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.contact-badge {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.contact-actions {
    display: flex;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== Admin Styles ===== */

/* Nav Divider */
.nav-divider {
    padding: 16px 16px 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

.nav-divider span {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

/* Admin Badge on Avatar */
.admin-badge {
    position: relative;
}

.admin-badge::after {
    content: '⭐';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 12px;
}

.user-role {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User Cell in Tables */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-name-text {
    font-weight: 500;
}

/* Role Badges */
.role-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.admin {
    background: #FEF3C7;
    color: #92400E;
}

.role-badge.user {
    background: #E0E7FF;
    color: #3730A3;
}

/* Status Indicators */
.status-indicator {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.active {
    background: #D1FAE5;
    color: #065F46;
}

.status-indicator.suspended {
    background: #FEE2E2;
    color: #991B1B;
}

/* Thread Count */
.thread-count {
    display: flex;
    flex-direction: column;
}

.thread-count .subtext {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Suspended Row */
.suspended-row {
    opacity: 0.6;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

/* User Details Modal */
.user-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 24px;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
}

.user-detail-info h3 {
    font-size: 24px;
    margin-bottom: 4px;
}

.user-detail-info p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 15px;
    font-weight: 500;
}

/* Detail Section */
.detail-section {
    margin-bottom: 24px;
}

.detail-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Activity Stats */
.activity-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.activity-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.activity-icon {
    font-size: 24px;
}

.activity-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.activity-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Workspace List Mini */
.workspace-list-mini {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-mini-item {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 14px;
}

/* Danger Button */
.btn-danger {
    padding: 10px 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #DC2626;
}

/* Alert Cards */
.alert-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 24px;
}

.alert-card.success {
    background: #D1FAE5;
    border: 1px solid #10B981;
}

.alert-card.warning {
    background: #FEF3C7;
    border: 1px solid #F59E0B;
}

.alert-card.error {
    background: #FEE2E2;
    border: 1px solid #EF4444;
}

.alert-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Card Body Padded */
.card-body-padded {
    padding: 24px;
}

/* Form Range */
.form-range {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Code Style Textarea */
.code-style {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Form Hint */
.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checkbox-title {
    font-weight: 600;
    font-size: 14px;
}

.checkbox-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Sync Stats */
.sync-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 24px;
}

.sync-stat-item {
    text-align: center;
}

.sync-stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.sync-stat-value.success {
    color: var(--success);
}

.sync-stat-value.warning {
    color: var(--warning);
}

.sync-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Change Badges */
.change-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.change-badge.config {
    background: #E0E7FF;
    color: #3730A3;
}

.change-badge.sync {
    background: #D1FAE5;
    color: #065F46;
}

.change-badge.model {
    background: #FEF3C7;
    color: #92400E;
}

/* Compliance Modal */
.compliance-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.compliance-stat {
    text-align: center;
    padding: 24px;
    border-radius: var(--border-radius);
}

.compliance-stat.success {
    background: #D1FAE5;
}

.compliance-stat.warning {
    background: #FEF3C7;
}

.compliance-number {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 8px;
}

.compliance-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.compliance-details h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.compliance-list {
    list-style: none;
    padding: 0;
}

.compliance-list li {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    font-size: 14px;
}

/* Filter Select Small */
.filter-select-sm {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    font-size: 13px;
    cursor: pointer;
}

/* Chart Placeholder */
.chart-placeholder {
    padding: 20px;
    min-height: 250px;
}

.chart-visual {
    height: 100%;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    gap: 8px;
    margin-bottom: 12px;
}

.bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
    cursor: pointer;
}

.bar:hover {
    opacity: 0.8;
}

.bar.active {
    background: var(--primary-dark);
}

.chart-labels {
    display: flex;
    justify-content: space-around;
    font-size: 12px;
    color: var(--text-secondary);
}

/* PII Breakdown */
.pii-breakdown-grid {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pii-breakdown-item {
    display: grid;
    grid-template-columns: 180px 1fr 100px;
    align-items: center;
    gap: 16px;
}

.pii-breakdown-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.pii-icon {
    font-size: 20px;
}

.pii-breakdown-bar {
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
}

.pii-breakdown-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.pii-breakdown-value {
    text-align: right;
    font-size: 16px;
    font-weight: 700;
}

/* Activity List */
.activity-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-rank {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.activity-count {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Storage */
.storage-total {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.storage-visual {
    padding: 24px;
}

.storage-bar {
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 12px;
}

.storage-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    transition: width 0.5s ease;
}

.storage-percentage {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}

.storage-breakdown {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.storage-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.storage-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.storage-label {
    flex: 1;
    font-size: 14px;
}

.storage-size {
    font-size: 14px;
    font-weight: 600;
}

/* Health Grid */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 24px;
}

.health-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.health-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-indicator.success {
    background: var(--success);
    animation: pulse-health 2s infinite;
}

@keyframes pulse-health {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

.health-content {
    flex: 1;
}

.health-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.health-value {
    font-size: 15px;
    font-weight: 600;
}

/* ===== File Stats Bar ===== */
.file-stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.file-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-stat-item .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.file-stat-item .stat-value {
    font-size: 24px;
    font-weight: 700;
}

.file-stat-item .stat-value.danger {
    color: var(--danger);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0 16px;
}

.search-icon {
    font-size: 18px;
    margin-right: 12px;
}

.search-box .search-input {
    border: none;
    padding: 12px 0;
}

.search-box .search-input:focus {
    box-shadow: none;
}

.filter-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Files Grid ===== */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.file-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.file-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.file-card-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.file-card-icon {
    font-size: 32px;
}

.file-card-body {
    padding: 16px;
}

.file-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-meta {
    margin-bottom: 12px;
}

.file-card-stats {
    display: flex;
    gap: 16px;
}

.file-card-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.file-card-stat .stat-icon {
    font-size: 16px;
}

.file-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.file-date {
    color: var(--text-secondary);
}

.file-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.file-status.completed {
    background: #D1FAE5;
    color: #065F46;
}

.file-status.processing {
    background: #FEF3C7;
    color: #92400E;
    animation: pulse 2s infinite;
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px 20px;
    text-align: center;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.upload-area h4 {
    font-size: 18px;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-tertiary) !important;
}

.file-selected {
    padding: 20px;
}

.file-icon-large {
    font-size: 48px;
    margin-bottom: 12px;
}

.file-selected .file-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.file-selected .file-size {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
}

.pagination-btn {
    padding: 10px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-numbers {
    display: flex;
    gap: 4px;
}

.pagination-number {
    min-width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-number:hover {
    background: var(--bg-tertiary);
}

.pagination-number.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    padding: 0 8px;
    color: var(--text-tertiary);
}

/* ===== Library Specific ===== */
.library-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s;
}

.library-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.library-card-header {
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.library-card-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.library-card-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.library-card-description {
    opacity: 0.9;
    font-size: 14px;
}

.library-card-body {
    padding: 20px;
}

.library-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.library-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.library-file-item .file-icon {
    font-size: 20px;
}

.library-file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.library-card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

/* ===== Responsive Design ===== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .content-area {
        padding: 20px;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .mobile-close {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .top-bar {
        padding: 0 16px;
        height: 60px;
    }
    
    .page-title h2 {
        font-size: 20px;
    }
    
    .subtitle {
        display: none;
    }
    
    .top-bar-actions .btn-primary span:last-child {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .content-area {
        padding: 16px;
    }
    
    .dashboard-grid {
        gap: 16px;
    }
    
    .card-header {
        padding: 16px;
    }
    
    .data-table thead th,
    .data-table tbody td {
        padding: 12px 16px;
    }
    
    .data-table {
        font-size: 13px;
    }
    
    /* Hide some table columns on mobile */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3),
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        display: none;
    }
    
    /* Workspace grid mobile */
    .workspace-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* File stats bar mobile */
    .file-stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 16px;
    }
    
    .file-stat-item .stat-value {
        font-size: 20px;
    }
    
    /* Filter bar mobile */
    .filter-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .filter-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
    }
    
    /* Files grid mobile */
    .files-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* Modal mobile */
    .modal {
        padding: 0;
    }
    
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    /* Pagination mobile */
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination-numbers .pagination-number:not(.active) {
        display: none;
    }
    
    .pagination-ellipsis {
        display: none;
    }
    
    /* Contacts mobile */
    .contact-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }
    
    .contact-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    
    .contact-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .contact-meta {
        flex-direction: column;
        gap: 4px;
    }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
    .top-bar-actions .btn-icon:last-child {
        display: none;
    }
    
    .thread-meta {
        flex-direction: column;
        gap: 4px;
    }
}

