@import url(https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap);
@import url(https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap);
/* Modern App Layout with Sidebar Navigation */

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --border-color: #475569;
    
    /* SVG Icon Colors */
    --svg-button-fill: var(--text-secondary);
    --svg-button-fill-hover: var(--primary-color);
    --svg-button-fill-active: var(--text-primary);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --sidebar-width: 280px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--background-color);
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(145deg, var(--surface-color), var(--background-color));
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.logo-text p {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--text-primary);
    border-left-color: var(--primary-color);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

/* Favorites Section */
.favorites-section {
    margin-top: 1.5rem;
    padding: 0 1.5rem;
}

.favorites-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.favorites-count {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    min-width: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.favorite-device {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.favorite-device:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.favorite-device.online {
    border-left: 3px solid var(--success-color);
}

.favorite-device.offline {
    border-left: 3px solid var(--error-color);
    opacity: 0.7;
}

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

.favorite-device-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-device-model {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-device-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.favorite-device-status.online {
    background: var(--success-color);
    box-shadow: 0 0 6px var(--success-color);
}

.favorite-device-status.offline {
    background: var(--error-color);
}

.no-favorites-message {
    padding: 1.5rem 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Custom scrollbar for favorites list */
.favorites-list::-webkit-scrollbar {
    width: 4px;
}

.favorites-list::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 2px;
}

.favorites-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.favorites-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--background-color);
}

.connection-status {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.indicator-dot.connected {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.indicator-dot.detected {
    background: var(--warning-color);
    box-shadow: 0 0 8px var(--warning-color);
}

.indicator-dot.waiting {
    background: var(--text-muted);
}

.indicator-dot.disconnected {
    background: var(--error-color);
    box-shadow: 0 0 8px var(--error-color);
}

.indicator-dot.loading {
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    background: var(--background-color);
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
}

.view-container {
    position: relative;
    height: 100%;
}

.view {
    display: none;
    padding: 2rem;
    height: 100%;
    overflow-y: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.view-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.view-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.stat-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    min-height: 0;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-value.low {
    color: var(--success-color);
}

.stat-value.medium {
    color: var(--warning-color);
}

.stat-value.high {
    color: var(--error-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Dashboard Sections */
.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    width: 100%;
}

.section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Activity Controls */
.activity-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.activity-filter-btn {
    padding: 0.375rem 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.activity-filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.activity-filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.clear-history-btn {
    padding: 0.375rem 0.75rem;
    background: var(--error-color);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clear-history-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

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

.activity-icon {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
    margin-top: 0.125rem;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
}

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

/* Connection Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.analytics-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
    transition: all 0.2s ease;
}

.analytics-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.analytics-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.analytics-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Custom scrollbar for activity list */
.activity-list::-webkit-scrollbar {
    width: 6px;
}

.activity-list::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 3px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.activity-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    text-decoration: none;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    font-size: 1.25rem;
    width: 20px;
    text-align: center;
}

/* Phone List View */
.phone-list-container {
    background: var(--background-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

/* Device Controls Bar */
.device-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    max-width: 400px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    z-index: 1;
    font-size: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

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

.search-input::placeholder {
    color: var(--text-muted);
}

.clear-search {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.clear-search:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.75rem 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.refresh-all-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.refresh-all-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.refresh-all-btn .btn-icon {
    font-size: 1rem;
}

.manage-groups-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--warning-color);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.manage-groups-btn:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.manage-groups-btn .btn-icon {
    font-size: 1rem;
}

/* Device Stats Summary */
.device-stats-summary {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    flex-wrap: wrap;
}

.device-stats-summary .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.device-stats-summary .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.device-stats-summary .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* No Devices Message */
.no-devices-message {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    margin-top: 1rem;
}

.no-devices-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-devices-message h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.no-devices-message p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Settings View */
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 800px;
}

.settings-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.settings-section h3 {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-group {
    padding: 0;
}

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

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

.setting-info {
    flex: 1;
    margin-right: 1.5rem;
}

.setting-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.setting-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.setting-control {
    flex-shrink: 0;
}

.setting-select {
    padding: 0.5rem 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
}

.setting-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-input {
    padding: 0.5rem 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    width: 80px;
    text-align: center;
}

.setting-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.setting-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.setting-button.danger {
    background: var(--error-color);
}

.setting-button.danger:hover {
    background: #dc2626;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch:hover .toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Theme Support */
.theme-light {
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --surface-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* SVG Icon Colors for Light Theme */
    --svg-button-fill: var(--text-secondary);
    --svg-button-fill-hover: var(--primary-color);
    --svg-button-fill-active: var(--text-primary);
}

/* Compact Mode */
.compact-mode .device-card {
    padding: 0.75rem;
}

.compact-mode .device-header {
    padding: 0.75rem;
    gap: 0.5rem;
}

.compact-mode .device-specs {
    gap: 0.5rem;
    padding: 0.5rem;
}

.compact-mode .spec-item {
    padding: 0.375rem;
    gap: 0.125rem;
}

.compact-mode .device-controls {
    padding: 0.75rem;
    gap: 0.75rem;
}

.compact-mode .stat-card {
    padding: 1rem;
}

.compact-mode .dashboard-grid {
    gap: 1rem;
}

.compact-mode .dashboard-sections {
    gap: 1.5rem;
}

.compact-mode .section {
    padding: 1rem;
}

.compact-mode .device-controls-bar {
    padding: 1rem;
}

.compact-mode .device-stats-summary {
    padding: 0.75rem;
    margin: 1rem 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .device-controls-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .search-container {
        max-width: none;
    }
    
    .filter-container {
        justify-content: space-between;
    }
    
    .device-stats-summary {
        gap: 1rem;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .setting-info {
        margin-right: 0;
    }
    
    .setting-control {
        width: 100%;
    }
    
    .setting-select {
        width: 100%;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
    
    .view {
        padding: 1rem;
    }
    
    .device-controls-bar {
        padding: 1rem;
    }
    
    .search-container {
        width: 100%;
        order: -1;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .section {
        padding: 1rem;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Utility Classes */
.text-center {
    text-align: center;
}

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

.text-secondary {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Streaming View - Full Screen Override */
body.stream {
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.stream .app-container {
    display: none !important;
}

/* Device streaming view */
body.stream .device-view {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    position: relative;
    background: var(--background-color);
}

body.stream .video-layer {
    position: absolute;
    z-index: 0;
}

body.stream .touch-layer {
    position: absolute;
    z-index: 1;
}

body.stream .video {
    width: 100%;
    height: auto;
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
}

body.stream .video canvas,
body.stream .video video {
    max-width: 90vw;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

body.stream .control-buttons-list {
    position: absolute;
    right: calc(50% - 55vh);
    top: 50%;
    transform: translateY(-50%);
    width: 4rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10;
    padding: 0.75rem 0;
    margin-left: 1.5rem;
}

@media (max-width: 1200px) {
    body.stream .control-buttons-list {
        right: 1.5rem;
        margin-left: 0;
    }
}

body.stream .control-button {
    margin: 0.5rem;
    padding: 0;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

body.stream .control-button:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    --svg-button-fill: var(--svg-button-fill-hover);
}

body.stream .control-wrapper > input[type=checkbox] {
    display: none;
}

body.stream .control-wrapper > label {
    display: inline-block;
}

body.stream .control-button > svg {
    fill: var(--text-secondary);
    width: 1.25rem;
    height: 1.25rem;
    transition: fill 0.2s ease;
}

body.stream .control-button:hover > svg {
    fill: var(--primary-color);
}

body.stream .control-wrapper > input[type=checkbox]:checked + label .control-button > svg {
    fill: var(--primary-color);
}

body.stream .control-wrapper > input[type=checkbox]:checked + label .control-button {
    background: var(--primary-color);
    border-color: var(--primary-color);
    --svg-button-fill: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3), 0 0 10px rgba(37, 99, 235, 0.4);
    animation: keyboard-capture-pulse 2s ease-in-out infinite;
}

body.stream .control-wrapper > input[type=checkbox]:checked + label .control-button > svg {
    fill: white;
}

/* Special styling for keyboard capture when enabled */
body.stream .control-wrapper > input[type=checkbox]:checked + label .control-button[title*="Capture keyboard"] {
    background: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 0 0 15px rgba(16, 185, 129, 0.5);
    animation: keyboard-capture-pulse 2s ease-in-out infinite;
}

body.stream .control-wrapper > input[type=checkbox]:checked + label .control-button[title*="Capture keyboard"]::after {
    content: "ACTIVE";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    font-size: 8px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    z-index: 10;
    animation: keyboard-indicator-pulse 1.5s ease-in-out infinite;
}

@keyframes keyboard-capture-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 0 0 15px rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5), 0 0 20px rgba(16, 185, 129, 0.7);
    }
}

@keyframes keyboard-indicator-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

@keyframes keyboard-status-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pinch-help-slide-in {
    from {
        transform: translateY(100%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes pinch-help-slide-out {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(100%) scale(0.8);
        opacity: 0;
    }
}

/* Pinch help indicator styling */
#pinch-zoom-help .help-icon {
    font-size: 20px;
    flex-shrink: 0;
}

#pinch-zoom-help .help-content {
    flex: 1;
}

#pinch-zoom-help .help-title {
    font-weight: 600;
    margin-bottom: 2px;
}

#pinch-zoom-help .help-instructions {
    font-size: 11px;
    opacity: 0.9;
}

#pinch-zoom-help .help-instructions kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

#pinch-zoom-help .help-close {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#pinch-zoom-help .help-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

body.stream .text-area {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    padding: 0.75rem;
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

body.stream .text-area:focus {
    border-color: var(--primary-color);
    outline: none;
}

body.stream .more-box {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin: 1rem 0;
}

body.stream .more-box label {
    color: var(--text-primary);
    font-weight: 500;
}

body.stream .spoiler > input ~ .box {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 0.5rem;
}

body.stream .spoiler > input:checked ~ .box {
    border-color: var(--primary-color);
}

body.stream .spoiler > label {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.stream .spoiler > label::before {
    content: "▶";
    transition: transform 0.2s ease;
}

body.stream .spoiler > input:checked ~ label::before {
    transform: rotate(90deg);
}

body.stream .spoiler > input {
    display: none;
}

@media (max-width: 768px) {
    body.stream .control-buttons-list {
        right: 1rem;
        width: 3.5rem;
        margin-left: 0;
    }

    body.stream .control-button {
        width: 2.5rem;
        height: 2.5rem;
        margin: 0.25rem;
    }
}

/* List view styles */
body.list {
    background-color: var(--background-color);
}

body.stream #devices {
    display: none !important;
}

/* Global SVG icon styling */
svg {
    fill: var(--svg-button-fill, currentColor);
    width: 1.25rem;
    height: 1.25rem;
    transition: fill 0.2s ease;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    min-width: 1.25rem;
    min-height: 1.25rem;
}

/* Ensure SVG icons are visible with fallback colors */
button svg,
.control-button svg,
.action-button svg {
    fill: var(--svg-button-fill, var(--text-secondary));
}

/* Debug helper to identify missing icons */
button:empty:not([aria-label]):not([title]) {
    background-color: rgba(255, 0, 0, 0.2);
    border: 2px dashed red;
}

button:empty:not([aria-label]):not([title])::after {
    content: "Missing Icon";
    font-size: 0.75rem;
    color: red;
}

/* Fallback for missing icons */
button:empty:not(.device-nickname-input):not(.clear-search):not(.add-tag-btn):not(.remove-tag)::before {
    content: "⚙️";
    font-size: 1.25rem;
    display: inline-block;
}

.control-button:empty::before {
    content: "⚙️";
    font-size: 1.25rem;
    display: inline-block;
}

/* Specific icon fallbacks for common missing icons */
.action-button.kill-server-button:empty::before {
    content: "⏹️";
}

.action-button.update-interfaces-button:empty::before {
    content: "🔄";
}

button[title*="Start"]:empty::before {
    content: "▶️";
}

button[title*="Stop"]:empty::before {
    content: "⏹️";
}

button[title*="Refresh"]:empty::before {
    content: "🔄";
}

button[title*="Settings"]:empty::before {
    content: "⚙️";
}

button[title*="Back"]:empty::before {
    content: "⬅️";
}

/* Button SVG styling */
button svg {
    fill: currentColor;
    width: 1.25rem;
    height: 1.25rem;
}

/* Control button general styling */
.control-button {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.control-button:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
    --svg-button-fill: var(--svg-button-fill-hover);
}

.control-button > svg {
    fill: currentColor;
    width: 1.25rem;
    height: 1.25rem;
    transition: fill 0.2s ease;
}

/* Action button styling for device controls */
.action-button {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
}

.action-button:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    --svg-button-fill: white;
}

.action-button > svg {
    fill: currentColor;
    width: 1rem;
    height: 1rem;
    transition: fill 0.2s ease;
}

/* Control buttons list styling */
.control-buttons-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
}

/* Control wrapper for checkboxes */
.control-wrapper > input[type=checkbox] {
    display: none;
}

.control-wrapper > label {
    display: inline-block;
    cursor: pointer;
}

.control-wrapper > input[type=checkbox]:checked + label .control-button {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    --svg-button-fill: white;
}

.control-wrapper > input[type=checkbox]:checked + label .control-button > svg {
    fill: white;
}

/* Media Upload Dialog Styles */
@keyframes media-dialog-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes media-dialog-fade-out {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes notification-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes notification-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.media-upload-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.media-upload-container {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

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

.media-upload-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.media-upload-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.media-upload-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.media-upload-body {
    padding: 2rem;
}

.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--background-color);
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.drop-zone-icon {
    font-size: 3rem;
    opacity: 0.7;
}

.drop-zone-text {
    color: var(--text-secondary);
}

.drop-zone-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.drop-zone-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.select-files-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.select-files-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.upload-progress-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background: var(--background-color);
    padding: 1.5rem;
}

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

.upload-status {
    font-weight: 600;
    color: var(--text-primary);
}

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

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.progress-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.progress-bar-container {
    background: var(--background-color);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-list::-webkit-scrollbar {
    width: 6px;
}

.progress-list::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 3px;
}

.progress-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.progress-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.upload-notification {
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .media-upload-overlay {
        padding: 1rem;
    }
    
    .media-upload-container {
        max-width: 100%;
    }
    
    .media-upload-header {
        padding: 1rem 1.5rem;
    }
    
    .media-upload-body {
        padding: 1.5rem;
    }
    
    .upload-drop-zone {
        padding: 2rem 1rem;
    }
    
    .drop-zone-icon {
        font-size: 2.5rem;
    }
}

/* Additional UI Cleanup for Overlapping Elements */
/* ============================================== */

/* Ensure proper z-index hierarchy */
.sidebar {
    z-index: 100;
}

.admin-overlay,
.media-upload-overlay,
.modal-overlay {
    z-index: 1000;
}

.dropdown,
.tooltip,
.popover {
    z-index: 500;
}

/* Fix potential header/content overlaps */
.view-header {
    position: relative;
    z-index: 10;
}

/* Ensure cards don't overflow their containers */
.stat-card,
.device-card,
.section {
    overflow: hidden;
    word-wrap: break-word;
}

/* Fix button and control spacing */
.action-button,
.control-button,
.filter-select,
.setting-button {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure proper text wrapping */
.device-nickname-input,
.spec-value,
.activity-title {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Fix grid and flex container issues */
.dashboard-grid,
.dashboard-sections,
.device-list {
    min-width: 0;
    overflow: hidden;
}

/* Ensure modals and overlays are properly positioned */
.modal-content,
.overlay-content {
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

/* Fix potential sidebar overlap on mobile */
@media (max-width: 768px) {
    .sidebar {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .main-content {
        position: relative;
        z-index: 1;
    }
}

/* Ensure inputs and selects don't overflow */
input,
select,
textarea {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix potential icon sizing issues */
.nav-icon,
.stat-icon,
.device-icon,
.activity-icon {
    flex-shrink: 0;
}

/* Ensure proper spacing in compact mode */
.compact-mode .view {
    padding: 1.5rem;
}

.compact-mode .device-card {
    margin-bottom: 0.75rem;
}

/* Additional responsive fixes */
@media (max-width: 480px) {
    .view {
        padding: 0.75rem;
    }
    
    .dashboard-grid {
        gap: 0.75rem;
    }
    
    .dashboard-sections {
        gap: 1rem;
    }
}

/* File Upload Styles */
/* ================== */

.file-upload-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.upload-section,
.device-selection-section,
.files-preview-section,
.upload-progress-section {
    width: 100%;
}

.upload-card,
.device-selection-card,
.files-preview-card,
.upload-progress-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.upload-card:hover,
.device-selection-card:hover,
.files-preview-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.upload-card h3,
.device-selection-card h3,
.files-preview-card h3,
.upload-progress-card h3 {
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Upload Drop Zone */
.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--background-color);
    position: relative;
    overflow: hidden;
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-2px);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.drop-zone-icon {
    font-size: 4rem;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.upload-drop-zone:hover .drop-zone-icon {
    opacity: 1;
    transform: scale(1.1);
}

.drop-zone-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.drop-zone-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-zone-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

.supported-formats {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

.select-files-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.select-files-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Upload Options */
.upload-options {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.option-checkbox:hover {
    color: var(--text-primary);
}

.option-checkbox input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
}

.option-checkbox input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.option-checkbox input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Device Selection */
.device-selection-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.btn-select-all,
.btn-clear-all,
.btn-refresh-devices {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--background-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.btn-select-all:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-clear-all:hover {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

.btn-refresh-devices:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.selected-count {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    min-height: 100px;
}

.no-devices-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-devices-message .no-devices-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
}

.no-devices-message h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.no-devices-message p {
    margin: 0;
    font-size: 0.875rem;
}

.device-selection-item {
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-height: 80px;
}

.device-selection-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.device-selection-item.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.device-selection-item.offline {
    opacity: 0.6;
    border-style: dashed;
}

.device-selection-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
}

.device-selection-item.selected .device-selection-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.device-selection-item.selected .device-selection-checkbox::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

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

.device-selection-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-selection-model {
    font-size: 0.875rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.device-selection-serial {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
    cursor: help;
}

.device-selection-status {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.device-selection-status.online {
    color: var(--success-color);
}

.device-selection-status.offline {
    color: var(--error-color);
}

/* Files Preview */
.file-count {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.file-preview-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.file-preview-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    overflow: hidden;
}

.file-preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.file-preview-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-details {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-preview-size,
.file-preview-type {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-remove {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.file-preview-remove:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-clear-files,
.btn-upload-start {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-files {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-clear-files:hover {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

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

.btn-upload-start:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-upload-start:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Progress Bars */
.overall-progress {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-label {
    font-weight: 600;
    color: var(--text-primary);
}

.progress-percentage {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.125rem;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
    border-radius: 6px;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 25%, rgba(255,255,255,0.2) 25%, rgba(255,255,255,0.2) 50%, transparent 50%, transparent 75%, rgba(255,255,255,0.2) 75%);
    background-size: 20px 20px;
    animation: progress-stripe 1s linear infinite;
}

@keyframes progress-stripe {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.upload-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.upload-item {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: all 0.2s ease;
}

.upload-item.uploading {
    border-color: var(--primary-color);
}

.upload-item.completed {
    border-color: var(--success-color);
    background: var(--primary-light);
}

.upload-item.error {
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.upload-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.upload-item-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.upload-item-status {
    font-size: 0.875rem;
    font-weight: 500;
}

.upload-item-status.uploading { color: var(--primary-color); }
.upload-item-status.completed { color: var(--success-color); }
.upload-item-status.error { color: var(--error-color); }

.upload-item-progress {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.upload-item-progress .progress-bar {
    height: 100%;
    border-radius: 3px;
}

.upload-item-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.upload-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-pause-upload,
.btn-cancel-upload,
.btn-clear-log {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pause-upload {
    background: var(--warning-color);
    color: white;
}

.btn-pause-upload:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-cancel-upload {
    background: var(--error-color);
    color: white;
}

.btn-cancel-upload:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-clear-log {
    background: var(--info-color, #3b82f6);
    color: white;
}

.btn-clear-log:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-restart-upload {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--primary-color);
    color: white;
}

.btn-restart-upload:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Responsive Design for File Upload */
@media (max-width: 768px) {
    .file-upload-container {
        gap: 1.5rem;
    }
    
    .upload-card,
    .device-selection-card,
    .files-preview-card,
    .upload-progress-card {
        padding: 1.5rem;
    }
    
    .upload-drop-zone {
        padding: 2rem 1rem;
    }
    
    .drop-zone-icon {
        font-size: 3rem;
    }
    
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    .upload-options {
        flex-direction: column;
        gap: 1rem;
    }
    
    .device-selection-controls {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .preview-actions,
    .upload-actions {
        flex-direction: column;
    }
}

/* In-App Notification System */
/* ========================== */

.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    min-width: 300px;
    max-width: 400px;
}

.notification.notification-show {
    transform: translateX(0);
    opacity: 1;
}

.notification-success {
    border-left: 4px solid var(--success-color);
    background: linear-gradient(135deg, var(--surface-color), rgba(16, 185, 129, 0.05));
}

.notification-error {
    border-left: 4px solid var(--error-color);
    background: linear-gradient(135deg, var(--surface-color), rgba(239, 68, 68, 0.05));
}

.notification-warning {
    border-left: 4px solid var(--warning-color);
    background: linear-gradient(135deg, var(--surface-color), rgba(245, 158, 11, 0.05));
}

.notification-info {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(135deg, var(--surface-color), rgba(59, 130, 246, 0.05));
}

.notification-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-primary);
    word-wrap: break-word;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
}

.notification-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Responsive notifications */
@media (max-width: 768px) {
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .notification {
        min-width: auto;
        max-width: none;
    }
    
    .notification-message {
        font-size: 0.8rem;
    }
}

/* ===========================
   MOBILE RESPONSIVE DESIGN
   =========================== */

/* Hide mobile header by default (desktop) */
.mobile-header {
    display: none;
}

.mobile-overlay {
    display: none;
}

/* Mobile First: Base styles for mobile devices */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    /* App Container Mobile Layout */
    .app-container {
        flex-direction: column;
        overflow-x: auto;
    }

    /* Mobile Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 300px;
        height: 100vh;
        transition: left 0.3s ease-in-out;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Mobile Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Mobile Header Bar */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        background: var(--surface-color);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
        box-sizing: border-box;
    }

    .mobile-menu-btn {
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--border-radius);
        transition: background-color 0.2s;
    }

    .mobile-menu-btn:hover {
        background: var(--surface-hover);
    }

    .mobile-title {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--text-primary);
    }

    /* Main Content Mobile */
    .main-content {
        margin-left: 0;
        padding: 1rem;
        min-height: calc(100vh - 70px);
    }

    /* Dashboard Grid Mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Device Grid Mobile */
    .device-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Device Card Mobile */
    .device {
        padding: 1rem;
    }

    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .device-info {
        width: 100%;
    }

    .device-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .device-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-width: auto;
    }

    /* File Upload Mobile */
    .file-upload-container {
        padding: 1rem;
    }

    .upload-card {
        padding: 1.5rem;
    }

    .upload-drop-zone {
        padding: 2rem 1rem;
        min-height: 120px;
    }

    .upload-drop-zone h3 {
        font-size: 1.25rem;
    }

    .upload-drop-zone p {
        font-size: 0.875rem;
    }

    /* Device Selection Mobile */
    .upload-devices-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .device-selection-item {
        padding: 1rem;
        min-height: 70px;
    }

    .device-selection-info {
        min-width: 0;
    }

    .device-selection-name {
        font-size: 0.9rem;
    }

    .device-selection-model,
    .device-selection-serial {
        font-size: 0.8rem;
    }

    /* File Preview Mobile */
    .files-preview-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .file-preview-item {
        padding: 0.75rem;
    }

    .file-preview-thumbnail img {
        width: 40px;
        height: 40px;
    }

    .file-preview-name {
        font-size: 0.875rem;
    }

    .file-preview-details {
        font-size: 0.75rem;
    }

    .file-preview-remove {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Upload Progress Mobile */
    .upload-items-list {
        gap: 0.75rem;
    }

    .upload-item {
        padding: 0.75rem;
    }

    .upload-item-info {
        min-width: 0;
    }

    .upload-item-name {
        font-size: 0.875rem;
    }

    .upload-item-status,
    .upload-item-speed {
        font-size: 0.75rem;
    }

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

    .form-input {
        padding: 0.75rem;
        font-size: 1rem; /* Prevent zoom on iOS */
    }

    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    /* Buttons Mobile */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
        min-height: 44px; /* Touch target size */
    }

    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Search Mobile */
    .search-container {
        margin-bottom: 1.5rem;
    }

    .search-input {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    /* Status Cards Mobile */
    .status-card {
        padding: 1rem;
    }

    .status-card h3 {
        font-size: 1.5rem;
    }

    .status-card p {
        font-size: 0.75rem;
    }

    /* Navigation Mobile */
    .nav-menu {
        padding: 1rem 0;
    }

    .nav-item {
        margin: 0 1rem 0.5rem 1rem;
        padding: 0.75rem 1rem;
    }

    .nav-icon {
        font-size: 1.25rem;
    }

    .nav-text {
        font-size: 0.875rem;
    }

    /* Tables Mobile */
    .table-container {
        overflow-x: auto;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    table {
        min-width: 600px;
    }

    /* Modals Mobile */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    /* Notifications Mobile */
    .notification-container {
        left: 1rem;
        right: 1rem;
        top: 1rem;
    }

    .notification {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .notification-message {
        font-size: 0.875rem;
        padding-right: 2rem;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

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

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

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

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

/* Large screens - ensure nothing breaks */
@media (min-width: 1400px) {
    .main-content {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
        padding-left: calc(var(--sidebar-width) + 2rem);
        padding-right: 2rem;
    }

    .device-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }

    .upload-devices-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn, .nav-item, .device-button, .file-preview-remove {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .device:hover,
    .nav-item:hover,
    .btn:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }

    /* Improve touch scrolling */
    .sidebar,
    .main-content,
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
}

.text-area {
    width: 100%;
    resize: vertical;
    margin-bottom: 5px;
}

.more-box button {
    margin: 2px;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: var(--controls-bg-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.more-box button:hover {
    background: #f5f5f5;
    border-color: #aaa;
}

.more-box button:active {
    background: #e0e0e0;
    transform: translateY(1px);
}

.more-box {
    display: none;
    position: absolute;
    background-color: var(--controls-bg-color);
    z-index: 2;
    padding: 0 .714rem .714rem .714rem;
}

.text-with-shadow, .more-box label {
    color: var(--text-color);
    text-shadow: var(--text-shadow-color) 0 0 .357rem;
}

.spoiler > input ~ .box {
    display: none;
}

.spoiler > input:checked ~ .box {
    display: block;
}

.spoiler > label::before {
    content: '►';
    margin-right: 5px;
}

.spoiler > input:checked ~ label::before {
    content: '▼';
}

.spoiler > input:checked ~ div {
    display: block;
    padding: 10px;
}

.spoiler > input {
    display: none;
}

/* Modern Device List Styles */

:root {
    --device-card-bg: var(--surface-color);
    --device-card-border: var(--border-color);
    --device-card-hover: var(--primary-color);
    --device-active-color: var(--success-color);
    --device-inactive-color: var(--warning-color);
    --device-error-color: var(--error-color);
    --device-card-shadow: var(--shadow-md);
    --device-card-shadow-hover: var(--shadow-lg);
    --device-card-radius: var(--border-radius-lg);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Container and layout */
body.list {
    padding: 0;
    background-color: var(--background-color);
    font-family: var(--font-family);
    line-height: 1.6;
}

#devices {
    max-width: 100%;
    margin: 0;
    padding: 0;
    min-height: auto;
}

body.stream #devices {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
    box-shadow: var(--shadow-lg);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    max-width: 400px;
    padding: 1rem;
}

body.list #device_list_menu {
    display: none;
}

#device_list_menu {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 4;
}

/* Device cards - clean professional layout */
#devices .device-list {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 500px), 1fr));
    font-family: var(--font-family);
    max-width: 100%;
    margin: 0;
    padding: 0;
}

#devices .device-list div.device {
    background: var(--device-card-bg);
    border: 1px solid var(--device-card-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    color: var(--text-primary);
    animation: deviceSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    position: relative;
}

/* Staggered animation for multiple devices */
#devices .device-list div.device:nth-child(1) { animation-delay: 0.1s; }
#devices .device-list div.device:nth-child(2) { animation-delay: 0.2s; }
#devices .device-list div.device:nth-child(3) { animation-delay: 0.3s; }
#devices .device-list div.device:nth-child(4) { animation-delay: 0.4s; }
#devices .device-list div.device:nth-child(5) { animation-delay: 0.5s; }
#devices .device-list div.device:nth-child(n+6) { animation-delay: 0.6s; }

#devices .device-list div.device:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: var(--shadow-lg), 0 8px 25px rgba(37, 99, 235, 0.15);
    border-color: var(--primary-color);
}

#devices .device-list div.device:hover .device-icon {
    transform: translateY(-1px) scale(1.1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)) 
            drop-shadow(0 0 12px rgba(37, 99, 235, 0.4));
}

#devices .device-list div.device:hover .status-indicator.online {
    transform: scale(1.05);
    box-shadow: var(--shadow-md), 0 0 20px rgba(16, 185, 129, 0.3);
}

#devices .device-list div.device.active {
    border-color: var(--success-color);
    border-width: 2px;
}

#devices .device-list div.device.not-active {
    opacity: 0.85;
    border-color: var(--warning-color);
}

/* Connection state animations */
#devices .device-list div.device.connecting {
    animation: deviceConnect 1.5s ease-out forwards;
}

#devices .device-list div.device.disconnecting {
    animation: deviceDisconnect 1s ease-out forwards;
}

/* Device card structure */
.device-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Device header - improved layout */
.device-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

/* Primary device info section */
.device-primary-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

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

.device-nickname-input {
    background: var(--surface-color);
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 0.375rem;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}

.device-nickname-input:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.device-nickname-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: var(--background-color);
}

.device-nickname-input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.device-nickname-input:not(:placeholder-shown) {
    background: var(--background-color);
    border-color: var(--success-color);
}

.device-model-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding-left: 1rem;
    font-style: italic;
}

/* Status indicator - improved design */
.device-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Favorite button */
.favorite-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-secondary);
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
}

.favorite-btn:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

.favorite-btn.favorited {
    color: #fbbf24; /* Golden star color */
}

.favorite-btn.favorited:hover {
    color: #f59e0b;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: 25px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: var(--shadow-sm);
}

.status-indicator.online {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
    animation: statusBreathing 3s ease-in-out infinite;
}

.status-indicator.offline {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    position: relative;
    transition: all 0.3s ease;
}

.status-indicator.online .status-dot {
    animation: statusPulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px currentColor, 0 0 15px rgba(16, 185, 129, 0.4);
}

.status-indicator.offline .status-dot {
    animation: statusPulseWeak 3s ease-in-out infinite;
    box-shadow: 0 0 4px currentColor;
}

/* Enhanced status dot with ripple effect for online devices */
.status-indicator.online .status-dot::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: statusRipple 2s ease-out infinite;
}

/* Device type specific status animations */
.status-indicator[data-device-type="phone"].online .status-dot {
    animation: statusPulse 1.8s ease-in-out infinite;
}

.status-indicator[data-device-type="tablet"].online .status-dot {
    animation: statusPulse 2.2s ease-in-out infinite;
}

.status-indicator[data-device-type="tv"].online .status-dot {
    animation: statusPulse 2.5s ease-in-out infinite;
}

.status-indicator[data-device-type="watch"].online .status-dot {
    animation: statusPulse 1.5s ease-in-out infinite;
}

.status-indicator[data-device-type="automotive"].online .status-dot {
    animation: statusPulse 2.0s ease-in-out infinite;
}

/* Connecting state animation */
.status-indicator.connecting {
    animation: statusConnecting 1.5s ease-in-out infinite;
}

.status-indicator.connecting .status-dot {
    animation: statusConnectingDot 1s linear infinite;
}

/* Special device type icons get enhanced animations */
.device-icon {
    transition: all 0.3s ease;
}

.device.active .device-icon {
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2)) 
            drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
}

/* Device specifications grid - cleaner design */
.device-specs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.spec-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.625rem;
    background: var(--surface-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    min-width: 0;
    overflow: hidden;
}

.spec-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.spec-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.spec-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spec-value.device-serial {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    background: var(--background-color);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    word-break: break-all;
}

/* Device group selector */
.device-group-select {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-family);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.device-group-select:hover,
.device-group-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Device tags */
.device-tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tags-list {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.device-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.device-tag .remove-tag {
    background: none;
    border: none;
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    margin-left: 0.125rem;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.device-tag .remove-tag:hover {
    background: rgba(255, 255, 255, 0.2);
}

.add-tag-btn {
    background: var(--surface-color);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    width: 24px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-tag-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-light);
}

/* Tag selector dropdown */
.tag-selector-dropdown {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 150px;
}

.tag-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag-option:hover {
    background: var(--background-color);
}

.tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Device notes */
.device-notes-item {
    grid-column: 1 / -1;
}

.device-notes-input {
    width: 100%;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-family);
    color: var(--text-primary);
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    transition: all 0.2s ease;
}

.device-notes-input:hover {
    border-color: var(--primary-color);
}

.device-notes-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.device-notes-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Device type icon */
.device-type-icon {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.device-type-icon:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-1px);
}

.device-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    animation: deviceIconFloat 4s ease-in-out infinite;
}

.device-type-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@keyframes deviceIconFloat {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-2px) scale(1.05); }
}

/* Connection animations */
@keyframes deviceSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    60% {
        opacity: 0.8;
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes deviceConnect {
    0% {
        border-color: var(--border-color);
        box-shadow: var(--shadow-md);
    }
    50% {
        border-color: var(--success-color);
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.3), var(--shadow-lg);
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        border-color: var(--success-color);
        box-shadow: var(--shadow-md);
        transform: translateY(0) scale(1);
    }
}

@keyframes deviceDisconnect {
    0% {
        opacity: 1;
        transform: scale(1);
        border-color: var(--success-color);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
        border-color: var(--error-color);
    }
    100% {
        opacity: 0.85;
        transform: scale(1);
        border-color: var(--warning-color);
    }
}



/* Device controls section - properly organized */
.device-controls {
    padding: 1rem;
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Organized control sections */
.primary-actions {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.server-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.streaming-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.device-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

/* Section headers */
.server-controls::before {
    content: "Server Controls";
    grid-column: 1 / -1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.streaming-options::before {
    content: "Streaming Options";
    grid-column: 1 / -1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.device-tools::before {
    content: "Device Tools";
    grid-column: 1 / -1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Hide section headers if sections are empty */
.server-controls:empty::before,
.streaming-options:empty::before,
.device-tools:empty::before {
    display: none;
}

/* Old organization rules removed - handled by new sections */

/* Old control blocks rules removed - now handled by organized sections */

/* Basic desc-block styling for organized sections */
#devices .device-list div.desc-block {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    overflow: hidden;
    min-height: 44px;
    max-height: 44px;
    display: flex;
    align-items: center;
}

#devices .device-list div.desc-block:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

#devices .device-list div.desc-block.hidden {
    display: none;
}

/* Streaming button styling */
#devices .device-list div.desc-block.stream {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    color: white;
    box-shadow: var(--shadow-md);
}

#devices .device-list div.desc-block.stream:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

#devices .device-list div.desc-block.stream a,
#devices .device-list div.desc-block.stream button {
    color: white;
    text-decoration: none;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    width: 100%;
    height: 100%;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Server control button styling */
#devices .device-list div.desc-block.server_pid button {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    width: 100%;
    height: 100%;
}

#devices .device-list div.desc-block.server_pid button:hover {
    background: var(--primary-color);
    color: white;
}

#devices .device-list div.desc-block.server_pid button > svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
    flex-shrink: 0;
}

/* Ensure all SVG icons are visible */
svg {
    display: inline-block;
    vertical-align: middle;
}

/* Fix any missing icon displays */
button:empty::before {
    content: "⚙️";
    font-size: 1.25rem;
    display: inline-block;
}

/* Action button SVG styling */
.action-button svg,
.update-interfaces-button svg,
.kill-server-button svg {
    fill: currentColor;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* Control buttons in device management */
.desc-block button svg {
    fill: currentColor;
    width: 1.25rem;
    height: 1.25rem;
    transition: fill 0.2s ease;
}

/* Refresh connection button styling */
#devices .device-list div.desc-block.refresh-connection button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    width: 100%;
    height: 100%;
    border-radius: 4px;
}

#devices .device-list div.desc-block.refresh-connection button:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#devices .device-list div.desc-block.refresh-connection button:disabled {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#devices .device-list div.desc-block.refresh-connection button > svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
    flex-shrink: 0;
}

/* Connection selector styling */
#devices .device-list div.desc-block.net_interface {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 0;
    flex-direction: row;
    align-items: center;
}

#devices .device-list div.desc-block.net_interface label {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    background: var(--background-color);
    border-right: 1px solid var(--border-color);
    height: 100%;
    white-space: nowrap;
    flex-shrink: 0;
}

#devices .device-list div.device select {
    background: var(--surface-color);
    border: none;
    color: var(--text-primary);
    padding: 1rem;
    font-size: 0.875rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    width: 100%;
    border-radius: 0;
}

#devices .device-list div.device select:hover,
#devices .device-list div.device select:focus {
    background: var(--background-color);
    outline: none;
}

/* Connection method text styling (replacing dropdown) */
.connection-method {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--surface-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-family);
    height: 100%;
    width: 100%;
}

/* Streaming options and tools styling */
#devices .device-list div.desc-block:not(.stream):not(.server_pid):not(.net_interface) a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    height: 100%;
}

#devices .device-list div.desc-block:not(.stream):not(.server_pid):not(.net_interface):hover {
    background: var(--primary-color);
}

#devices .device-list div.desc-block:not(.stream):not(.server_pid):not(.net_interface):hover a {
    color: white;
}

/* Legacy compatibility - remove old styles */
#devices .device-header div {
    /* Reset old styles */
}

#devices .device-info,
#devices .device-name-section,
#devices .device-name,
#devices .device-model,
#devices .device-version,
#devices .device-serial,
#devices .device-state {
    /* These are now handled by new structure */
}

/* Clean up old control organization */
#devices .device-controls .desc-block.stream {
    /* Handled by primary-actions section */
}

#devices .device-controls .desc-block.server_pid,
#devices .device-controls .desc-block.net_interface {
    /* Handled by server-controls section */
}

#devices .device-controls .desc-block:not(.stream):not(.server_pid):not(.net_interface) {
    /* Handled by streaming-options section */
}

/* Update services to device-controls for legacy support */
.services,
.device-controls {
    /* Handled above in main device-controls section */
}

/* Responsive design - simplified for new layout */
@media (max-width: 768px) {
    #devices {
        padding: 0 1rem 1rem 1rem;
    }
    
    #devices .device-list {
        grid-template-columns: 1fr;
        gap: 1rem;
        max-width: none;
    }
    
    .device-header {
        padding: 1rem;
        gap: 1rem;
    }
    
    .device-primary-info {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .device-nickname-input {
        font-size: 1rem;
        padding: 0.625rem 0.875rem;
    }
    
    .device-model-name {
        font-size: 0.8rem;
        padding-left: 0.875rem;
    }
    
    .status-indicator {
        align-self: flex-start;
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
    
    .device-specs {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .spec-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0.75rem;
    }
    
    .spec-label {
        font-size: 0.7rem;
        flex-shrink: 0;
        text-transform: none;
    }
    
    .spec-value {
        font-size: 0.8rem;
        text-align: right;
    }
    
    .spec-value.device-serial {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .device-controls {
        padding: 1rem;
        gap: 1rem;
    }
    
    .server-controls {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .streaming-options {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.75rem;
    }
    
    .device-tools {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 0.75rem;
    }
    
    #devices .tracker-name {
        font-size: 1.25rem;
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    #devices {
        padding: 0 0.5rem 0.5rem 0.5rem;
    }
    
    .device-header {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .device-specs {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .device-controls {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .device-nickname-input {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .device-model-name {
        font-size: 0.75rem;
    }
    
    .status-indicator {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .server-controls,
    .streaming-options,
    .device-tools {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    #devices .tracker-name {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
}

/* Loading and status animations */
/* Enhanced status animations */
@keyframes statusPulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
        box-shadow: 0 0 8px currentColor, 0 0 15px rgba(16, 185, 129, 0.4);
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.2);
        box-shadow: 0 0 12px currentColor, 0 0 25px rgba(16, 185, 129, 0.6);
    }
}

@keyframes statusPulseWeak {
    0%, 100% { 
        opacity: 0.6; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.3; 
        transform: scale(0.9);
    }
}

@keyframes statusRipple {
    0% {
        opacity: 0.7;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.3;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1.8);
    }
}

@keyframes statusBreathing {
    0%, 100% {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
        box-shadow: var(--shadow-sm);
    }
    50% {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.1));
        box-shadow: var(--shadow-md), 0 0 15px rgba(16, 185, 129, 0.2);
    }
}

@keyframes statusConnecting {
    0%, 100% {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(37, 99, 235, 0.05));
        border-color: rgba(37, 99, 235, 0.3);
    }
    50% {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(37, 99, 235, 0.1));
        border-color: rgba(37, 99, 235, 0.5);
    }
}

@keyframes statusConnectingDot {
    0% {
        opacity: 0.3;
        transform: scale(0.8);
        background: var(--primary-color);
    }
    25% {
        opacity: 0.6;
        transform: scale(1.1);
        background: var(--warning-color);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
        background: var(--primary-color);
    }
    75% {
        opacity: 0.6;
        transform: scale(1.1);
        background: var(--warning-color);
    }
    100% {
        opacity: 0.3;
        transform: scale(0.8);
        background: var(--primary-color);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge.online {
    background: var(--success-color);
    color: white;
}

.status-badge.offline {
    background: var(--warning-color);
    color: white;
}

.status-badge.error {
    background: var(--error-color);
    color: white;
}

/* Inactive device styles */
#devices .device-list .device.not-active {
    opacity: 0.75;
}

#devices .device-list .device.not-active .device-nickname-input {
    color: var(--text-muted);
}

#devices .device-list .device.not-active div.desc-block button {
    opacity: 0.6;
    cursor: not-allowed;
}

#devices .device-list .device.not-active div.desc-block button:hover {
    background: var(--surface-color);
    color: var(--text-muted);
    border-color: var(--border-color);
    transform: none;
    box-shadow: none;
}

#devices .device-list .device.not-active select {
    opacity: 0.6;
    cursor: not-allowed;
}

#devices .device-list .device.not-active a {
    color: var(--text-muted);
}

/* Tracker name */
#devices .tracker-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 2rem 0;
    padding: 0;
    text-align: center;
}

/* Highlight effect for favorite device navigation */
.device.highlight {
    animation: deviceHighlight 2s ease-out;
}

@keyframes deviceHighlight {
    0% {
        background: rgba(37, 99, 235, 0.3);
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        background: rgba(37, 99, 235, 0.2);
    }
    100% {
        background: transparent;
        transform: scale(1);
        box-shadow: none;
    }
}

body.file-listing {
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: auto;
}

.file-listing h1 {
    border-bottom: 1px solid var(--button-border-color);
    margin-bottom: 10px;
    padding-bottom: 10px;
    white-space: nowrap;
}

.file-listing tr:hover {
    background-color: var(--controls-bg-color);
}

.file-listing .quick-link-box {
    display: inline-block;
    margin-bottom: 10px;
    padding-bottom: 10px;
}

.file-listing .quick-link-box.hidden {
    display: none;
}

.file-listing a.icon {
    -webkit-padding-start: 1.5em;
    -moz-padding-start: 1.5em;
    text-decoration: none;
    user-select: auto;
}

.file-listing a.icon:hover {
    text-decoration: underline;
}

.file-listing a.link {
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAACAElEQVQ4y4WSzUsVYRjFf897RwUz+wK7LiSIyKCoyEUXDFzcqYhq0R+R4J/gMqilf0VC7VwUuBUxobJumyLTvjDIG0TcO96J7sw8T4t3Rp0kfDYH3o/DOc85Qj4LCwvGPpOmKfPz88zMzEhxFux+cGV8HARE/H2BqopzjpWVV4RhSPNH02YfzkqJwMwwDDHxKIKZR+ccAEmSMDExQZZldLY6Njc3J64gUNVtEswTFsTFdDodFhcXCYKAqakp9ijAjOK5AJbbKJSEYZ3N75t0u10+rK2VCVSVX+0elpfe8mxpHTCvCgM1btw8S71+hupwFYD3q6sAlCw4gXp4jno4ShA4nJNclf43mW0FWZbhHLTbHVZefgUxkiQlTf+QqZKmqd9NvuAsy/ZaqFSMx4+W2fjW5HccY5bgKg7BSNNunpLfjarutfCm8ZEXz9+xFbVRSxg8dIDr1y7m3Sii9lgQBLtb1ni9TqUiiBh9vT1MT9/hePUw/f29iI/KJ4N4S//GqKpUnJd4dzJkaGgQy5Rbt8fY2Pi50wnZ6ce2hVarxfkLJzDg6JEBxi6dBDNEfD9GRo5hlqswo9VqlQmiKKJWO83l2ilU1W9ZduIy9R+LwkVRVLYQxzFOYHLyKp8/NWk0vjA6OszAwT7MBFXfiaKjcRyXCaIo4v6De6WSPHnKvvMXLQgqHcJs3fIAAAAASUVORK5CYII=) left top no-repeat;
}
.file-listing a.file {
    background : url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAABHUlEQVR42o2RMW7DIBiF3498iHRJD5JKHurL+CRVBp+i2T16tTynF2gO0KSb5ZrBBl4HHDBuK/WXACH4eO9/CAAAbdvijzLGNE1TVZXfZuHg6XCAQESAZXbOKaXO57eiKG6ft9PrKQIkCQqFoIiQFBGlFIB5nvM8t9aOX2Nd18oDzjnPgCDpn/BH4zh2XZdlWVmWiUK4IgCBoFMUz9eP6zRN75cLgEQhcmTQIbl72O0f9865qLAAsURAAgKBJKEtgLXWvyjLuFsThCSstb8rBCaAQhDYWgIZ7myM+TUBjDHrHlZcbMYYk34cN0YSLcgS+wL0fe9TXDMbY33fR2AYBvyQ8L0Gk8MwREBrTfKe4TpTzwhArXWi8HI84h/1DfwI5mhxJamFAAAAAElFTkSuQmCC) left top no-repeat;
}

.file-listing a.dir {
    background : url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAd5JREFUeNqMU79rFUEQ/vbuodFEEkzAImBpkUabFP4ldpaJhZXYm/RiZWsv/hkWFglBUyTIgyAIIfgIRjHv3r39MePM7N3LcbxAFvZ2b2bn22/mm3XMjF+HL3YW7q28YSIw8mBKoBihhhgCsoORot9d3/ywg3YowMXwNde/PzGnk2vn6PitrT+/PGeNaecg4+qNY3D43vy16A5wDDd4Aqg/ngmrjl/GoN0U5V1QquHQG3q+TPDVhVwyBffcmQGJmSVfyZk7R3SngI4JKfwDJ2+05zIg8gbiereTZRHhJ5KCMOwDFLjhoBTn2g0ghagfKeIYJDPFyibJVBtTREwq60SpYvh5++PpwatHsxSm9QRLSQpEVSd7/TYJUb49TX7gztpjjEffnoVw66+Ytovs14Yp7HaKmUXeX9rKUoMoLNW3srqI5fWn8JejrVkK0QcrkFLOgS39yoKUQe292WJ1guUHG8K2o8K00oO1BTvXoW4yasclUTgZYJY9aFNfAThX5CZRmczAV52oAPoupHhWRIUUAOoyUIlYVaAa/VbLbyiZUiyFbjQFNwiZQSGl4IDy9sO5Wrty0QLKhdZPxmgGcDo8ejn+c/6eiK9poz15Kw7Dr/vN/z6W7q++091/AQYA5mZ8GYJ9K0AAAAAASUVORK5CYII=) left top no-repeat;
}

.file-listing a.up {
    background : url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU0toU0EUPfPysx/tTxuDH9SCWhUDooIbd7oRUUTMouqi2iIoCO6lceHWhegy4EJFinWjrlQUpVm0IIoFpVDEIthm0dpikpf3ZuZ6Z94nrXhhMjM3c8895977BBHB2PznK8WPtDgyWH5q77cPH8PpdXuhpQT4ifR9u5sfJb1bmw6VivahATDrxcRZ2njfoaMv+2j7mLDn93MPiNRMvGbL18L9IpF8h9/TN+EYkMffSiOXJ5+hkD+PdqcLpICWHOHc2CC+LEyA/K+cKQMnlQHJX8wqYG3MAJy88Wa4OLDvEqAEOpJd0LxHIMdHBziowSwVlF8D6QaicK01krw/JynwcKoEwZczewroTvZirlKJs5CqQ5CG8pb57FnJUA0LYCXMX5fibd+p8LWDDemcPZbzQyjvH+Ki1TlIciElA7ghwLKV4kRZstt2sANWRjYTAGzuP2hXZFpJ/GsxgGJ0ox1aoFWsDXyyxqCs26+ydmagFN/rRjymJ1898bzGzmQE0HCZpmk5A0RFIv8Pn0WYPsiu6t/Rsj6PauVTwffTSzGAGZhUG2F06hEc9ibS7OPMNp6ErYFlKavo7MkhmTqCxZ/jwzGA9Hx82H2BZSw1NTN9Gx8ycHkajU/7M+jInsDC7DiaEmo1bNl1AMr9ASFgqVu9MCTIzoGUimXVAnnaN0PdBBDCCYbEtMk6wkpQwIG0sn0PQIUF4GsTwLSIFKNqF6DVrQq+IWVrQDxAYQC/1SsYOI4pOxKZrfifiUSbDUisif7XlpGIPufXd/uvdvZm760M0no1FZcnrzUdjw7au3vu/BVgAFLXeuTxhTXVAAAAAElFTkSuQmCC) left top no-repeat;
}

.file-listing a.push {
    color: var(--text-color);
}

.file-listing .listing {
    margin: 8px;
}

.file-listing .foreground {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    z-index: 1000;
    background-color: var(--controls-bg-color);
}

.file-listing .foreground-message {
    flex: auto;
    font-size: 30px;
    color: #999;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px;
    pointer-events: none;
}

.file-listing .foreground-message.drop-target-message {
    border: 4px dashed #ddd;
}

.file-listing .entry-name {
    position: relative;
}

.file-listing .background-progress {
    position: absolute;
    left: 0;
    top: 0;
    background-color: var(--progress-background-color);
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    border-spacing: 0;
}

.file-listing .background-progress.error {
    background-color: var(--progress-background-error-color);
}

