:root {
    --primary-bg: #0A0E17;
    --secondary-bg: #111827;
    --primary-text: #F9FAFB;
    --secondary-text: #9CA3AF;
    --accent-color: #6366F1;
    --accent-hover: #4F46E5;
    --danger-color: #EF4444;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --modal-bg: rgba(17, 24, 39, 0.95); /* Used for modal content background */
    --hover-bg: rgba(99, 102, 241, 0.1);
    --border-color: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(17, 24, 39, 0.7); /* Slightly more opaque card bg */
    --backdrop-blur: blur(10px); /* Adjusted blur */
    --input-bg: #1F2937; /* Specific background for inputs */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--primary-bg);
    color: var(--primary-text);
    line-height: 1.6;
}

/* Navbar Styles */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--secondary-bg);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-brand h2 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-text), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent; /* Fallback for browsers that don't support background-clip: text */
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
    z-index: 1001; /* Ensure hamburger is above nav-menu when it's fixed */
}

.hamburger:hover {
    background-color: var(--hover-bg);
}

.hamburger .bar {
    width: 24px;
    height: 2px;
    background-color: var(--primary-text);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.navbar.active .hamburger .bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar.active .hamburger .bar:nth-child(2) {
    opacity: 0;
}

.navbar.active .hamburger .bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Reduced gap slightly */
}

.nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1rem; /* Reduced gap slightly */
}

.nav-item {
    margin: 0;
}

.nav-link {
    color: var(--secondary-text);
    text-decoration: none;
    padding: 0.6rem 0.9rem; /* Adjusted padding */
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    display: flex;
    align-items: center;
}

.nav-link i {
    margin-right: 0.6rem; /* Adjusted margin */
    width: 1.25rem; /* Adjusted width */
    text-align: center;
}

.nav-link:hover, .nav-link:focus {
    color: var(--primary-text);
    background: var(--hover-bg);
}

.nav-link.active {
    color: var(--accent-color);
    font-weight: 600; /* Make active link bolder */
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px; /* Align with navbar border */
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    border-radius: 2px;
}

.search-box {
    position: relative;
}

.search-box input, #commandInput {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem; /* Adjusted padding */
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--input-bg);
    color: var(--primary-text);
    font-size: 0.875rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
#commandInput { /* Specific styling for commandInput if different from search */
    padding: 0.6rem 1rem;
}

.search-box input:focus, #commandInput:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--hover-bg);
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-text);
    pointer-events: none; /* So it doesn't interfere with input click */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem; /* Adjusted gap */
}

.user-info i {
    color: var(--secondary-text);
    font-size: 1.2rem; /* Adjusted size */
    cursor: pointer;
    transition: color 0.3s ease;
}

.user-info i:hover {
    color: var(--accent-color);
}

/* Mobile Menu Styles */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: 61px; /* Height of navbar */
        left: 0;
        width: 100%;
        height: calc(100vh - 61px);
        background-color: rgba(10, 14, 23, 0.98); /* Darker, more opaque for mobile menu */
        padding: 1.5rem;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        backdrop-filter: var(--backdrop-blur);
        -webkit-backdrop-filter: var(--backdrop-blur);
        border-top: 1px solid var(--border-color);
        z-index: 999; /* Below navbar sticky elements like hamburger */
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .navbar.active .nav-menu {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    }

    .nav-list {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem; /* Tighter gap for mobile list */
    }

    .nav-item {
        width: 100%;
        opacity: 0;
        transform: translateX(-20px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .navbar.active .nav-item {
        opacity: 1;
        transform: translateX(0);
    }

    .nav-item:nth-child(1) { transition-delay: 0.1s; }
    .nav-item:nth-child(2) { transition-delay: 0.15s; }
    .nav-item:nth-child(3) { transition-delay: 0.2s; }
    .nav-item:nth-child(4) { transition-delay: 0.25s; }
    /* Add more if needed */

    .nav-link {
        padding: 0.9rem 1.25rem; /* Adjusted padding */
        width: 100%;
        display: flex;
        align-items: center;
        border-radius: 0.5rem; /* Consistent radius */
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        color: var(--primary-text);
    }

    .nav-link:hover, .nav-link:focus {
        transform: translateX(5px);
        border-color: var(--accent-color);
        background: var(--hover-bg);
    }

    .nav-link.active {
        background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
        border-color: transparent;
        color: white; /* Ensure text is white on gradient */
    }
    .nav-link.active::after { /* Remove underline for mobile active link if background changes */
        display: none;
    }

    .nav-link i {
        width: 1.5rem;
        text-align: center;
        margin-right: 1rem;
        font-size: 1.1rem; /* Adjusted icon size */
    }

    .nav-right { /* This contains user-info and search on mobile */
        flex-direction: column;
        width: 100%;
        gap: 1.5rem;
        margin-top: 1rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
    }
    
    .search-box { /* Ensure search box in mobile menu is styled well */
        width: 100%;
    }
    .search-box input {
        background: var(--input-bg); /* Ensure consistent input bg */
    }

    .user-info {
        justify-content: flex-start; /* Align user info to start on mobile */
        gap: 1.25rem;
    }
}

/* Main Content Styles */
.main-content {
    padding: 1.5rem; /* Adjusted padding */
    width: 100%;
}

@media (min-width: 768px) {
    .main-content {
        padding: 2rem; /* Larger padding for desktop */
    }
}

/* Dashboard Section Styles */
.dashboard-section {
    display: none; /* Hidden by default, JS controls visibility */
}
.dashboard-section.active {
    display: block; /* Show the active section */
}

/* Section Headings */
.dashboard-section h2, .dashboard-section h3, .dashboard-section h4 {
    color: var(--primary-text);
}

.dashboard-section h2 { /* e.g., #deviceDetailTitle */
    font-size: 1.75rem;
    font-weight: 600;
}

.dashboard-section h3 { /* e.g., System Information, Keystroke Logs, Console */
    font-size: 1.25rem;
    font-weight: 500;
}
.dashboard-section h4 { /* e.g., Command History */
    font-size: 1.1rem;
    font-weight: 500;
}

/* General content panel for sections */
.content-panel {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.content-panel.h-100 {
    display: flex;
    flex-direction: column;
}
.content-panel #systemInfoDisplay { /* System Info specific, if needed */
    flex-grow: 1;
    overflow-y: auto;
    max-height: 400px;
}

/* --- MODIFIED/NEW: Keystroke Log Display Area specific styling --- */
.content-panel .log-display-area {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 400px;
    background-color: var(--primary-bg); /* Darker distinct background for the log area */
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-family: 'SF Mono', 'Menlo', 'Consolas', 'Courier New', monospace; /* Monospace font */
    color: var(--primary-text); /* Default text color for logs */
}

/* Styling for individual log entries (if script.js wraps them, e.g. in <div class="keystroke-log-entry">) */
.keystroke-log-entry {
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
    line-height: 1.6;
    white-space: pre-wrap; /* Preserve whitespace and newlines */
    word-break: break-all; /* Break long strings */
}
.keystroke-log-entry:last-child {
    margin-bottom: 0;
}

/* If you can identify and wrap special keys in JS: <span class="special-key">[ENTER]</span> */
.special-key {
    background-color: var(--input-bg);
    color: var(--warning-color);
    padding: 0.05em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
    margin: 0 0.1em;
    display: inline-block;
    border: 1px solid rgba(245, 158, 11, 0.3); /* Border matching warning color */
    font-weight: 500;
}

/* Fallback if logs are just simple <p> tags directly inside .log-display-area */
.log-display-area > p {
    margin-bottom: 0.5em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--primary-text); /* Ensure p tags get the right color */
}
.log-display-area > p:last-child {
    margin-bottom: 0;
}
.log-display-area .loading-indicator { /* Ensure loading indicator is styled correctly here */
    color: var(--secondary-text);
    font-style: italic;
    text-align: center;
    padding: 1rem 0; /* Add some padding to loading indicator within logs */
}
/* --- END MODIFIED/NEW --- */


/* Device Card Styles */
.device-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
}

.device-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    border-color: var(--accent-color);
}

.device-card .card-body {
     display: flex;
     flex-direction: column;
     flex-grow: 1;
}

.device-card .device-info {
     flex-grow: 1;
     margin-bottom: 1rem;
}
.device-card .device-info h5 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary-text);
    margin-bottom: 0.5rem;
}
.device-card .device-info p {
    font-size: 0.875rem;
    color: var(--secondary-text);
    margin-bottom: 0.25rem;
}


.device-card .device-actions {
     margin-top: auto;
     padding-top: 1rem;
     border-top: 1px solid var(--border-color);
     display: flex;
     gap: 0.5rem;
}

.status {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status.active {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status.inactive {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.status.unknown {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}


/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    gap: 0.5rem;
    border: 1px solid transparent;
}
.btn i {
    line-height: 1;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-secondary {
    background-color: var(--secondary-text);
    color: var(--primary-bg);
    border-color: var(--secondary-text);
}
.btn-secondary:hover, .btn-secondary:focus {
    background-color: var(--primary-text);
    border-color: var(--primary-text);
    color: var(--primary-bg);
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}
.btn-success:hover, .btn-success:focus {
    background-color: #059669;
    border-color: #059669;
    color: white;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}
.btn-danger:hover, .btn-danger:focus {
    background-color: #DC2626;
    border-color: #DC2626;
    color: white;
    transform: translateY(-1px);
}

/* Modal Styles (if used) */
.modal-content {
    background: var(--modal-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--primary-text);
}

.modal-header {
    border-bottom-color: var(--border-color);
    color: var(--primary-text);
}
.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.modal-title {
    color: var(--primary-text);
}
.modal-body {
    color: var(--secondary-text);
}
.modal-body p, .modal-body div {
    color: var(--secondary-text);
}
.modal-body strong {
    color: var(--primary-text);
}


/* Console Styles */
.console-output {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow-y: auto;
    padding: 1rem;
    font-family: 'SF Mono', 'Courier New', monospace;
    color: var(--secondary-text);
    min-height: 150px;
    max-height: 300px;
}
.console-output p.text-muted {
    color: var(--secondary-text) !important;
}

.console-entry {
    margin-bottom: 0.5rem;
    color: var(--primary-text);
    white-space: pre-wrap;
}

.console-input-area {
    display: flex;
    gap: 0.75rem;
}


/* Command History Styles */
.command-history-section {
    margin-top: 1.5rem;
}

.command-history-entry {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--primary-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.command-history-entry .command-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--secondary-text);
}

.command-history-entry pre {
    white-space: pre-wrap;
    word-break: break-all;
    background-color: #000;
    color: var(--primary-text);
    padding: 0.75rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: 'SF Mono', 'Courier New', monospace;
}

.command-history-entry .status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: capitalize;
}
.status-badge.pending {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}
.status-badge.completed {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}
.status-badge.failed {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}


/* --- MODIFIED: Table Styles --- */
.table {
    width: 100%;
    margin-bottom: 1rem;
    background: transparent;
    border-radius: 0.75rem;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-color);
}

.table th,
.table td {
    border-color: var(--border-color);
    padding: 0.9rem 1rem;
    vertical-align: middle;
    /* color: var(--secondary-text); <-- Removed general color from here */
    border-bottom: 1px solid var(--border-color);
}
.table td:not(:last-child), .table th:not(:last-child) {
    border-right: 1px solid var(--border-color);
}


.table thead th {
    background: var(--secondary-bg);
    color: var(--primary-text); /* Header text is primary */
    font-weight: 500;
    border-bottom: 2px solid var(--accent-color);
}
.table tbody tr {
    background-color: var(--card-bg);
}
.table tbody tr:last-child td {
    border-bottom: none;
}

/* --- KEY CHANGE FOR LIST VIEW FONT COLOR --- */
.table tbody td {
    color: var(--primary-text); /* Changed from --secondary-text for better contrast */
}

.table tbody tr:hover {
    background: var(--hover-bg);
    /* color: var(--primary-text); This is implicitly handled by td color now */
}
.table tbody tr:hover td {
    color: var(--primary-text); /* Ensure hover maintains primary text color */
}

.table tbody tr.selected {
     background: var(--accent-color) !important;
     color: white !important;
}
.table tbody tr.selected td {
    border-color: rgba(255, 255, 255, 0.3);
    color: white !important;
}
.table tbody tr.selected td a, .table tbody tr.selected td .btn {
    color: white !important;
}

/* Styling for links within table cells */
.table tbody td a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.table tbody td a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}
/* --- END MODIFIED TABLE STYLES --- */


/* Utility Classes */
.text-muted {
    color: var(--secondary-text) !important;
}

.loading-indicator {
    text-align: center;
    padding: 2rem;
    font-style: italic;
    color: var(--secondary-text);
    width: 100%;
}
