:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --light-color: #f1f5f9;
    --border-color: #e2e8f0;
    --text-color: #334155;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
    background: var(--light-color);
    line-height: 1.6;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

/* Header */
.header {
    background: #fff;
    padding: 15px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Force transparent on ALL logo and image elements */
* .logo, * .logo img, .header-content img, 
[style*="SignVisionlogo"] {
    background: none !important;
    background-color: transparent !important;
    -webkit-background-fill-color: transparent !important;
    background-image: none !important;
}

.header-content > div:first-child { background: transparent !important; background-color: rgba(0,0,0,0) !important; }
.header-content > div:first-child img { background: transparent !important; -webkit-background-fill-color: transparent; }
.logo img, .logo div { background: transparent !important; }

.logo { display: flex; align-items: center; height: 40px; background: transparent !important; }
.logo img { height: 40px; width: auto; background: transparent !important; border: none; outline: none; }
.logo img[style*="display: none"] + span { display: inline !important; font-size: 24px; font-weight: 700; color: var(--primary-color); } 
.logo span { display: none; color: var(--secondary-color); }

.nav-menu { display: flex; gap: 5px; list-style: none; flex-wrap: wrap; }
.nav-menu a { color: var(--text-color); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); transition: all 0.3s; font-size: 14px; white-space: nowrap; }
.nav-menu a:hover, .nav-menu a.active { background: var(--primary-color); color: #fff; }

/* Mobile Responsive */
@media (max-width: 992px) {
    .header-content { flex-wrap: wrap; gap: 10px; }
    .nav-menu { 
        display: none; 
        width: 100%; 
        max-height: 300px; 
        overflow-y: auto;
        background: #fff;
        padding: 10px;
        box-shadow: var(--shadow);
        order: 3;
    }
    .nav-menu.show { display: flex; flex-wrap: wrap; gap: 5px; }
    .menu-toggle { display: block; font-size: 24px; cursor: pointer; padding: 5px 10px; background: var(--primary-color); color: #fff; border-radius: var(--radius); }
    .nav-menu li { min-width: calc(50% - 5px); }
    .nav-menu a { display: block; text-align: center; }
}
@media (min-width: 993px) {
    .menu-toggle { display: none; }
}

/* Dashboard Layout */
.dashboard { display: flex; min-height: calc(100vh - 70px); }
.sidebar { width: 250px; background: var(--dark-color); padding: 20px 0; }
.sidebar-menu { list-style: none; }
.sidebar-menu a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: rgba(255,255,255,0.7); text-decoration: none; transition: all 0.3s; }
.sidebar-menu a:hover, .sidebar-menu a.active { background: rgba(255,255,255,0.1); color: #fff; border-left: 3px solid var(--primary-color); }
.sidebar-menu i { width: 20px; text-align: center; }

/* Mobile sidebar */
@media (max-width: 768px) {
    .dashboard { flex-direction: column; }
    .sidebar { width: 100%; padding: 10px; }
    .sidebar-menu { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
    .sidebar-menu a { padding: 8px 12px; font-size: 14px; }
    .sidebar-menu span { display: none; }
    .main-content { padding: 15px; }
}

.main-content { flex: 1; padding: 30px; }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: #fff; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary-color); }
.stat-card .label { color: var(--text-muted); font-size: 14px; }
.stat-card.success .value { color: var(--success-color); }
.stat-card.warning .value { color: var(--warning-color); }

/* Cards */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { font-size: 18px; font-weight: 600; }
.card-body { padding: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius); font-weight: 500; text-decoration: none; cursor: pointer; transition: all 0.3s; border: none; font-size: 14px; }
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-success { background: var(--success-color); color: #fff; }
.btn-warning { background: var(--warning-color); color: #fff; }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-outline { border: 2px solid var(--primary-color); background: transparent; color: var(--primary-color); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; }
.form-control { width: 100%; padding: 10px 15px; border: 2px solid var(--border-color); border-radius: var(--radius); font-size: 14px; transition: border-color 0.3s; }
.form-control:focus { outline: none; border-color: var(--primary-color); }
select.form-control { cursor: pointer; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; position: relative; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); position: relative; }
.data-table th { background: var(--light-color); font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.data-table tr:hover { background: var(--light-color); }
.data-table td .btn { position: relative; z-index: 1; }

/* Status Badges */
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-badge.online { background: #dcfce7; color: #166534; }
.status-badge.offline { background: #fee2e2; color: #991b1b; }
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.downloaded { background: #dbeafe; color: #1e40af; }

/* Alerts */
.alert { padding: 15px 20px; border-radius: var(--radius); margin-bottom: 20px; }
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success-color); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger-color); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning-color); }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); }

/* Content Grid */
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; padding: 10px 0; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: #fff; padding: 30px; border-radius: var(--radius); max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; }

/* Layout Preview */
.layout-preview { display: grid; gap: 10px; padding: 20px; background: #000; border-radius: var(--radius); min-height: 300px; }
.layout-fullscreen { grid-template: 1fr / 1fr; }
.layout-split-2x1 { grid-template: 1fr / 1fr 1fr; }
.layout-split-2x2 { grid-template: 1fr 1fr / 1fr 1fr; }
.layout-split-3x1 { grid-template: 1fr / 1fr 1fr 1fr; }
.layout-split-3x2 { grid-template: 1fr 1fr / 1fr 1fr 1fr; }
.layout-item { background: #333; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; }

/* Footer */
.footer { background: #fff; padding: 20px 0; text-align: center; color: var(--text-muted); border-top: 1px solid var(--border-color); margin-top: 40px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar-menu a span { display: none; }
    .sidebar-menu a { justify-content: center; }
    .nav-menu { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table th { background: var(--light-color); font-weight: 600; color: var(--text-color); white-space: nowrap; }
.table tr:hover td { background: #f8fafc; }
.table td:last-child { white-space: nowrap; }

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
}
.drag-handle:active {
    cursor: grabbing;
}
tr.dragging {
    opacity: 0.5;
}
tr.drag-over td {
    border-top: 2px solid var(--primary-color);
}

/* Indeterminate progress bar for sanitization phase */
#uploadProgressBar.indeterminate {
    width: 100% !important;
    background: linear-gradient(90deg, #2563eb, #7c3aed, #2563eb) !important;
    background-size: 200% 100% !important;
    animation: progress-indeterminate 1.5s ease infinite;
}
@keyframes progress-indeterminate {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Disabled modal close during upload processing */
.modal-close:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Upload status processing state */
.upload-status-processing {
    color: #7c3aed !important;
    font-weight: 600 !important;
}

/* Group Sidebar */
.groups-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.groups-sidebar h4 {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.group-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.group-tree li {
    list-style: none;
}

.group-tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    color: var(--text-color);
    user-select: none;
}

.group-tree-item:hover {
    background: var(--light-color);
}

.group-tree-item.active {
    background: #dbeafe;
    color: var(--primary-color);
    font-weight: 600;
}

.group-tree-item .tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.15s;
}

.group-tree-item .tree-toggle.expanded {
    transform: rotate(90deg);
}

.group-tree-item .tree-toggle.no-children {
    visibility: hidden;
}

.group-tree-item .group-icon {
    color: var(--text-muted);
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.group-tree-item .group-icon.active-icon {
    color: var(--primary-color);
}

.group-tree-item .group-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-tree-item .group-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--light-color);
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.group-tree-item .group-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}

.group-tree-item:hover .group-actions {
    display: flex;
}

.group-tree-item .group-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    color: var(--text-muted);
    border-radius: 3px;
    transition: all 0.15s;
}

.group-tree-item .group-actions button:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

.group-tree-item .group-actions button.delete-btn:hover {
    color: var(--danger-color);
}

.group-tree-children {
    padding-left: 24px;
}

.group-tree-item.drag-over {
    background: #dbeafe;
    outline: 2px dashed var(--primary-color);
    outline-offset: -2px;
}

/* Group badge on client cards */
.group-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--primary-color);
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.group-badge i {
    font-size: 10px;
}

/* Override badge on client cards */
.override-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #d97706;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    margin-left: 5px;
}

.override-badge i {
    font-size: 10px;
}

/* Add group button */
.add-group-btn {
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.add-group-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--light-color);
}

/* Client card drag styling */
.client-card {
    cursor: grab;
}

.client-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Client drop zone indicator */
.client-drop-zone {
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    margin: 10px 0;
}

/* Responsive sidebar */
@media (max-width: 992px) {
    .groups-sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
    }
}
