/* ─── Background ─────────────────────────────────────────── */
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(ellipse at top left, #071320 0%, #050e18 50%, #020609 100%);
    padding: calc(var(--header-height) + 32px) 16px 0;
    overflow-x: hidden;
}

/* ─── Decorative orbs ────────────────────────────────────── */
.bg__orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
    animation: orb-float 10s ease-in-out infinite alternate;
}

.bg__orb--1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #4CAF50, transparent 70%);
    top: -150px;
    left: -150px;
    animation-duration: 12s;
}

.bg__orb--2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #112ed4, transparent 70%);
    bottom: -120px;
    right: -120px;
    animation-duration: 9s;
    animation-delay: -4s;
}

.bg__orb--3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #1a3a52, transparent 70%);
    top: 40%;
    left: 55%;
    animation-duration: 15s;
    animation-delay: -7s;
}

@keyframes orb-float {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 20px) scale(1.08); }
}

/* ─── Layout ─────────────────────────────────────────────── */
.dashboard__main {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 32px;
}

/* ─── Header ─────────────────────────────────────────────── */
.cabecera {
    width: 100%;
    text-align: center;
    color: #ffffff;
}

.cabecera > h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.cabecera > h3 {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(137, 161, 174, 0.9);
    margin-bottom: 20px;
}

/* ─── Cards ──────────────────────────────────────────────── */
.dashboard__dataContainer,
.dashboard__dataContainerNoMax {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 20px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.dashboard__dataContainerNoMax {
    max-width: 100%;
}

/* Section accent borders */
.section--green { border-color: rgba(76, 175, 80, 0.4); }
.section--red   { border-color: rgba(244, 39,  39, 0.35); }
.section--blue  { border-color: rgba(17,  46, 212, 0.45); }

/* ─── Section headings ───────────────────────────────────── */
.dashboard__main h2,
.dashboard__components h2 {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 6px;
    letter-spacing: 0.02em;
}

.dashboard__main > .dashboard__dataContainer > .dashboard__components:first-child h2 {
    font-size: 1.25rem;
}

/* ─── Rows & data ────────────────────────────────────────── */
.dashboard__dataRow {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.dashboard__dataRow:last-child {
    margin-bottom: 0;
}

.dashboard__dataCol {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
}

.dashboard__dataCol .dashboard__data {
    justify-content: flex-start;
}

.dashboard__dataCol .dashboard__data input {
    flex: 1;
    min-width: 0;
}

.dashboard__data,
.dashboard__dataText {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.dashboard__dataText {
    flex-wrap: wrap;
}

.dashboard__data > p,
.dashboard__dataText p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    min-width: 110px;
    text-align: end;
}

.dashboard__dataText .bold {
    color: rgba(255, 255, 255, 0.9);
}

.dashboard__dataText code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.35);
    color: #7dd3a8;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ─── Components wrapper ─────────────────────────────────── */
.dashboard__components {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

/* ─── Inputs & textareas ─────────────────────────────────── */
input[type=text],
input[type=password] {
    width: 145px;
    padding: 9px 10px;
    margin: 2px 0;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    box-sizing: border-box;
    font-size: 0.8rem;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

input[type=text]:focus,
input[type=password]:focus {
    border-color: rgba(76, 175, 80, 0.6);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

input[type=text]::placeholder,
input[type=password]::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

textarea {
    font-size: 0.78rem;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    padding: 6px 8px;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    border-color: rgba(76, 175, 80, 0.5);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.12);
}

/* Readonly inputs in subscribe section */
input[readonly] {
    background: rgba(76, 175, 80, 0.12) !important;
    border-color: rgba(76, 175, 80, 0.3) !important;
    color: #a5d6a7 !important;
    font-weight: 600;
    text-align: center;
    cursor: default;
    caret-color: transparent;
}

input[readonly]:focus {
    box-shadow: none !important;
    border-color: rgba(76, 175, 80, 0.3) !important;
}

/* ─── Buttons ────────────────────────────────────────────── */
button {
    color: white;
    border: none;
    cursor: pointer;
    padding: 9px 16px;
    margin-top: 8px;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.btnConectar {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    box-shadow: 0 4px 14px rgba(229, 57, 53, 0.4);
    width: 33.333%;
    padding: 10px 18px;
}

.btnConectar:hover {
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.5);
}

.publicar_btn {
    background: linear-gradient(135deg, #e07b1a 0%, #bf5e00 100%);
    box-shadow: 0 3px 10px rgba(224, 123, 26, 0.35);
    width: 100%;
}

.publicar_btn:hover {
    box-shadow: 0 5px 16px rgba(224, 123, 26, 0.5);
}

/* ─── Status label ───────────────────────────────────────── */
#status_mqtt {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ─── Grid containers ────────────────────────────────────── */
.grid-container {
    display: flex;
    padding: 5px;
    text-align: center;
    align-items: stretch;
    justify-content: center;
    flex: 1 1 240px;
    border-radius: 14px;
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.25);
}

.grid-container-vertical {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    text-align: center;
    align-items: stretch;
    justify-content: center;
    border-radius: 14px;
    gap: 8px;
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.25);
    width: 100%;
}

.grid-container-1,
.grid-container-2 {
    display: flex;
    padding: 5px;
    text-align: center;
    align-items: stretch;
    justify-content: center;
    flex: 1 1 180px;
    min-height: 240px;
    border-radius: 14px;
    overflow: hidden;
}

.grid-container-1 {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.25);
}

.grid-container-2 {
    background: rgba(176, 20, 20, 0.2);
    border: 1px solid rgba(244, 67, 54, 0.25);
}

/* ─── Grid items ─────────────────────────────────────────── */
.grid-item {
    background: rgba(255, 255, 255, 0.06) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding: 12px 16px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    text-align: center;
    border-radius: 12px;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.grid-item p:first-child,
.grid-item > p:first-child {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.8rem;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
}

/* Images constrained to not overflow */
.grid-item img {
    max-width: 100%;
    max-height: 70px;
    object-fit: contain;
    flex-shrink: 0;
    padding-bottom: 8px;
}

.grid-item > input[type=text],
.grid-item > input[type=password],
.grid-item > .data_subscribe {
    width: 100%;
    max-width: 160px;
    box-sizing: border-box;
}

/* Textarea fills remaining space so subscribe and publish look the same */
.grid-item > textarea {
    width: 100%;
    border-radius: 6px;
    flex: 1;
    min-height: 0;
    resize: none;
}

/* ─── Shared row for charts + robot control ──────────────── */
.dashboard__row {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.dashboard__col--charts {
    flex: 2;
    min-width: 0;
}

.dashboard__col--control {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dashboard__col--control .dashboard__components {
    flex: 1;
    align-items: center;
    justify-content: center;
}

/* Stack on tablet and below */
@media screen and (max-width: 900px) {
    .dashboard__row {
        flex-direction: column;
    }
}

/* ─── D-pad robot control ────────────────────────────────── */
.robot-dpad {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 340px;
}

.dpad__row {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: stretch;
}

.dpad__cell {
    flex: 1;
}

.dpad__cell--center {
    flex: 0 0 48px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dpad__cell--action {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dpad__cell--action input[type=text] {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
}

.dpad__btn {
    width: 100% !important;
    padding: 12px 8px;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
}

/* Robot head items: side by side inside the row container */
.grid-item--robot {
    flex: 1 1 140px;
    min-height: 180px;
    padding: 14px 12px;
    gap: 6px;
    justify-content: space-between;
}

.card__divider {
    width: 100%;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin: 6px 0 2px;
}

[data-theme="light"] .card__divider {
    border-top-color: rgba(15, 40, 90, 0.15);
}

/* Chart container: grows to fill available space in the charts column */
.grid-container--chart {
    flex: 1 1 240px;
    min-width: 0;
}

/* Chart items need a slightly lighter bg for chart readability */
.chart-item {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Wrapper constrains the canvas so Chart.js has a defined space to fill */
.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
}

.chart-canvas-wrapper canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}


/* ─── Responsive ─────────────────────────────────────────── */

/* Tablet landscape */
@media screen and (max-width: 1024px) {
    .grid-container-1,
    .grid-container-2 {
        flex: 1 1 160px;
    }

    .grid-container {
        flex: 1 1 200px;
    }
}

/* Tablet portrait */
@media screen and (max-width: 768px) {
    body {
        padding: 20px 12px 40px;
    }

    .dashboard__main {
        gap: 16px;
    }

    .dashboard__dataContainerNoMax {
        max-width: 100%;
    }

    .grid-container-1,
    .grid-container-2 {
        flex: 1 1 140px;
    }

    .grid-container {
        flex: 1 1 180px;
    }

    .bg__orb--1 { width: 350px; height: 350px; }
    .bg__orb--2 { width: 300px; height: 300px; }
    .bg__orb--3 { display: none; }
}

/* Mobile */
@media screen and (max-width: 480px) {
    body {
        padding: 16px 10px 32px;
    }

    .grid-container-1,
    .grid-container-2 {
        flex: 1 1 100%;
    }

    .grid-container {
        flex: 1 1 100%;
    }

    .grid-container-vertical {
        min-width: unset;
        width: 100%;
    }

    .cabecera > h2 {
        font-size: 1.2rem;
    }

    input[type=text],
    input[type=password] {
        width: 110px;
    }

    .bg__orb--1 { width: 220px; height: 220px; opacity: 0.15; }
    .bg__orb--2 { width: 200px; height: 200px; opacity: 0.15; }
}
