/* =================================================== */
/* ==      UPGRADED DARKNODE DASHBOARD STYLES        == */
/* =================================================== */

/* --- FONT & COLOR VARIABLES (THEME CONTROL) --- */
:root {
    --font-family: 'Poppins', sans-serif;
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-blue: #2c3e50;
    
    /* Light Theme */
    --bg-color: #f4f7f6;
    --sidebar-bg: linear-gradient(160deg, #2c3e50, #34495e);
    --topbar-bg: rgba(255, 255, 255, 0.7);
    --widget-bg: #ffffff;
    --text-color: #34495e;
    --text-muted: #7f8c8d;
    --border-color: #ecf0f1;
    --shadow-color: rgba(44, 62, 80, 0.1);
}

body.dark-theme {
    /* Dark Theme */
    --bg-color: #1e2833;
    --sidebar-bg: linear-gradient(160deg, #131a20, #1a232c);
    --topbar-bg: rgba(26, 35, 44, 0.7);
    --widget-bg: #2c3a47;
    --text-color: #ecf0f1;
    --text-muted: #95a5a6;
    --border-color: #3a4b5a;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* --- BASE STYLES --- */
* { box-sizing: border-box; }
body {
    background: var(--bg-color);
    font-family: var(--font-family);
    color: var(--text-color);
    margin: 0;
    display: flex;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 25px;
    border-right: 1px solid var(--border-color);
    transition: background 0.3s;
}
.brand {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo { height: 40px; border-radius: 50%; }
.menu { list-style: none; padding: 0; }
.menu li {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 500;
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.menu li.active, .menu li:hover {
    background: var(--primary-color);
    color: #fff;
}
.sidebar-footer { margin-top: auto; }
.user-profile { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.user-profile i { font-size: 2.5em; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; }
.user-role { font-size: 0.8em; opacity: 0.7; }
.logout-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); }

/* --- MAIN DASHBOARD AREA --- */
.dashboard-main { flex: 1; display: flex; flex-direction: column; }

/* --- TOP BAR --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}
.welcome-message {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-color);
}
.topbar-actions { display: flex; align-items: center; gap: 20px; font-size: 1.3em; }
.topbar-actions .fa-bell { color: var(--warning-color); animation: bell-shake 1.5s infinite; }
@keyframes bell-shake { 0%,100%{transform:rotate(0);} 10%,30%,50%{transform:rotate(-15deg);} 20%,40%{transform:rotate(15deg);} }

/* --- THEME TOGGLE SWITCH --- */
.theme-toggle-container {
    display: flex;
    align-items: center;
}

.theme-toggle-checkbox { 
    display: none; 
}

.theme-toggle-label {
    display: block;
    position: relative;
    width: 50px;
    height: 26px;
    background: var(--dark-blue);
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

.theme-toggle-label::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 4px;
    transition: transform 0.3s;
}

.theme-toggle-checkbox:checked + .theme-toggle-label { 
    background: var(--primary-color); 
}

.theme-toggle-checkbox:checked + .theme-toggle-label::after { 
    transform: translateX(23px); 
}

.theme-toggle-label .fa-moon, .theme-toggle-label .fa-sun {
    position: absolute;
    color: #fff;
    font-size: 0.9em;
    transition: opacity 0.3s;
}

.theme-toggle-label .fa-moon { left: 7px; top: 6px; }
.theme-toggle-label .fa-sun { right: 7px; top: 6px; opacity: 0; }
.theme-toggle-checkbox:checked + .theme-toggle-label .fa-moon { opacity: 0; }
.theme-toggle-checkbox:checked + .theme-toggle-label .fa-sun { opacity: 1; }

/* --- WIDGETS --- */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    grid-auto-rows: minmax(200px, auto);
    gap: 30px;
    padding: 30px;
}
.widget {
    background: var(--widget-bg);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px var(--shadow-color);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}
/* Entry Animation for Widgets */
.animated-widget {
    opacity: 0;
    transform: translateY(30px);
    animation: widget-fade-in 0.6s ease-out forwards;
}
/* Stagger the animation */
.animated-widget:nth-child(2) { animation-delay: 0.1s; }
.animated-widget:nth-child(3) { animation-delay: 0.2s; }
.animated-widget:nth-child(4) { animation-delay: 0.3s; }
.animated-widget:nth-child(5) { animation-delay: 0.4s; }
@keyframes widget-fade-in {
    to { opacity: 1; transform: translateY(0); }
}

.widget:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px var(--shadow-color);
}
.widget h3 {
    font-size: 1.3em;
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.widget-btn {
    background: var(--primary-color);
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
    margin: 5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.widget-btn:hover {
    background: var(--dark-blue);
}
.widget-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}
.btn-danger {
    background: var(--danger-color);
}
.btn-danger:hover {
    background: #c0392b;
}
.btn-secondary {
    background: var(--text-muted);
}
.btn-secondary:hover {
    background: #6c757d;
}

/* Agent Management Styles */
.agent-card {
    background: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}
.agent-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}
.agent-card.selected {
    border-color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}
.agent-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.agent-status.online {
    background: var(--secondary-color);
    animation: pulse 2s infinite;
}
.agent-status.offline {
    background: var(--danger-color);
}
.agent-info {
    flex: 1;
}
.agent-info h4 {
    margin: 0 0 5px 0;
    color: var(--text-color);
}
.agent-info p {
    margin: 2px 0;
    font-size: 0.9em;
    color: var(--text-muted);
}
.agent-info small {
    color: var(--text-light);
    font-family: monospace;
}
.btn-icon {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}
.btn-icon:hover {
    background: var(--dark-blue);
}
.no-agents {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-style: italic;
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}
.action-btn {
    background: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}
.action-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}
.action-btn i {
    font-size: 2em;
    margin-bottom: 10px;
    color: var(--primary-color);
}
.action-btn h4 {
    margin: 0 0 5px 0;
    color: var(--text-color);
}
.action-btn p {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-muted);
}

/* Command Results */
.command-results {
    margin-top: 20px;
}
.command-result {
    background: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
}
.command-result h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
}
.result-content {
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0,0,0,0.05);
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
}
.result-content pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}
.command-result small {
    color: var(--text-muted);
}

/* LIVE MONITORING STYLES - UPDATED */
.monitoring-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.live-stream-container {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    background: var(--widget-bg);
    display: none;
}

.live-stream-container.active {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.live-indicator {
    background: var(--danger-color);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.stream-timer {
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    color: var(--text-color);
    background: var(--bg-color);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.stream-content {
    text-align: center;
    margin-bottom: 15px;
}

.stream-status {
    text-align: center;
    padding: 10px;
    color: var(--text-muted);
    font-style: italic;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* SCREENSHOTS GALLERY - COMPLETELY UPDATED */
.screenshots-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.screenshots-section h4 {
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.screenshots-section h4::before {
    content: "";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 1.2em;
}

.screenshots-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    min-height: 200px;
}

.screenshot-thumbnail {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: var(--widget-bg);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.screenshot-thumbnail:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px var(--shadow-color);
}

.screenshot-thumbnail img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.screenshot-thumbnail:hover img {
    transform: scale(1.05);
}

.screenshot-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 8px 6px;
    font-size: 0.75em;
    text-align: center;
    backdrop-filter: blur(5px);
}

.screenshot-overlay small {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.no-screenshots {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.no-screenshots::before {
    content: "";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 2em;
    opacity: 0.5;
}

.no-screenshots p {
    margin: 0;
    font-size: 1em;
}

.no-screenshots small {
    font-size: 0.85em;
    opacity: 0.7;
}

.no-results {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-style: italic;
}

/* Modal Styles - UPDATED */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--widget-bg);
    margin: 2% auto;
    padding: 0;
    border-radius: 15px;
    width: 95%;
    max-width: 900px;
    max-height: 95vh;
    overflow: hidden;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.7);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.close:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

.modal-content h3 {
    padding: 20px 20px 0;
    margin: 0;
    color: var(--text-color);
    font-size: 1.4em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content h3::before {
    content: "";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

#modalScreenshot {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    background: var(--bg-color);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: var(--widget-bg);
    border-top: 1px solid var(--border-color);
}

/* Status Grid */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; text-align: center; gap: 20px; align-items: center; height: 100%;}
.status-item { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.status-item span { font-weight: 600; margin-top: 10px; }
.stat-number { font-size: 2.5em; font-weight: 700; color: var(--primary-color); }

/* Analytics Chart */
.chart-container { display: flex; gap: 15px; height: 120px; align-items: flex-end; }
.chart-bar { flex-grow: 1; background: var(--primary-color); border-radius: 5px 5px 0 0; opacity: 0.7; transition: height 1s ease-out, opacity 0.3s; }
.chart-bar:hover { opacity: 1; }

/* Activity Timeline */
.activity-timeline ul { list-style: none; padding-left: 0; margin: 0; }
.activity-timeline li {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}
.activity-timeline li:last-child { border-bottom: none; }
.activity-timeline li span { margin-left: auto; color: var(--text-muted); font-size: 0.9em; }
.activity-timeline li i { color: var(--primary-color); font-size: 1.2em; }

/* Location Widget */
.map-preview { height: 100%; min-height: 150px; background: linear-gradient(90deg, #3498db20, #23d5ab30); border-radius: 13px; }

/* Download Widget */
.widget.download-agent {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
}
.widget.download-agent h3 {
    color: #fff;
}
.widget.download-agent p {
    color: rgba(255, 255, 255, 0.9);
}
.widget.download-agent .widget-btn {
    background: #fff;
    color: var(--dark-blue);
    font-weight: 600;
}
.widget.download-agent .widget-btn:hover {
    background: #eee;
}

/* Pulse Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Notification Styles */
.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 300px;
    max-width: 500px;
    font-family: var(--font-family, 'Poppins', sans-serif);
}

.notification-error {
    background: var(--danger-color);
    color: white;
}

.notification-warning {
    background: var(--warning-color);
    color: white;
}

.notification-info {
    background: var(--primary-color);
    color: white;
}

.notification-success {
    background: var(--secondary-color);
    color: white;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 900px) {
    body { flex-direction: column; }
    .sidebar { display: none; }
    .dashboard-widgets { grid-template-columns: 1fr; padding: 20px; }
    .topbar { padding: 15px; }
    .quick-actions-grid { grid-template-columns: 1fr 1fr; }
    .monitoring-controls { flex-direction: column; }
    .screenshots-gallery { 
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
        padding: 10px;
    }
    .modal-content {
        width: 98%;
        margin: 1% auto;
    }
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .screenshots-gallery { 
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
    .screenshot-thumbnail img {
        height: 100px;
    }
    .widget {
        padding: 15px;
    }
    .dashboard-widgets {
        padding: 15px;
        gap: 20px;
    }
    .notification-toast {
        min-width: 250px;
        max-width: 90%;
        right: 10px;
        left: 10px;
    }
}