:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --font: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glassmorphism {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glassmorphism-dark {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--glass-border);
}

.view {
    display: none;
    min-height: 100vh;
}
.view.active {
    display: flex;
}

/* Auth View */
#auth-view {
    align-items: center;
    justify-content: center;
}

.auth-box {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: scale-up 0.4s ease-out;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}
.mb-4 { margin-bottom: 32px !important; }

.logo-icon {
    font-size: 32px;
    color: var(--primary);
    background: -webkit-linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-box h3 { font-size: 24px; margin-bottom: 8px; }
.auth-box .subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }

.input-group {
    text-align: left;
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}
.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.2s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.primary-btn {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
    filter: brightness(1.1);
}

.auth-hints {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Dashboard Layout */
#dashboard-view {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    padding: 32px 0;
    display: flex;
    flex-direction: column;
}
.sidebar .brand {
    padding: 0 24px;
    justify-content: flex-start;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
}
.nav-item i { font-size: 20px; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-header {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    border-radius: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.5); /* extra slight tint */
}
.top-header h1 { font-size: 24px; font-weight: 600; }

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}
.avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    border: 2px solid var(--accent);
}
.user-info { display: flex; flex-direction: column; }
.user-info span:first-child { font-weight: 500; }
.role-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border-radius: 12px;
    display: inline-block;
    align-self: flex-start;
    margin-top: 4px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px; height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.3);}

.pages-container {
    padding: 40px;
}

.page { display: none; }
.page.active { display: block; animation: fade-in 0.3s ease-out; }

/* Dashboard Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}
.metric-card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    border-top: 1px solid rgba(255,255,255,0.2); /* glossy effect top */
    transition: transform 0.2s;
}
.metric-card:hover { transform: translateY(-3px); }

.metric-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.metric-icon.blue { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.metric-icon.purple { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.metric-icon.green { background: rgba(16, 185, 129, 0.2); color: #34d399; }

.metric-info h4 { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.metric-info h2 { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.trend { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.trend.positive { color: var(--success); }
.trend.negative { color: var(--danger); }

/* Utility Classes */
.mt-2 { margin-top: 32px; }
.hidden { display: none !important; }

/* Data Tables */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.data-table-container { overflow-x: auto; border-radius: 12px; padding: 4px;}
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 18px 24px; border-bottom: 1px solid var(--glass-border); }
.data-table th { background: rgba(0,0,0,0.2); font-weight: 600; color: var(--text-muted); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.2s; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.04); }

.status-badge {
    padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-badge.new { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.status-badge.contacted { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.status-badge.converted { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }

/* Campaigns Grid */
.campaigns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.campaign-card { padding: 24px; transition: transform 0.2s; position: relative; overflow: hidden; }
.campaign-card:hover { transform: translateY(-4px); }
.campaign-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
}
.campaign-card.active::before { background: var(--success); }
.campaign-card.planning::before { background: var(--warning); }

.camp-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.camp-title { font-weight: 600; font-size: 18px; }
.camp-progress { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-top: 16px; overflow: hidden; }
.camp-bar { height: 100%; background: var(--primary); border-radius: 4px; }

/* Assets Grid */
.assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
.asset-card { border-radius: 16px; overflow: hidden; border: 1px solid var(--glass-border); transition: transform 0.2s; cursor: pointer; }
.asset-card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); }
.asset-img { height: 160px; width: 100%; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; font-size: 48px; color: var(--text-muted); transition: color 0.2s, background 0.2s; }
.asset-card:hover .asset-img { color: var(--primary); background: rgba(59,130,246,0.1); }
.asset-info { padding: 16px; background: var(--glass-bg); }
.asset-info h5 { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Activities */
.activity-list { list-style: none; padding: 24px; }
.activity-item { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); margin-bottom: 16px; }
.activity-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.activity-time { font-size: 13px; color: var(--text-muted); min-width: 70px; font-weight: 500;}

/* Animations */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-up { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.slide-up { animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

/* Topics Grid */
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.topic-card { padding: 24px; border-radius: 16px; border: 1px solid var(--glass-border); transition: transform 0.2s; position: relative; }
.topic-card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); }
.topic-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.topic-title { font-weight: 600; font-size: 16px; color: var(--text-main); }
.topic-date { font-size: 13px; color: var(--text-muted); }
.topic-status { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: rgba(59, 130, 246, 0.2); color: #93c5fd; white-space: nowrap; margin-left: 12px;}
.topic-body { font-size: 14px; color: var(--text-muted); line-height: 1.5; }

/* Users Page */
.users-container { display: flex; flex-direction: column; width: 100%; }
.user-form { display: flex; flex-direction: column; min-width: 300px; padding: 24px; position: relative;}
.users-list-area { width: 100%; padding: 24px; display: flex; flex-direction: column;}

/* MODAL OVERLAY */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none !important; }
.modal-content {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
}

.perm-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.perm-chk { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; color: var(--text-main); }
.perm-chk input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.perm-chk.admin-chk { color: var(--warning); font-weight: 600; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 8px;}

.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.user-card { padding: 20px; border-radius: 12px; background: rgba(0,0,0,0.2); border: 1px solid var(--glass-border); transition: all 0.2s; position: relative;}
.user-card:hover { transform: translateY(-4px); box-shadow: 0 8px 15px rgba(0,0,0,0.3); border-color: rgba(255,255,255,0.2); }
.user-card-header { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.user-avatar { width: 40px; height: 40px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold; }
.user-avatar.admin { background: var(--warning); color: #000; }
.user-card-title h4 { font-size: 16px; margin-bottom: 4px; color: var(--text-main); }
.user-card-title span { font-size: 12px; color: var(--text-muted); }
/* Assets Explorer */
.assets-explorer { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 20px;}
.asset-item { display: flex; flex-direction: column; align-items: center; padding: 20px 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--glass-border); border-radius: 12px; cursor: pointer; transition: all 0.2s; position: relative;}
.asset-item:hover { background: rgba(255,255,255,0.05); transform: translateY(-4px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); border-color: rgba(255,255,255,0.2);}
.asset-icon { font-size: 48px; margin-bottom: 12px; }
.asset-name { font-size: 14px; font-weight: 500; text-align: center; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main);}
.asset-date { font-size: 12px; color: var(--text-muted); margin-top: 5px;}

.asset-delete-btn { position: absolute; top: 8px; right: 8px; background: rgba(239, 68, 68, 0.2); color: #ef4444; border: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: 0.2s; }
.asset-item:hover .asset-delete-btn { opacity: 1; }
.asset-delete-btn:hover { background: #ef4444; color: #fff; }

.breadcrumbs { display: flex; align-items: center; gap: 5px; flex-wrap: wrap;}
.crumb { color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.crumb:hover { color: var(--primary); }
.crumb.active { color: var(--primary); font-weight: 600; cursor: default; }
.crumb-separator { color: rgba(255,255,255,0.2); font-size: 12px; }

/* Upload Manager Box */
.upload-manager { position: fixed; bottom: 20px; right: 20px; width: 350px; background: rgba(30, 41, 59, 0.95); border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 1000; overflow: hidden; backdrop-filter: blur(10px); display: flex; flex-direction: column; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.upload-manager.hidden { transform: translateY(120%); }
.um-header { padding: 12px 16px; background: rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center; cursor: pointer; border-bottom: 1px solid var(--glass-border); }
.um-header h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-main); }
.um-actions { display: flex; gap: 10px; color: var(--text-muted); }
.um-actions i { cursor: pointer; transition: 0.2s; }
.um-actions i:hover { color: var(--primary); }
.um-body { max-height: 250px; overflow-y: auto; transition: max-height 0.3s; }
.um-body.collapsed { max-height: 0; }
.um-list { padding: 0; margin: 0; list-style: none; display: flex; flex-direction: column; }
.um-item { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; gap: 12px; position: relative; }
.um-item:last-child { border-bottom: none; }
.um-icon { font-size: 24px; color: var(--text-muted); }
.um-info { flex: 1; overflow: hidden; }
.um-name { font-size: 13px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.um-progress-text { font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }
.um-bar-bg { width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.um-bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s ease; }
.um-status-icon { font-size: 18px; }
.um-status-icon.success { color: var(--success); }
.um-status-icon.error { color: var(--error); }
.user-action-btns { position: absolute; top: 15px; right: 15px; display: flex; gap: 8px; }
.user-btn { background: none; border: none; font-size: 18px; opacity: 0.5; transition: opacity 0.2s; cursor: pointer; }
.user-btn.edit { color: var(--primary); }
.user-btn.delete { color: var(--danger); }
.user-btn:hover { opacity: 1; }
.user-perms-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.user-tag { background: rgba(59, 130, 246, 0.2); color: #93c5fd; padding: 4px 8px; border-radius: 4px; font-size: 11px; }
.user-tag.admin-tag { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

/* Password Form Fields */
.pwd-wrapper { position: relative; display: block; }
.toggle-pwd { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); font-size: 20px; color: var(--text-muted); cursor: pointer; transition: color 0.2s;}
.toggle-pwd:hover { color: var(--text-main); }
.pwd-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* Campaign Brief Enhancements */
.camp-tagline { font-size: 14px; font-weight: 600; color: #8b5cf6; font-style: italic; margin-bottom: 12px; }
.camp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.camp-grid-item { background: rgba(255, 255, 255, 0.05); padding: 8px; border-radius: 6px; display: flex; flex-direction: column; }
.item-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; }
.item-value { font-size: 13px; color: var(--text-main); }
.camp-toggle-box details { background: rgba(0, 0, 0, 0.2); border-radius: 6px; }
.camp-toggle-box summary { padding: 10px; font-size: 13px; color: #94a3b8; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.camp-toggle-box summary::-webkit-details-marker { display: none; }
.camp-toggle-box summary:hover { color: var(--text-main); }
.camp-details { padding: 0 10px 10px 10px; font-size: 13px; color: #cbd5e1; border-top: 1px solid rgba(255,255,255,0.05); margin-top: 5px; padding-top: 10px; }
.camp-details p { margin-bottom: 8px; line-height: 1.5; }
.camp-details p:last-child { margin-bottom: 0; }
.camp-details strong { color: var(--text-main); }
