/*==========
  Reset y variables
/*==========*/

* {
    box-sizing: border-box;
}

:root {
    --green: #245c4d;
    --green-dark: #1b473c;
    --cream: #f4efe7;
    --danger: #9b2c2c;
    --warning: #b7791f;
    --blue: #277da1;
    --border: #e8e2d8;
    --text: #2f2f2f;
}

/*==========
  Base
/*==========*/

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    background: var(--cream);
    color: var(--text);
    padding: 14px;
}

.panel {
    width: min(1320px, 100%);
    margin: 0 auto;
    background: #fff;
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

p {
    margin: 6px 0 0;
    color: #666;
    font-size: 14px;
}

h1 {
    margin: 0;
    color: var(--green);
    font-size: 30px;
    line-height: 1.05;
}

h2 {
    margin: 0 0 4px;
    color: var(--green);
    font-size: 19px;
}

/*==========
  Header protocolo
/*==========*/

.protocol-header {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 14px;
}

.eyebrow {
    display: inline-block;
    color: var(--green);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .06em;
    margin-bottom: 4px;
}

.protocol-card {
    background: #eef7f3;
    border-left: 6px solid var(--green);
    padding: 12px;
    border-radius: 14px;
}

.protocol-card strong,
.protocol-card span {
    display: block;
}

.protocol-card strong {
    color: var(--green);
    font-size: 17px;
    margin-bottom: 5px;
}

.protocol-card span {
    color: #555;
    font-size: 13px;
    line-height: 1.35;
}

/*==========
  Visuales principales
/*==========*/

.visual-zone {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.object-card {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    text-align: center;
    min-height: 205px;
}

.object-card h3 {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 15px;
}

.object-wrap {
    height: 112px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
    margin-bottom: 8px;
}

/*==========
  Bolsa de yerba
/*==========*/

.bag {
    width: 72px;
    height: 102px;
    border-radius: 12px 12px 7px 7px;
    border: 3px solid #7b5b34;
    background: #d9b46f;
    position: relative;
    overflow: hidden;
    clip-path: polygon(12% 0%, 88% 0%, 100% 100%, 0% 100%);
}

.bag span {
    position: absolute;
    top: 16px;
    left: 0;
    width: 100%;
    z-index: 3;
    color: #4d351d;
    font-weight: bold;
    font-size: 11px;
}

.bag-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(#6f8f3a, #4f6f26);
    transition: height .45s ease;
}

/*==========
  Dispenser
/*==========*/

.dispenser {
    width: 62px;
    height: 108px;
    border: 3px solid #246b83;
    border-radius: 28px 28px 12px 12px;
    background: #eafaff;
    position: relative;
    overflow: hidden;
}

.dispenser::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 16px;
    width: 28px;
    height: 9px;
    border-radius: 20px;
    background: rgba(255,255,255,.8);
    z-index: 4;
}

.water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(#8bd8ff, #299bd6);
    transition: height .45s ease;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.6);
    z-index: 3;
    animation: bubble 2.2s infinite ease-in-out;
}

.b1 {
    width: 8px;
    height: 8px;
    left: 16px;
    bottom: 16px;
}

.b2 {
    width: 6px;
    height: 6px;
    right: 17px;
    bottom: 34px;
    animation-delay: .5s;
}

@keyframes bubble {
    0% { transform: translateY(0); opacity: .2; }
    50% { opacity: .9; }
    100% { transform: translateY(-48px); opacity: 0; }
}

/*==========
  Termo
/*==========*/

.termo {
    width: 52px;
    height: 108px;
    border: 3px solid #444;
    border-radius: 12px 12px 20px 20px;
    background: #f1f1f1;
    position: relative;
    overflow: hidden;
}

.termo::before {
    content: "";
    position: absolute;
    top: -15px;
    left: 14px;
    width: 21px;
    height: 18px;
    border-radius: 7px 7px 0 0;
    background: #333;
}

.termo-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(#91d9ff, #227fb3);
    transition: height .45s ease, background .3s ease;
}

.termo-fill.hot {
    background: linear-gradient(#ffb36b, #d65a2f);
}

.steam {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 5px;
    z-index: 10;
}

.steam span {
    width: 5px;
    height: 22px;
    border-radius: 999px;
    background: rgba(130,130,130,.35);
    animation: steam 1.4s infinite ease-in-out;
}

.steam span:nth-child(2) {
    animation-delay: .25s;
}

.steam span:nth-child(3) {
    animation-delay: .5s;
}

@keyframes steam {
    0% { transform: translateY(10px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-12px); opacity: 0; }
}

/*==========
  Mate animado
/*==========*/

.mate-drawing {
    height: 115px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
}

.mate-body {
    width: 86px;
    height: 78px;
    background: #7a4a28;
    border: 4px solid #3b2416;
    border-radius: 12px 12px 42px 42px;
    position: relative;
    overflow: visible;
}

.yerba-surface {
    width: 62px;
    height: 16px;
    border-radius: 50%;
    background: #6f8f3a;
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    z-index: 5;
    opacity: 0;
    transition: opacity .25s, background .25s;
}

.mate-liquid {
    width: 54px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    top: 15px;
    transform: translateX(-50%);
    z-index: 6;
    opacity: 0;
    transition: opacity .25s, background .25s;
    animation: pulseLiquid 1.2s infinite ease-in-out;
}

.mate-liquid.mate {
    background: #bd6b35;
    opacity: .95;
}

.mate-liquid.terere {
    background: #4cb3df;
    opacity: .95;
}

.bombilla {
    width: 7px;
    height: 96px;
    background: linear-gradient(#e1e1e1, #777);
    border: 1px solid #6f6f6f;
    border-radius: 999px;
    position: absolute;
    right: 4px;
    bottom: 34px;
    transform: rotate(24deg);
    transform-origin: bottom center;
    z-index: 20;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}

.bombilla::before {
    content: "";
    width: 20px;
    height: 9px;
    background: #c9c9c9;
    border: 1px solid #777;
    border-radius: 12px;
    position: absolute;
    top: -7px;
    left: -7px;
}

.mate-drawing.prepared .yerba-surface {
    opacity: 1;
}

.mate-drawing.has-bombilla .bombilla {
    opacity: 1;
}

.mate-drawing.blocked .bombilla {
    background: linear-gradient(#9b2c2c, #5b1111);
    animation: shake .35s infinite;
}

.mate-drawing.washed .yerba-surface {
    background: #a9a06a;
}

@keyframes pulseLiquid {
    0%, 100% {
        transform: translateX(-50%) scaleX(.96);
    }

    50% {
        transform: translateX(-50%) scaleX(1.06);
    }
}

@keyframes shake {
    0%, 100% {
        transform: rotate(24deg) translateX(0);
    }

    50% {
        transform: rotate(24deg) translateX(3px);
    }
}

/*==========
  Medidores y estados
/*==========*/

.meter-text {
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

.secret-status {
    font-size: 11px;
    margin-top: 5px;
    color: #777;
}

.bar {
    width: 100%;
    height: 9px;
    background: #ddd;
    border-radius: 999px;
    overflow: hidden;
    margin: 6px 0 0;
}

.fill {
    height: 100%;
    width: 0%;
    background: var(--green);
    transition: width .35s;
}

.fill.warning {
    background: var(--warning);
}

.fill.danger {
    background: var(--danger);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}

.status {
    padding: 7px;
    border-radius: 10px;
    background: #eee;
    text-align: center;
    font-size: 12px;
}

.status.active {
    background: var(--green);
    color: white;
}

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

.status.terere {
    background: var(--blue);
    color: white;
}

/*==========
  Acciones y JSON
/*==========*/

.main-row {
    display: grid;
    grid-template-columns: minmax(330px, .9fr) minmax(520px, 1.35fr);
    gap: 14px;
    align-items: stretch;
}

.actions-panel,
.json-panel {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    min-height: 300px;
}

.hint {
    font-size: 12px;
    margin-bottom: 10px;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

button {
    border: none;
    padding: 10px 13px;
    border-radius: 10px;
    background: var(--green);
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: .2s;
}

button:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
}

.reset {
    background: var(--danger);
}

.extra {
    background: #6d5a2d;
}

.btn-primary {
    background: var(--green);
}

.btn-success {
    background: #1f7a3e;
    font-weight: bold;
    transform: scale(1.05);
}

.btn-warning {
    background: var(--warning);
}

.btn-shop {
    background: #4c6f91;
}

.btn-easter-egg {
    background: #7b6228;
}

/*==========
  Estado y estadísticas
/*==========*/

.state-card {
    background: #eef7f3;
    border-left: 6px solid var(--green);
    padding: 12px;
    border-radius: 14px;
    margin-bottom: 12px;
}

.state-card span {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 3px;
}

.state-card strong {
    display: block;
    color: var(--green);
    font-size: 18px;
    margin-bottom: 4px;
}

.state-card small {
    display: block;
    line-height: 1.3;
}

.event-box {
    background: #eef7f3;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}

.event-box span {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}

.event-box strong {
    color: var(--green);
    font-size: 13px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.stat {
    padding: 8px;
    border-radius: 10px;
    background: #f0f0f0;
    text-align: center;
    font-size: 11px;
}

.stat strong {
    display: block;
    font-size: 19px;
    color: var(--green);
}

/*==========
  JSON
/*==========*/

.json-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

#copyJsonBtn {
    background: #333;
    padding: 8px 12px;
}

pre {
    height: 360px;
    margin: 0;
    background: #111;
    color: #00ff88;
    padding: 14px;
    border-radius: 12px;
    overflow: auto;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
}

/*==========
  Modal
/*==========*/

.mate-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 12, .72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.mate-modal.active {
    display: flex;
}

.mate-modal-box {
    width: min(420px, 92vw);
    background: #f7f0d8;
    border: 4px solid var(--green);
    border-radius: 22px;
    padding: 26px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    animation: modalPop .22s ease-out;
}

.mate-modal-icon {
    font-size: 52px;
    margin-bottom: 10px;
}

.mate-modal-box h2 {
    margin: 0 0 12px;
    color: var(--green);
    font-size: 24px;
}

.mate-modal-box p {
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    margin-bottom: 20px;
}

.mate-modal-box button {
    background: var(--green);
    color: white;
    border: none;
    padding: 12px 22px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
}

@keyframes modalPop {
    from {
        transform: scale(.88);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/*==========
  Responsive
/*==========*/

@media (max-width: 1000px) {
    body {
        overflow-y: auto;
    }

    .protocol-header,
    .main-row {
        grid-template-columns: 1fr;
    }

    .visual-zone {
        grid-template-columns: repeat(2, 1fr);
    }

    .status-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    pre {
        height: 300px;
    }
}

@media (max-width: 560px) {
    .visual-zone {
        grid-template-columns: 1fr;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        font-size: 24px;
    }
}
