/**
 * Network Monitor - Mobile-First Responsive Styles
 */

:root {
    --bg-dark: #0f0f0f;
    --bg-card: #1a1a2e;
    --bg-lighter: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-green: #00ff88;
    --accent-red: #ff4757;
    --accent-blue: #4facfe;
    --accent-orange: #ffa502;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 100%;
    padding: 12px;
    padding-bottom: 80px;
    /* Space for footer */
}

/* Header - Compact for Mobile */
.header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 600;
}

.subtitle {
    display: none;
}

.header-right {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #00f2fe);
    color: #000;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

/* Stats Grid - 2x2 Grid on Mobile */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-height: 60px;
}

.stat-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
}

.stat-online .stat-value {
    color: var(--accent-green);
}

.stat-offline .stat-value {
    color: var(--accent-red);
}

.stat-active .stat-value {
    color: var(--accent-orange);
}

/* Network Map */
.network-map {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.map-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.map-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.map-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.map-node-icon {
    font-size: 2rem;
    background: var(--bg-lighter);
    padding: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
}

.map-node-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.map-connector {
    width: 2px;
    height: 30px;
    background: linear-gradient(to bottom, var(--accent-blue), var(--accent-green));
}

.map-devices-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.map-device {
    background: var(--bg-lighter);
    border-radius: 8px;
    padding: 8px;
    font-size: 1.2rem;
    min-width: 40px;
    text-align: center;
    position: relative;
}

.map-device.online::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
}

.map-device.offline {
    opacity: 0.4;
}

.map-device.offline::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
}

/* Section Header with Filters */
.section-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-btn {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--accent-blue);
    color: #000;
    border-color: var(--accent-blue);
}

/* Device Grid - Stack on Mobile */
.devices-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.device-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 4px solid transparent;
    overflow: hidden;
}

.device-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.device-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.device-card-details span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.device-card.online {
    border-left-color: var(--accent-green);
}

.device-card.offline {
    border-left-color: var(--accent-red);
    opacity: 0.7;
}

.device-card.transmitting {
    border-left-color: var(--accent-orange);
}

.device-icon {
    font-size: 1.8rem;
    background: var(--bg-lighter);
    padding: 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.device-main-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-info {
    flex: 1;
    min-width: 0;
}

.device-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.device-ip {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'Consolas', monospace;
}

.device-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.status-badge.online {
    background: rgba(0, 255, 136, 0.2);
    color: var(--accent-green);
}

.status-badge.offline {
    background: rgba(255, 71, 87, 0.2);
    color: var(--accent-red);
}

.device-duration {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Modal - Full Screen on Mobile */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    background: var(--bg-lighter);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.device-info {
    background: var(--bg-lighter);
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.info-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.info-value {
    font-size: 0.85rem;
}

.info-value.mono {
    font-family: 'Consolas', monospace;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.modal-footer .btn {
    flex: 1;
    justify-content: center;
}

/* Notification Toggle Switch */
.notification-toggle {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.toggle-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* iOS-style Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-green);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

#notificationStatus {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1001;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-subtle);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

/* Port Scan Section */
.port-scan-section {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.scan-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Desktop Styles */
@media (min-width: 768px) {
    .app {
        max-width: 1200px;
        margin: 0 auto;
        padding: 24px;
    }

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

    .header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        display: block;
        color: var(--text-secondary);
        font-size: 0.9rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-card {
        flex-direction: row;
        padding: 16px;
        gap: 12px;
    }

    .device-card {
        flex-direction: row;
        align-items: center;
        padding: 16px;
    }

    .device-card-header {
        flex: 0 0 auto;
    }

    .device-card-details {
        flex: 1;
    }

    .section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .devices-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        align-items: center;
        padding: 24px;
    }

    .modal-content {
        max-width: 500px;
        border-radius: var(--radius);
    }
}

@media (min-width: 1024px) {
    .devices-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}