/* Botões Toggle */

.toggle-container {
    display: flex;
    justify-content: center;
    margin-top: 25px;
}

.toggle-graficos {
    margin-top: 18px;
}

.toggle-button {
    background-color: #222;
    color: #f8f8f8;
    border: none;
    padding: 14px 24px;
    font-size: 1.1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-button:hover {
    background-color: #333;
}

.toggle-button:active {
    background-color: #444;
}


/* Painéis de treino */

.training-panels {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
        "cadence cadence avg zones"
        "cadence cadence revs zones"
        "calories calories calories calories";
    gap: 16px;
    margin-top: 0;
    align-content: start;
}

.panel-card {
    border: 1px solid #303641;
    border-radius: 8px;
    background: #1d2026;
    overflow: hidden;
}

.panel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 10px 12px;
    border-bottom: 1px solid #303641;
}

.panel-card-header h3 {
    margin: 0;
    color: #e0e0e0;
    font-size: 1rem;
    font-weight: 700;
}

.panel-toggle {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #16191d;
    color: #d9d9d9;
    font-size: 1.2rem;
    line-height: 1;
}

.panel-card-body {
    padding: 14px;
}

.panel-card canvas {
    display: block;
    width: 100%;
    min-height: 190px;
    background: #222;
    border-radius: 8px;
}

.panel-card.is-minimized .panel-card-body {
    display: none;
}

.panel-card.is-minimized .panel-card-header {
    border-bottom: none;
}

.panel-card[data-panel-id="cadenceTime"] {
    grid-area: cadence;
}

.panel-card[data-panel-id="avgRpm"] {
    grid-area: avg;
}

.panel-card[data-panel-id="pedalRevs"] {
    grid-area: revs;
}

.panel-card[data-panel-id="cadenceZones"] {
    grid-area: zones;
}

.panel-card[data-panel-id="calories30Days"] {
    grid-area: calories;
}

.panel-card[data-panel-id="cadenceTime"] canvas {
    min-height: 360px;
}

.panel-card[data-panel-id="cadenceZones"] canvas {
    min-height: 240px;
}

.panel-card[data-panel-id="calories30Days"] canvas {
    min-height: 380px;
}

.panel-kpi {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.panel-kpi .panel-card-body {
    display: flex;
    flex: 1;
    min-height: 130px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.kpi-value {
    margin: 0;
    color: #ffffff;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}

.kpi-label {
    display: block;
    margin-top: 6px;
    color: #9e9e9e;
    font-size: 0.9rem;
}


/* Reset */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background-color: #16191d;
    color: #f4f4f4;
    padding: 16px;
    min-height: 100vh;
}


/* Container */

.app-layout {
    width: 100%;
    max-width: 1760px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 18px;
}

.control-column {
    flex: 0 0 400px;
    max-width: 100%;
}

.container {
    width: 100%;
    max-width: 400px;
    background: #23272e;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 24px;
    color: #fff;
}

label {
    display: block;
    margin-top: 20px;
    font-weight: 600;
    font-size: 1.2rem;
    color: #b5b9c2;
}

input,
select {
    width: 100%;
    padding: 16px 14px;
    margin-top: 10px;
    border: 1px solid #444;
    border-radius: 12px;
    font-size: 1.2rem;
    background-color: #16191d;
    color: #fafafa;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    border-color: #57aaff;
    outline: none;
}

.botoes {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    justify-content: center;
}

.connection-modal[hidden] {
    display: none;
}

.connection-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.65);
}

.connection-modal-content {
    position: relative;
    width: min(100%, 360px);
    padding: 24px;
    border: 1px solid #343a44;
    border-radius: 14px;
    background: #23272e;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.connection-modal-content h2 {
    margin-bottom: 18px;
    font-size: 1.5rem;
    text-align: center;
}

.connection-options {
    display: grid;
    gap: 12px;
}

.connection-options button {
    width: 100%;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #16191d;
    color: #d9d9d9;
}

.connection-help {
    margin-top: 14px;
    color: #ffb74d;
    text-align: center;
    font-size: 0.95rem;
}

button {
    padding: 16px 24px;
    font-size: 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    background-color: #2962ff;
    color: white;
    transition: background-color 0.3s ease;
    min-width: 120px;
}

button:hover {
    background-color: #0049b6;
}

button:active {
    background-color: #003380;
}

button#reset {
    background-color: #434343;
    color: #b3b3b3;
}

button#reset:hover {
    background-color: #5d5d5d;
}

button#reset:active {
    background-color: #434343;
}

button.pareado {
    background-color: #81da64;
    color: #224623;
}

button.pareado:hover {
    background-color: #81da64;
}

button.pareado:active {
    background-color: #81da64;
}

.data {
    margin-top: 30px;
    background: #1d2026;
    padding: 20px;
    border-radius: 14px;
    border: 1px solid #282c34;
    position: relative;
}

.data p {
    font-size: 1.4rem;
    margin: 12px 0;
    line-height: 1.5;
    color: #e0e0e0;
}

.data .history-warning {
    margin-top: 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 183, 77, 0.12);
    color: #ffcc80;
    font-size: 0.95rem;
    text-align: center;
}

.data p>span {
    color: #9e9e9e;
    font-size: 0.8em;
}

#status {
    font-size: 1.1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    font-style: italic;
    color: #8d8d8d;
    font-weight: bold;
}

#status:active {
    opacity: 0.7;
}

#status.pedalando {
    color: #00e676;
}

.status-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px transparent;
    border-radius: 50%;
    background-color: #666;
    transition: all 0.25s ease-in-out;
}

.status-indicator.pedalando {
    background-color: #00e676;
}

.status-indicator.parado {
    background-color: #ff1744;
}

.pareado .status-indicator.parado {
    background-color: #ffd817;
}

.status-indicator.enviando {
    background-color: #448aff !important;
    /* Azul forte */
    box-shadow: 0 0 8px #448aff55;
}

.status-indicator.enviando {
    background-color: #448aff !important;
    box-shadow: 0 0 8px #448aff55;
}

.status-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    color: #fff;
    background: none;
    border: none;
    box-shadow: none;
    cursor: pointer;
    outline: none;
    padding: 0;
    margin-bottom: 16px;
    transition: opacity 0.2s;
    user-select: none;
}

.status-btn:hover {
    background: none;
    border: none;
    box-shadow: none;
    cursor: pointer;
}

.status-btn:active {
    opacity: 0.7;
}

.status-btn:focus-visible {
    outline: 2px solid #448aff;
}

.status-indicator.pareado {
    box-shadow: 0 0 0 3px #4caf50, 0 0 8px #4caf5080;
    /* Borda verde com glow */
    border: 2px solid #4caf50;
}

#status.parado {
    color: #ee4e4e;
}

.pareado #status.parado {
    color: #dbd527;
}

.dataMostrarWrap {
    position: absolute;
    right: 15px;
    top: 15px;
}

#dataMostrar {
    background: transparent;
    border: none;
    width: 121px;
    font-size: 16px;
    font-family: 'Segoe UI', Roboto, sans-serif;
    padding: 2px;
    margin: 0;
    text-align: center;
    color: #9c9c9c;
}

@media (max-width: 1500px) {
    .training-panels {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "cadence cadence"
            "avg revs"
            "zones zones"
            "calories calories";
    }
}

@media (max-width: 1100px) {
    body {
        padding: 12px;
    }

    .app-layout {
        display: grid;
        grid-template-columns: 1fr;
    }

    .control-column,
    .container {
        max-width: none;
    }

    .training-panels {
        grid-template-columns: 1fr;
        grid-template-areas:
            "cadence"
            "avg"
            "revs"
            "zones"
            "calories";
    }

    .panel-card[data-panel-id="cadenceTime"] canvas,
    .panel-card[data-panel-id="calories30Days"] canvas {
        min-height: 260px;
    }

    .panel-card[data-panel-id="cadenceZones"] canvas {
        min-height: 220px;
    }
}
