:root {
    --page-pad: clamp(4px, 1.6vh, 16px);
    --section-gap: clamp(6px, 1.4vh, 14px);
    --card-pad: clamp(8px, 1.6vh, 18px);
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: var(--page-pad);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    background-color: #ffffff;
    padding: clamp(12px, 2.4vh, 28px);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    max-width: 1100px;
    width: 90%;
    height: calc(100vh - (2 * var(--page-pad)));
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    box-sizing: border-box;
}
@supports (height: 100dvh) {
    .container {
        height: calc(100dvh - (2 * var(--page-pad)));
    }
}

h1 {
    color: #007bff;
    text-align: center;
    margin-bottom: 0;
    font-size: clamp(1.2rem, 2.8vh, 2rem);
    line-height: 1.1;
}

.subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: clamp(6px, 1.2vh, 16px);
    font-size: clamp(0.85rem, 1.5vh, 1rem);
}

.alert {
    padding: clamp(8px, 1.4vh, 12px);
    margin-bottom: clamp(6px, 1.2vh, 14px);
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    font-size: clamp(0.85rem, 1.5vh, 1rem);
}

.alert.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.services {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.2vh, 14px);
    flex: 1 1 auto;
    min-height: 0;
}

.service {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(6px, 1vh, 10px) clamp(8px, 1.6vw, 14px);
    padding: var(--card-pad);
    border-radius: 10px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.service.active {
    border-left: 5px solid #28a745;
    background-color: #f6fff8;
}

.service.inactive {
    border-left: 5px solid #dc3545;
}

.service-name {
    font-size: clamp(0.95rem, 2vh, 1.15em);
    font-weight: 600;
    color: #333;
    flex: 1 1 220px;
}

.service-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.service-link:hover,
.service-link:focus-visible {
    text-decoration: underline;
}

.service-link .link-icon {
    font-size: 0.9em;
    opacity: 0.6;
}

.status {
    display: flex;
    align-items: center;
    font-weight: 500;
    margin-left: auto;
    margin-right: clamp(8px, 2vw, 20px);
    white-space: nowrap;
    font-size: clamp(0.85rem, 1.6vh, 1rem);
}

.status-dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-dot.active {
    background-color: #28a745;
}

.status-dot.inactive {
    background-color: #dc3545;
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: clamp(7px, 1.2vh, 10px) clamp(10px, 1.8vw, 18px);
    border-radius: 6px;
    cursor: pointer;
    font-size: clamp(0.85rem, 1.6vh, 1rem);
    font-weight: 600;
    transition: background-color 0.2s;
    min-width: clamp(80px, 11vw, 120px);
}

button:hover:not(:disabled) {
    background-color: #0056b3;
}

button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.note {
    margin-top: clamp(8px, 1.4vh, 20px);
    padding: clamp(8px, 1.4vh, 12px);
    background-color: #e9f7fe;
    border: 1px solid #b3e0ff;
    border-radius: 8px;
    color: #007bff;
    text-align: center;
    font-size: clamp(0.75rem, 1.4vh, 0.9rem);
    flex-shrink: 0;
}

/* Styles pour les actions individuelles et globales */
.service-actions {
    display: flex;
    gap: clamp(6px, 1.2vh, 10px);
    flex-wrap: wrap;
    justify-content: flex-end;
}
.service-actions button {
    flex: 1 1 110px;
}
.service-actions button[data-action="start"] {
    flex: 2 1 170px;
    font-size: clamp(0.95rem, 2vh, 1.1rem);
    padding: clamp(9px, 1.5vh, 12px) clamp(14px, 2.2vw, 22px);
    order: 1;
}
.global-actions {
    margin-top: clamp(8px, 1.2vh, 18px);
    text-align: center;
    flex-shrink: 0;
}
.global-actions button {
    background-color: #dc3545; /* Rouge pour l'arrêt */
}
.global-actions button:hover:not(:disabled) {
    background-color: #c82333;
}
.service-actions button[data-action="restart"] {
    background-color: #ffc107;
    color: #333;
    order: 2;
}
.service-actions button[data-action="restart"]:hover:not(:disabled) {
    background-color: #e0a800;
}
.service-actions button[data-action="stop"] {
    background-color: #dc3545;
    color: #fff;
    order: 3;
}
.service-actions button[data-action="stop"]:hover:not(:disabled) {
    background-color: #c82333;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .container {
        width: 94%;
        padding: clamp(14px, 2.4vh, 24px);
    }

    .service {
        padding: clamp(10px, 1.8vh, 16px);
    }

    .status {
        margin-right: 0;
    }
}

@media (max-width: 700px) and (min-height: 700px) {
    .service {
        flex-direction: column;
        align-items: flex-start;
    }

    .status {
        margin-left: 0;
        margin-right: 0;
    }

    .service-actions {
        width: 100%;
        justify-content: flex-start;
    }

    button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: clamp(1.25rem, 3.2vh, 1.6rem);
    }

    .subtitle {
        font-size: clamp(0.85rem, 1.6vh, 0.95rem);
    }

    .container {
        width: 98%;
    }
}

@media (max-height: 700px) {
    .container {
        padding: clamp(10px, 2vh, 16px);
    }

    .service {
        padding: clamp(8px, 1.4vh, 12px);
    }

    .note {
        margin-top: clamp(6px, 1.2vh, 12px);
    }
}

@media (max-height: 600px) {
    :root {
        --page-pad: clamp(4px, 1.2vh, 12px);
        --section-gap: clamp(4px, 1vh, 10px);
        --card-pad: clamp(6px, 1.2vh, 12px);
    }

    .subtitle {
        margin-bottom: clamp(4px, 1vh, 10px);
    }

    .global-actions {
        margin-top: clamp(6px, 1vh, 12px);
    }
}

@media (min-width: 701px) {
    .service-actions {
        flex-wrap: nowrap;
    }

    .service-actions button {
        flex: 1 1 0;
        min-width: clamp(110px, 12vw, 140px);
    }

    .service-actions button[data-action="start"] {
        flex: 2 1 0;
        min-width: clamp(220px, 24vw, 280px);
        padding: clamp(9px, 1.5vh, 12px) clamp(18px, 2.8vw, 28px);
    }
}
