/* Wi-Fi Stalker - Modern Dashboard Styles */

:root {
    /* Crosstalk Solutions Brand Colors */
    --ct-blue: #2B3990;
    --ct-orange: #F15A29;
    --ct-grey: #939598;

    /* Light Mode (default) */
    --primary-color: #2B3990;
    --accent-color: #F15A29;
    --secondary-color: #939598;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --online-color: #10b981;
    --offline-color: #ef4444;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Dark Mode - applied when data-theme="dark" is set on html element */
:root[data-theme="dark"] {
    --primary-color: #4B5FBB;
    --accent-color: #F15A29;
    --secondary-color: #939598;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --online-color: #10b981;
    --offline-color: #ef4444;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

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

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

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

/* Header */
header {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.header-top {
    margin-bottom: 1rem;
}

.back-to-dashboard {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.back-to-dashboard:hover {
    background: var(--background);
    color: #2563eb;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.refresh-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.status-bar {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    gap: 0.5rem;
}

.status-item .label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Action Bar */
.action-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Search Box */
.search-box {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1e2d75;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

:root[data-theme="dark"] .btn-primary:hover {
    background: #5b6fc9;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-small,
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Table */
.table-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--background);
}

thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

thead th.sortable:hover {
    color: var(--primary-color);
}

thead th.sortable span {
    margin-left: 0.25rem;
    font-size: 0.7rem;
}

tbody tr {
    border-top: 1px solid var(--border-color);
    transition: background 0.15s;
    cursor: pointer;
}

tbody tr:hover {
    background: var(--background);
}

tbody tr.connected {
    border-left: 4px solid var(--online-color);
}

tbody tr.disconnected {
    border-left: 4px solid var(--offline-color);
    opacity: 0.8;
}

tbody td {
    padding: 1rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

.status-indicator.blocked {
    opacity: 0.9;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
}

code {
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
}

.modal-xlarge {
    max-width: 1400px;
    width: 95%;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="url"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(43, 57, 144, 0.2);
}

/* Info box in modals */
.auth-info-box {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.auth-info-box p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Webhooks Section */
.webhooks-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.webhooks-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.webhooks-section .subtitle {
    margin-bottom: 1rem;
}

.webhook-add-btn {
    margin-bottom: 1rem;
}

.webhooks-list {
    margin-top: 1rem;
}

.webhook-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: var(--background);
}

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

.webhook-item-info {
    flex: 1;
}

.webhook-item-actions {
    display: flex;
    gap: 0.5rem;
}

.webhook-type-badge {
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
}

.webhook-disabled-badge {
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
}

.webhook-events {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Checkbox labels */
.checkbox-label {
    display: block;
    margin-bottom: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

/* Modal utilities */
.modal-subtitle {
    margin-bottom: 1rem;
}

.modal-search {
    margin-bottom: 1rem;
}

.modal-actions {
    margin-top: 1.5rem;
}

.history-actions {
    margin-bottom: 1rem;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Messages */
.message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-entry {
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.history-ap {
    margin-bottom: 0.5rem;
}

.history-ap strong {
    font-size: 1.1rem;
    margin-right: 0.5rem;
}

.history-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-time div {
    margin-bottom: 0.25rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    margin-bottom: 1rem;
}

.toast-success {
    background: var(--success-color);
    color: white;
}

.toast-error {
    background: var(--danger-color);
    color: white;
}

.toast-info {
    background: var(--primary-color);
    color: white;
}

/* Info Tooltip */
.info-tooltip {
    display: inline-block;
    margin-left: 0.5rem;
    cursor: help;
    font-size: 1rem;
    vertical-align: middle;
}

.info-tooltip:hover {
    transform: scale(1.2);
    transition: transform 0.2s;
}

.toast-warning {
    background: var(--warning-color);
    color: white;
}

/* Clients List (Get Devices Modal) */
.clients-list {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.client-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.client-item:hover {
    border-color: var(--primary-color);
    background: var(--background);
}

.client-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
}

.client-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.client-info {
    flex: 1;
}

.client-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.client-name strong {
    font-size: 1rem;
}

.client-mac {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.badge-tracked {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--success-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-blocked {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--danger-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Device Details Grid */
.device-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.info-section {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
}

.info-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Signal Strength Badges */
.signal-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.signal-excellent {
    background: #10b981; /* Green */
}

.signal-good {
    background: #3b82f6; /* Blue */
}

.signal-fair {
    background: #f59e0b; /* Orange */
}

.signal-poor {
    background: #ef4444; /* Red */
}

/* Wired Device Indicator */
.wired-indicator {
    color: var(--primary-color);
}

.wired-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--primary-color);
    color: white;
}

.wired-badge-small {
    margin-right: 0.25rem;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.footer-disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* Favorite AP Badge */
.favorite-badge {
    color: #f59e0b;
    margin-right: 0.25rem;
}

/* Analytics Section */
.analytics-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.analytics-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
}

/* Live data loading indicator */
.live-data-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    background: var(--background);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.loading-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

.analytics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.analytics-loading .loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.analytics-error {
    text-align: center;
    padding: 2rem;
    color: var(--danger-color);
    background: rgba(var(--danger-rgb, 220, 38, 38), 0.1);
    border-radius: 8px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.analytics-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.analytics-title {
    font-weight: 600;
    color: var(--text-primary);
}

.analytics-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.chart-container {
    position: relative;
    height: 200px;
}

.no-data-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
    font-style: italic;
    background: var(--background);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.toggle-link {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-decoration: none;
}

.toggle-link:hover {
    color: var(--primary-color);
}

/* Heat Map Styles */
.heat-map-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.heat-map-header {
    display: grid;
    grid-template-columns: 40px repeat(7, 1fr);
    gap: 2px;
}

.heat-map-corner {
    /* Empty corner cell */
}

.heat-map-day-label {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

.heat-map-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    overflow-y: auto;
}

.heat-map-row {
    display: grid;
    grid-template-columns: 40px repeat(7, 1fr);
    gap: 2px;
}

.heat-map-hour-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.25rem;
}

.heat-map-cell {
    border-radius: 2px;
    height: 14px;
    cursor: default;
    transition: transform 0.1s ease;
}

.heat-map-cell:hover {
    transform: scale(1.1);
}

/* Heat map color scale - green for connected, red for not connected */
.heat-never { background: #ef4444; }     /* Red - never/rarely connected */
.heat-rare { background: #fca5a5; }      /* Light red */
.heat-low { background: #bbf7d0; }       /* Light green */
.heat-medium { background: #4ade80; }    /* Green */
.heat-high { background: #166534; }      /* Dark green - frequently connected */

/* Heat Map Legend */
.heat-map-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.legend-label {
    padding: 0 0.25rem;
}

.legend-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .status-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .action-bar {
        flex-direction: column;
    }

    table {
        font-size: 0.875rem;
    }

    thead th,
    tbody td {
        padding: 0.75rem 0.5rem;
    }

    .modal-content {
        width: 95%;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .modal-xlarge {
        max-width: 95%;
    }
}
