/* ========== RICManager Signage - PWA admin ==========
   Mobile-first, sin framework. Paleta sobria con acento naranja Ricma.    */

:root {
    --bg:        #f4f6fa;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1f2937;
    --muted:     #64748b;
    --primary:   #f97316;
    --primary-d: #ea580c;
    --danger:    #dc2626;
    --ok:        #16a34a;
    --warn:      #ca8a04;
    --topbar-h:  56px;
    --tabs-h:    52px;
    --radius:    10px;
    --shadow:    0 2px 6px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.oculto { display: none !important; }
.muted  { color: var(--muted); font-size: .9rem; }
.error  { color: var(--danger); margin: .5rem 0; min-height: 1.2em; }

button { font-family: inherit; cursor: pointer; }

/* ===== LOGIN ===== */
#vista-login {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-card {
    background: var(--surface);
    padding: 2rem 1.5rem;
    border-radius: var(--radius);
    width: 100%; max-width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    text-align: center;
}
.login-logo {
    width: 120px; height: 120px;
    margin: 0 auto .75rem;
    display: block;
    border-radius: 22px;
    box-shadow: 0 8px 24px rgba(249,115,22,.25);
}
.login-card .muted { font-size: .85rem; }
.login-card form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1.5rem; text-align: left; }
.login-foot {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: .8rem;
}
.link {
    background: none; border: none;
    color: var(--primary); cursor: pointer;
    font-size: inherit; padding: 0;
    text-decoration: underline;
    font-family: inherit;
}
.link:hover { color: var(--primary-d); }
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login-card input {
    padding: .7rem .8rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.login-card button {
    padding: .8rem;
    font-size: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}
.login-card button:hover { background: var(--primary-d); }

/* ===== TOPBAR + TABS ===== */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    background: #1f2937;
    color: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem;
    box-shadow: var(--shadow);
}
.brand {
    font-weight: 600;
    display: flex; align-items: center; gap: .55rem;
}
.brand-logo {
    width: 32px; height: 32px;
    border-radius: 7px;
    flex-shrink: 0;
}
.brand-text span { color: var(--primary); }
.btn-icono {
    background: transparent;
    color: white;
    border: none;
    font-size: 1.2rem;
    padding: .3rem .55rem;
    border-radius: 6px;
}
.btn-icono:hover { background: rgba(255,255,255,.1); }

.topbar-right {
    display: flex; align-items: center; gap: .6rem;
}
.user-label {
    color: rgba(255,255,255,.7);
    font-size: .8rem;
    display: none;
}
@media (min-width: 700px) { .user-label { display: inline; } }

.cuota-badge {
    background: rgba(255,255,255,.08);
    padding: .3rem .6rem;
    border-radius: 8px;
    font-size: .7rem;
    color: rgba(255,255,255,.9);
    min-width: 110px;
    line-height: 1.2;
}
.cuota-barra {
    margin-top: .2rem;
    height: 4px;
    background: rgba(255,255,255,.15);
    border-radius: 2px;
    overflow: hidden;
}
.cuota-barra > div {
    height: 100%;
    background: var(--ok);
    transition: width .3s;
}
.cuota-barra > div.media   { background: var(--warn); }
.cuota-barra > div.alta    { background: var(--danger); }
.cuota-barra.grande {
    height: 8px;
    background: var(--border);
    margin: .35rem 0;
}
.cuota-barra.grande > div { background: var(--primary); }

.cliente-badge {
    display: inline-block;
    font-size: .65rem;
    background: var(--primary);
    color: white;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-weight: 600;
    margin-left: .35rem;
    vertical-align: middle;
}

.tabs {
    position: sticky; top: var(--topbar-h); z-index: 49;
    height: var(--tabs-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    flex: 1 0 auto;
    background: transparent;
    border: none;
    padding: 0 1rem;
    font-size: .9rem;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.tab.activa {
    color: var(--text);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ===== CONTENIDO ===== */
#contenido { padding: 1rem; max-width: 900px; margin: 0 auto; }

.seccion-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
    margin-bottom: .25rem;
}
.seccion-header h2 { margin: 0; font-size: 1.25rem; }

.btn-primario {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: .55rem 1rem;
    font-size: .9rem;
    font-weight: 600;
    display: inline-flex; align-items: center; gap: .4rem;
}
.btn-primario:hover { background: var(--primary-d); }

.btn-secundario {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .45rem .9rem;
    font-size: .85rem;
}
.btn-secundario:hover { background: #f1f5f9; }

.btn-peligro {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: .45rem .9rem;
    font-size: .85rem;
}
.btn-peligro:hover { background: var(--danger); color: white; }

/* ===== LISTAS ===== */
.lista-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.card h3 {
    margin: 0 0 .25rem;
    font-size: 1rem;
    word-break: break-word;
}
.card .meta { font-size: .8rem; color: var(--muted); margin-bottom: .75rem; }
.card .acciones {
    display: flex; gap: .5rem; flex-wrap: wrap;
    margin-top: .75rem;
}

.estado-pill {
    display: inline-block;
    font-size: .7rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-weight: 600;
    margin-right: .35rem;
}
.estado-pill.online   { background: #dcfce7; color: var(--ok); }
.estado-pill.offline  { background: #fee2e2; color: var(--danger); }
.estado-pill.pendiente{ background: #fef3c7; color: var(--warn); }

.codigo-emparejamiento {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: .15em;
    color: var(--primary);
    background: #fff7ed;
    padding: .35rem .75rem;
    border-radius: 6px;
    display: inline-block;
}

/* ===== TV ICON en cards de Pantallas ===== */
.pantalla-card { text-align: center; }
.pantalla-card h3,
.pantalla-card .meta,
.pantalla-card .acciones { text-align: left; }
.pantalla-card .acciones { justify-content: flex-start; }

.tv-icon-wrap {
    display: flex;
    justify-content: center;
    margin: -.25rem auto .9rem;
    padding: .5rem 0 0;
}
.tv-icon {
    width: 160px;
    height: 120px;
    display: block;
}
.tv-frame {
    fill: #1f2937;       /* slate-800: marco oscuro */
    stroke: #0f172a;
    stroke-width: 1;
}
.tv-screen {
    fill: #0f172a;       /* slate-900 default */
    transition: fill .4s;
}
.tv-stand-top, .tv-stand-base { fill: #475569; }   /* slate-600 */
.tv-led { fill: #64748b; transition: fill .3s, filter .3s; }
.tv-bubble {
    fill: rgba(249, 115, 22, .15);
    stroke: rgba(249, 115, 22, .4);
    stroke-width: 1;
    transition: fill .4s, stroke .4s;
}
.tv-bubble-text {
    fill: rgba(255,255,255,.85);
    font-size: 10px;
    font-weight: 800;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ===== Estados de la TV ===== */
/* Online: pantalla iluminada, LED verde brillando */
.tv-icon-wrap.online .tv-screen {
    fill: #0c1f3a;
    filter: drop-shadow(0 0 6px rgba(22,163,74,.35));
}
.tv-icon-wrap.online .tv-led {
    fill: #16a34a;
    filter: drop-shadow(0 0 4px #16a34a);
    animation: tv-led-pulse 1.6s ease-in-out infinite;
}
.tv-icon-wrap.online .tv-bubble {
    fill: rgba(249, 115, 22, .25);
    stroke: rgba(249, 115, 22, .7);
}

/* Offline: pantalla apagada, LED rojo tenue */
.tv-icon-wrap.offline .tv-screen { fill: #1e293b; }
.tv-icon-wrap.offline .tv-led    { fill: #dc2626; opacity: .8; }
.tv-icon-wrap.offline .tv-bubble { opacity: .35; }

/* Pendiente: pantalla con tono naranja sutil, LED ambar */
.tv-icon-wrap.pendiente .tv-screen { fill: #1c1408; }
.tv-icon-wrap.pendiente .tv-led {
    fill: #ca8a04;
    animation: tv-led-pulse 2s ease-in-out infinite;
}
.tv-icon-wrap.pendiente .tv-bubble {
    fill: rgba(249, 115, 22, .35);
    stroke: rgba(249, 115, 22, .8);
}

@keyframes tv-led-pulse {
    0%, 100% { opacity: .5; }
    50%      { opacity: 1; }
}

/* ===== MEDIOS (grid de thumbnails) ===== */
.lista-medios {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}
.medio-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
}
.medio-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: #0f172a;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 2rem;
    overflow: hidden;
}
.medio-thumb img,
.medio-thumb video {
    width: 100%; height: 100%; object-fit: cover;
}
.medio-info { padding: .5rem; flex: 1; display: flex; flex-direction: column; gap: .35rem; }
.medio-nombre {
    font-size: .8rem;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.medio-acciones { display: flex; justify-content: space-between; }
.medio-acciones button {
    background: transparent;
    border: none;
    font-size: 1rem;
    padding: .25rem .4rem;
    color: var(--muted);
}
.medio-acciones button:hover { color: var(--danger); }

/* ===== PROGRESO SUBIDA ===== */
#progreso-subida {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin: 1rem 0;
    font-size: .9rem;
}
#progreso-subida .barra {
    background: var(--bg);
    height: 6px; border-radius: 3px;
    overflow: hidden; margin-top: .35rem;
}
#progreso-subida .barra > div {
    background: var(--primary);
    height: 100%;
    transition: width .2s;
}

/* ===== MODAL ===== */
.modal {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-cerrar {
    position: absolute; top: .5rem; right: .75rem;
    background: transparent; border: none;
    font-size: 1.6rem; color: var(--muted);
    line-height: 1; padding: .25rem .5rem;
}
.modal-card h3 { margin: 0 0 1rem; }
.modal-card form { display: flex; flex-direction: column; gap: .9rem; }
.modal-card label {
    display: flex; flex-direction: column; gap: .3rem;
    font-size: .85rem; color: var(--muted);
}
.modal-card input,
.modal-card select,
.modal-card textarea {
    padding: .6rem .7rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}
.dias-semana {
    display: flex; flex-wrap: wrap; gap: .35rem;
}
.dias-semana label {
    flex-direction: row; align-items: center; gap: .3rem;
    background: #f1f5f9; padding: .3rem .6rem; border-radius: 6px;
    font-size: .85rem; color: var(--text); cursor: pointer;
}
.dias-semana input { margin: 0; }

.lista-items-playlist {
    display: flex; flex-direction: column; gap: .35rem;
    background: var(--bg);
    padding: .5rem; border-radius: 8px;
    max-height: 260px; overflow-y: auto;
}
.item-playlist {
    display: flex; align-items: center; gap: .5rem;
    background: var(--surface);
    padding: .4rem .6rem;
    border-radius: 6px;
    font-size: .85rem;
}
.item-playlist .drag { color: var(--muted); cursor: grab; }
.item-playlist button { background: transparent; border: none; color: var(--danger); font-size: 1rem; }

/* ===== STORAGE PANEL (Medios) ===== */
:root {
    --st-imagen: #3b82f6;   /* azul */
    --st-video:  #f97316;   /* naranja Ricma */
    --st-libre:  #e2e8f0;   /* gris claro */
}

.storage-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1rem 0;
    box-shadow: var(--shadow);
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.storage-donut {
    position: relative;
    width: 140px;
    height: 140px;
    flex-shrink: 0;
}
.donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);  /* empezar arriba */
}
.donut-bg {
    fill: none;
    stroke: var(--st-libre);
    stroke-width: 14;
}
.donut-seg {
    fill: none;
    stroke-width: 14;
    stroke-linecap: butt;
    transition: stroke-dasharray .6s ease, stroke-dashoffset .6s ease;
}
.seg-imagen { stroke: var(--st-imagen); }
.seg-video  { stroke: var(--st-video); }

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.donut-pct {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.donut-label {
    font-size: .7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.storage-leyenda {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.leyenda-fila {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .9rem;
}
.leyenda-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.color-imagen { background: var(--st-imagen); }
.color-video  { background: var(--st-video); }
.color-libre  { background: var(--st-libre); border: 1px solid var(--border); }

.leyenda-nombre {
    flex: 1;
    color: var(--text);
}
.leyenda-valor {
    color: var(--muted);
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
}

.leyenda-total {
    margin-top: .5rem;
    padding-top: .6rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
    color: var(--muted);
    text-align: right;
}

/* ===== APP FOOTER ===== */
.app-foot {
    max-width: 900px;
    margin: 2rem auto 1rem;
    padding: 1rem;
    display: flex; justify-content: space-between; align-items: center;
    font-size: .75rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ===== AVISO LEGAL ===== */
.legal-texto {
    font-size: .85rem;
    line-height: 1.55;
    max-height: 65vh;
    overflow-y: auto;
    padding: .5rem .5rem .5rem 0;
    color: var(--text);
}
.legal-texto p { margin: 0 0 .8rem; }
.legal-texto strong { color: var(--primary-d); }
.legal-texto ul {
    margin: .25rem 0 .9rem;
    padding-left: 1.2rem;
}
.legal-texto li { margin-bottom: .35rem; }
.legal-texto a {
    color: var(--primary);
    text-decoration: underline;
}
.legal-texto a:hover { color: var(--primary-d); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 1.25rem; left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: .7rem 1.2rem;
    border-radius: 999px;
    font-size: .9rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    z-index: 200;
    max-width: 90vw;
    text-align: center;
}
.toast.error { background: var(--danger); }
.toast.ok    { background: var(--ok); }
