/* === Variables CSS pour thÃ¨mes === */
:root[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --border: #404040;
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e0e0e0;
    --text-primary: #1a1a1a;
    --text-secondary: #606060;
    --accent: #2196f3;
    --accent-hover: #1976d2;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --border: #d0d0d0;
}

:root[data-theme="blue"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #4896ef;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --border: #30363d;
}

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

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

/* === Container === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 0; /* Le header gÃ¨re son propre padding */
}

/* === Header === */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 2px solid var(--border);
    /* Header fixe */
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 100;
    /* Effet de flou pour un look moderne */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* === Buttons === */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

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

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

/* === Navigation sections === */
.sections-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.section-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.section-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.section-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* === Sections === */
.config-section {
    display: none;
}

.config-section.active {
    display: block;
}

.config-section h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.help-text {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* === Sensors Section === */
.sensors-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
}

#sensors-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.sensor-category {
    margin-bottom: 25px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.category-header:hover {
    background: var(--border);
}

.category-title {
    font-size: 16px;
    font-weight: 600;
}

.category-count {
    background: var(--accent);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.sensors-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.sensor-item {
    background: var(--bg-tertiary);
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.sensor-item:hover {
    background: var(--border);
}

/* === Groupes hiÃ©rarchiques === */
.sensor-group {
    margin-bottom: 15px;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.group-header:hover {
    background: var(--border);
}

.group-toggle {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.group-icon {
    font-size: 18px;
}

.group-name {
    flex: 1;
    font-weight: 500;
    font-size: 15px;
}

.group-count {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.group-children {
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
}

/* Niveau 1 : Composants principaux (CPU, GPU, etc.) */
.sensor-group[data-level="1"] .group-header {
    background: var(--bg-secondary);
    padding: 12px 15px;
    border: 1px solid var(--border);
}

.sensor-group[data-level="1"] .group-name {
    font-size: 16px;
    font-weight: 600;
}

/* Niveau 2+ : CatÃ©gories de capteurs */
.sensor-group[data-level="2"] .group-header {
    background: var(--bg-tertiary);
}

.sensor-group[data-level="3"] .group-header {
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.sensor-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.sensor-info {
    flex: 1;
}

.sensor-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.sensor-value {
    font-size: 13px;
    color: var(--text-secondary);
}

.sensor-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg-primary);
}

.sensor-options {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sensor-options select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
}

.sensor-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* === Tabs Section === */
.tabs-manager {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
}

.tabs-list {
    margin-bottom: 20px;
}

.tab-item {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.tab-handle {
    cursor: move;
    font-size: 20px;
}

.tab-item input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.tab-sensors-count {
    color: var(--text-secondary);
    font-size: 13px;
}

/* === Apps Section === */
.apps-list {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.app-item {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 60px 1fr 1fr 100px auto;
    gap: 15px;
    align-items: center;
}

.app-item input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.app-icon-input {
    text-align: center;
    font-size: 24px;
}

/* === Theme Section === */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
}

.theme-selector label {
    cursor: pointer;
}

.theme-selector input[type="radio"] {
    display: none;
}

.theme-option {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.theme-selector input[type="radio"]:checked + .theme-option {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.theme-preview {
    width: 100%;
    height: 80px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.theme-dark { background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%); }
.theme-light { background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%); }
.theme-blue { background: linear-gradient(135deg, #0d1117 0%, #161b22 100%); }

/* === Notification === */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    background: var(--success);
    color: white;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

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

.notification.error {
    background: var(--danger);
}

/* === Responsive === */
@media (max-width: 768px) {
    .sensors-grid {
        grid-template-columns: 1fr;
    }
    
    .app-item {
        grid-template-columns: 1fr;
    }
    
    .sections-nav {
        gap: 5px;
    }
    
    .section-tab {
        padding: 10px 15px;
        font-size: 13px;
    }
}

/* === Configuration Button === */
.sensor-config-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.sensor-config-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
}

.sensor-config-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
}

.config-group {
    margin-bottom: 20px;
}

.config-group h4 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent);
}

.config-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.config-group select {
    width: 100%;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 15px;
}

.config-group input[type="checkbox"] {
    margin-right: 8px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

.modal-cancel {
    background: var(--bg-tertiary);
}

.modal-cancel:hover {
    background: var(--border);
}

/* === Section Ordre des capteurs === */
#order-tabs-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.order-tab-section {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--border);
}

.order-tab-section h3 {
    margin-bottom: 15px;
    color: var(--accent);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-sensors-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 50px;
}

.order-sensor-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.order-sensor-item:hover {
    border-color: var(--accent);
    background: var(--bg-primary);
}

.order-sensor-item:active {
    cursor: grabbing;
}

.order-sensor-item.sortable-ghost {
    opacity: 0.4;
    background: var(--accent);
}

.order-sensor-item.sortable-chosen {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.order-sensor-handle {
    color: var(--text-secondary);
    font-size: 18px;
    cursor: grab;
}

.order-sensor-handle:active {
    cursor: grabbing;
}

.order-sensor-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-sensor-name {
    font-weight: 500;
    color: var(--text-primary);
}

.order-sensor-details {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
}

.order-sensor-number {
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.order-empty-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* === Section Plugin === */
.plugin-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.plugin-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.plugin-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.plugin-card.active {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.plugin-card.active::before {
    content: 'âœ“';
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.plugin-card {
    position: relative;
}

.plugin-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.plugin-icon {
    font-size: 28px;
}

.plugin-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.plugin-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.plugin-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.plugin-meta a {
    color: var(--accent);
    text-decoration: none;
}

.plugin-meta a:hover {
    text-decoration: underline;
}

.plugin-config {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.plugin-config h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: var(--text-primary);
}

.plugin-config .config-group {
    margin-bottom: 15px;
}

.plugin-config .config-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--text-secondary);
}

.plugin-config .config-group input {
    width: 100%;
    max-width: 300px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.plugin-config .config-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.plugin-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

#connection-status {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#connection-status.success {
    color: var(--success);
}

#connection-status.error {
    color: var(--danger);
}

#connection-status.loading {
    color: var(--text-secondary);
}

.plugin-info {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid var(--accent);
}

.plugin-info h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.plugin-info p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.plugin-info ul {
    margin-top: 10px;
    margin-left: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.plugin-info ul li {
    margin-bottom: 5px;
}

.plugin-info code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* ==================== Section Plexamp ==================== */

.plugin-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
}

.plugin-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.plugin-title h3 {
    margin: 0;
    color: var(--text-primary);
}

.plugin-title p {
    margin: 5px 0 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

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

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

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

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

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

.plugin-toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: white;
}

/* Status messages */
.status-success {
    color: var(--success);
}

.status-error {
    color: var(--danger);
}

.status-warning {
    color: var(--warning);
}

#plexamp-status, #connection-status {
    margin-left: 10px;
    font-size: 0.9em;
}

#plexamp-config small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-top: 5px;
}
