/* ============================================
   Variables CSS - Themes
   ============================================ */
:root,
:root[data-theme="dark"] {
    --bg-body: #1a1a2e;
    --bg-panel: rgba(26, 26, 46, 0.95);
    --bg-panel-solid: #1a1a2e;
    --bg-tab: rgba(0, 0, 0, 0.2);
    --bg-input: rgba(255, 255, 255, 0.1);
    --bg-overlay: rgba(26, 26, 46, 0.8);

    --text-primary: #eee;
    --text-secondary: #ccc;
    --text-muted: #888;
    --text-white: #fff;

    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.15);
    --border-medium: rgba(255, 255, 255, 0.2);
    --border-drag: rgba(255, 255, 255, 0.3);

    --accent: #667eea;
    --accent-end: #764ba2;
    --accent-focus-ring: rgba(102, 126, 234, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);

    --marker-border: white;
    --marker-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --pulse-color: rgba(56, 239, 125, 0.6);

    --tab-hover-bg: rgba(255, 255, 255, 0.03);
    --tab-active-bg: rgba(102, 126, 234, 0.1);
    --collapse-btn-color: rgba(255, 255, 255, 0.7);
}

:root[data-theme="light"] {
    --bg-body: #f0f2f5;
    --bg-panel: rgba(255, 255, 255, 0.97);
    --bg-panel-solid: #ffffff;
    --bg-tab: rgba(0, 0, 0, 0.04);
    --bg-input: rgba(0, 0, 0, 0.05);
    --bg-overlay: rgba(255, 255, 255, 0.8);

    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --text-white: #fff;

    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.1);
    --border-medium: rgba(0, 0, 0, 0.15);
    --border-drag: rgba(0, 0, 0, 0.15);

    --accent: #667eea;
    --accent-end: #764ba2;
    --accent-focus-ring: rgba(102, 126, 234, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);

    --marker-border: white;
    --marker-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    --pulse-color: rgba(56, 239, 125, 0.6);

    --tab-hover-bg: rgba(0, 0, 0, 0.03);
    --tab-active-bg: rgba(102, 126, 234, 0.08);
    --collapse-btn-color: rgba(255, 255, 255, 0.8);
}

/* Transition douce entre les themes */
body,
#control-panel,
#legend,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip,
.leaflet-control-layers {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ============================================
   Reset et styles de base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
}

/* Conteneur de la carte */
#map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Panneau de controle */
#control-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 280px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    background: var(--bg-panel);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

#control-panel.collapsed {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
}

/* Bouton toggle panneau */
.panel-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 999;
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: opacity 0.3s ease;
}

.panel-toggle.visible {
    display: flex;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-collapse-btn {
    background: none;
    border: none;
    color: var(--collapse-btn-color);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.panel-collapse-btn:hover {
    color: white;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* Bouton toggle theme */
.theme-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.2);
}

/* Onglets */
.panel-tabs {
    display: flex;
    background: var(--bg-tab);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-tab {
    flex: 1;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

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

.panel-tab.active {
    color: var(--text-white);
    border-bottom-color: var(--accent);
    background: var(--tab-active-bg);
}

/* Contenu des onglets */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.panel-section {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 8px;
}

.btn:first-child {
    margin-top: 0;
}

.btn .icon {
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 239, 125, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(235, 51, 73, 0.4);
}

/* ============================================
   Device search / autocomplete
   ============================================ */
.device-search-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 2px;
}

.device-search-input-row {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.device-search-input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-focus-ring);
}

.device-search-input {
    flex: 1;
    padding: 8px 10px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    min-width: 0;
}

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

.device-search-clear {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 8px;
    font-size: 11px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.device-search-clear.visible {
    display: block;
}

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

.device-dropdown-list {
    display: none;
    width: 100%;
    margin-top: 4px;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.device-dropdown-list.open {
    display: block;
}

.device-dropdown-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s ease;
    border-bottom: 1px solid var(--border-subtle);
}

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

.device-dropdown-item:hover,
.device-dropdown-item.focused {
    background: var(--bg-input);
}

.device-dropdown-item.active {
    background: var(--tab-active-bg);
    color: var(--accent);
}

.device-dropdown-item.no-results {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
    justify-content: center;
}

.device-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-item-id {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Select cache (conserve pour le JS) */
#device-select {
    display: none;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Status indicator */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background: #38ef7d;
    box-shadow: 0 0 8px rgba(56, 239, 125, 0.6);
}

.status-indicator.offline {
    background: #f45c43;
    box-shadow: 0 0 8px rgba(244, 92, 67, 0.6);
}

/* Infos */
#last-position-info, #stats-info {
    font-size: 12px;
    line-height: 1.6;
}

#last-position-info p, #stats-info p {
    margin: 4px 0;
}

#last-position-info strong, #stats-info strong {
    color: var(--text-muted);
}

/* Device color picker */
.device-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.device-color-picker {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.device-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.device-color-picker::-webkit-color-swatch {
    border: 2px solid var(--border-drag);
    border-radius: 4px;
}

.device-color-picker::-moz-color-swatch {
    border: 2px solid var(--border-drag);
    border-radius: 4px;
}

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

/* Section parametres */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
}

.settings-row label {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
}

.settings-input {
    width: 70px;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-focus-ring);
}

.settings-input::-webkit-inner-spin-button,
.settings-input::-webkit-outer-spin-button {
    opacity: 1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    margin-top: 10px;
}

.settings-status {
    display: inline-block;
    font-size: 11px;
    margin-left: 8px;
    vertical-align: middle;
    transition: color 0.2s ease;
}

.settings-status.success {
    color: #38ef7d;
}

.settings-status.error {
    color: #f45c43;
}

/* Legende */
#legend {
    position: absolute;
    bottom: 20px;
    left: 10px;
    background: var(--bg-panel);
    padding: 12px 15px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 12px;
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    flex-shrink: 0;
}

.legend-line {
    width: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-end));
    border-radius: 2px;
}

/* Leaflet layers control - theme dynamique */
.leaflet-control-layers {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text-primary) !important;
}

.leaflet-control-layers-toggle {
    width: 36px !important;
    height: 36px !important;
    background-size: 20px 20px !important;
    border-radius: 8px !important;
}

.leaflet-control-layers-expanded {
    padding: 8px 12px !important;
}

.leaflet-control-layers label {
    color: var(--text-secondary) !important;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
}

.leaflet-control-layers-separator {
    border-top-color: var(--border-light) !important;
}

/* Leaflet popup custom */
.leaflet-popup-content-wrapper {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.leaflet-popup-content {
    margin: 12px 15px;
    font-size: 13px;
    line-height: 1.6;
}

.leaflet-popup-tip {
    background: var(--bg-panel);
}

.popup-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--accent);
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

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

.popup-value {
    font-weight: 500;
}

/* Wrapper pour marqueurs dynamiques (pas de style propre, gere en inline) */
.custom-marker-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 var(--pulse-color);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(56, 239, 125, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 239, 125, 0);
    }
}

/* ============================================
   Responsive - Tablettes (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    #control-panel {
        width: 260px;
    }

    .panel-tab {
        padding: 8px 10px;
        font-size: 11px;
    }

    #legend {
        max-width: calc(100vw - 80px);
    }
}

/* ============================================
   Responsive - Mobile (max-width: 600px)
   ============================================ */
@media (max-width: 600px) {
    /* Panneau pleine largeur en bas de l'ecran */
    #control-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 55vh;
        border-radius: 16px 16px 0 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #control-panel.collapsed {
        transform: translateY(100%);
    }

    .panel-header {
        border-radius: 16px 16px 0 0;
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Poignee de glissement visuelle */
    .panel-header::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        margin: 0 auto 8px;
    }

    /* Bouton toggle repositionne en bas */
    .panel-toggle {
        top: auto;
        bottom: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* Onglets plus grands pour le touch */
    .panel-tab {
        padding: 12px 10px;
        font-size: 12px;
    }

    /* Boutons plus grands (touch targets 44px min) */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .btn-sm {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }

    /* Select plus grand */
    #device-select {
        padding: 10px 12px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Checkbox plus grands */
    .checkbox-label {
        padding: 8px 0;
        font-size: 14px;
        min-height: 44px;
    }

    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* Settings inputs plus grands */
    .settings-input {
        width: 72px;
        padding: 8px;
        font-size: 14px;
        min-height: 40px;
    }

    .settings-row label {
        font-size: 13px;
    }

    /* Legende en haut a gauche */
    #legend {
        bottom: auto;
        top: 10px;
        left: 10px;
        right: auto;
        max-width: calc(100vw - 70px);
        font-size: 11px;
        padding: 8px 12px;
    }

    .legend-item {
        font-size: 11px;
        padding: 3px 0;
    }

    /* Color pickers plus grands */
    .device-color-picker {
        width: 36px;
        height: 36px;
    }

    .device-color-label {
        font-size: 13px;
    }

    /* Popups Leaflet adaptees */
    .leaflet-popup-content {
        margin: 10px 12px;
        font-size: 12px;
    }

    .popup-title {
        font-size: 13px;
    }

    /* Controle de couches Leaflet */
    .leaflet-control-layers-toggle {
        width: 40px !important;
        height: 40px !important;
    }

    /* Panels sections padding reduit */
    .panel-section {
        padding: 10px 15px;
    }

    /* Status info */
    #last-position-info, #stats-info {
        font-size: 13px;
    }
}

/* ============================================
   Responsive - Petits mobiles (max-width: 380px)
   ============================================ */
@media (max-width: 380px) {
    #control-panel {
        max-height: 60vh;
    }

    .panel-header h3 {
        font-size: 14px;
    }

    .settings-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    .settings-row label {
        flex: 1 1 100%;
        font-size: 12px;
    }

    .settings-input {
        width: 100%;
    }
}

/* ============================================
   Interface d'administration des devices GPS
   ============================================ */

.admin-page {
    min-height: 100vh;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* Barre de navigation */
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%);
    color: white;
    flex-shrink: 0;
}

.admin-topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-back-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 13px;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 5px;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.admin-back-link:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.admin-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.admin-user-badge {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 20px;
}

/* Messages flash */
.admin-messages {
    padding: 12px 24px 0;
}

.admin-msg {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
}

.admin-msg-success { background: rgba(56,239,125,0.15); border: 1px solid rgba(56,239,125,0.3); color: #38ef7d; }
.admin-msg-error   { background: rgba(244,92,67,0.15);  border: 1px solid rgba(244,92,67,0.3);  color: #f45c43; }

/* Corps de la page */
.admin-body {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* Carte / section */
.admin-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
}

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

.admin-card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.admin-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 10px;
    border-radius: 20px;
}

/* Tableau */
.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.admin-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s ease;
}

.admin-table tbody tr:last-child {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: var(--bg-input);
}

.admin-table tbody tr.row-editing {
    background: var(--tab-active-bg);
}

.admin-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

.admin-code {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

.admin-url {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 12px;
}

.color-pill {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-drag);
    vertical-align: middle;
    margin-right: 6px;
}

.color-hex-label {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green { background: rgba(56,239,125,0.15); color: #38ef7d; }
.badge-gray  { background: var(--bg-input);        color: var(--text-muted); }
.badge-red   { background: rgba(244,92,67,0.15);   color: #f45c43; }

/* Boutons d'action du tableau */
.admin-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.admin-actions form {
    margin: 0;
}

.admin-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

.admin-btn:hover { opacity: 0.85; transform: translateY(-1px); }

.admin-btn-edit    { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-medium); }
.admin-btn-delete  { background: rgba(244,92,67,0.15); color: #f45c43; border: 1px solid rgba(244,92,67,0.3); }
.admin-btn-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-end) 100%); color: white; padding: 9px 20px; font-size: 13px; }
.admin-btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border-medium); padding: 9px 20px; font-size: 13px; }

.admin-empty {
    padding: 24px 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

/* Formulaire admin */
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.field-required {
    color: #f45c43;
}

.field-input {
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-focus-ring);
}

.field-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Color picker inline */
.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.field-color {
    width: 44px;
    height: 36px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

.field-color::-webkit-color-swatch-wrapper { padding: 2px; }
.field-color::-webkit-color-swatch { border-radius: 4px; border: none; }

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

/* Toggle switch */
.field-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    margin-top: 4px;
}

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

.toggle-track {
    width: 40px;
    height: 22px;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
}

.field-toggle input:checked + .toggle-track {
    background: var(--accent);
    border-color: var(--accent);
}

.field-toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
    background: white;
}

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

/* Actions du formulaire */
.admin-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 20px 20px;
}

/* Responsive admin */
@media (max-width: 700px) {
    .admin-body { padding: 12px; gap: 12px; }
    .admin-topbar { padding: 10px 12px; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .form-field-full { grid-column: 1; }
    .admin-url { max-width: 120px; }
}

/* Bouton acces admin dans le panneau carte */
.btn-admin-access {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-admin-access:hover {
    background: var(--tab-active-bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

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