/* ══════════════════════════════════════════════════
   MULTITAREA — Flomay Química
   Shell de pestañas que iframea páginas propias de la app,
   compartiendo la misma sesión (sessionStorage por pestaña
   de navegador, compartida con los iframes del mismo tab).
   ══════════════════════════════════════════════════ */

:root {
    --blue-dark:   #1e3a5f;
    --blue-mid:    #2563eb;
    --blue-light:  #dbeafe;
    --green:       #10b981;
    --green-light: #d1fae5;
    --bg:          #eef1f6;
    --surface:     #ffffff;
    --border:      #e2e8f0;
    --text:        #1a202c;
    --text-mid:    #4a5568;
    --text-light:  #718096;
    --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.18);
    --radius:      12px;
    --radius-sm:   8px;
    --header-h:    60px;
    --tabbar-h:    48px;
    --nav-h:       58px;
    --pane-header-h: 34px;
}

*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ══════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════ */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    flex-shrink: 0;
    padding: 0 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1200;
}
.logo-container { display:flex; align-items:center; gap:.75rem; }
.logo-image { height:36px; object-fit:contain; }
.logo { font-weight:700; font-size:1.05rem; color: var(--blue-dark); white-space:nowrap; }

.user-info { display:flex; align-items:center; gap:.75rem; }
#userName { font-size:.85rem; color: var(--text-mid); }
.logout-button {
    display:flex; align-items:center; gap:.4rem;
    padding:.4rem .9rem; border:none; border-radius:999px;
    background: var(--blue-light); color: var(--blue-mid);
    font-size:.82rem; font-weight:600; cursor:pointer; transition:.2s;
}
.logout-button:hover { background: var(--blue-mid); color:#fff; }

/* ══════════════════════════════════════════
   BARRA DE PESTAÑAS
   ══════════════════════════════════════════ */
.ws-tabbar {
    display: flex;
    align-items: center;
    gap: .6rem;
    height: var(--tabbar-h);
    flex-shrink: 0;
    padding: 0 .75rem;
    background: var(--surface);
    border-bottom: 1.5px solid var(--border);
    position: relative;
    z-index: 1100;
}
.ws-tabs {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}
.ws-tabs::-webkit-scrollbar { height:4px; }
.ws-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }

.ws-tab {
    display: flex; align-items: center; gap:.5rem;
    padding: .4rem .5rem .4rem .9rem;
    border: 1.5px solid transparent;
    border-radius: 8px 8px 0 0;
    background: var(--bg); color: var(--text-mid);
    font-size: .85rem; font-weight: 600;
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: .15s;
}
.ws-tab:hover { background: var(--blue-light); color: var(--blue-mid); }
.ws-tab.active {
    background: var(--surface); color: var(--blue-mid);
    border-color: var(--border); border-bottom-color: var(--surface);
    box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.ws-tab-close {
    display:flex; align-items:center; justify-content:center;
    width:20px; height:20px; border-radius:50%;
    color: var(--text-light); font-size:.72rem;
    transition:.15s;
}
.ws-tab-close:hover { background:#fee2e2; color:#dc2626; }

.ws-add-btn {
    display:flex; align-items:center; gap:.5rem; flex-shrink:0;
    padding:.45rem 1rem; border:none; border-radius:999px;
    background: linear-gradient(135deg, var(--blue-mid), var(--blue-dark));
    color:#fff; font-size:.85rem; font-weight:700; cursor:pointer;
    box-shadow: 0 3px 10px rgba(37,99,235,.3); transition:.2s;
}
.ws-add-btn:hover { transform:translateY(-1px); box-shadow:0 6px 18px rgba(37,99,235,.4); }

.ws-split-btn {
    display:flex; align-items:center; justify-content:center; flex-shrink:0;
    width:38px; height:38px; border:1.5px solid var(--border); border-radius:999px;
    background: var(--surface); color: var(--text-mid); font-size:.95rem;
    cursor:pointer; transition:.15s;
}
.ws-split-btn:hover, .ws-split-btn.active { border-color: var(--blue-mid); color: var(--blue-mid); background: var(--blue-light); }

/* ══════════════════════════════════════════
   MENÚ DE VISTA DIVIDIDA
   ══════════════════════════════════════════ */
.ws-layout-menu {
    position: absolute;
    top: calc(var(--header-h) + var(--tabbar-h) + 8px);
    right: .75rem;
    width: 210px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 1300;
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    animation: wsPickerIn .15s ease;
}
.ws-layout-menu button {
    display:flex; align-items:center; gap:.75rem;
    padding:.5rem .6rem; border:none; background:none; border-radius:8px;
    cursor:pointer; font-size:.82rem; font-weight:600; color: var(--text-mid); text-align:left;
    transition:.15s;
}
.ws-layout-menu button:hover { background: var(--blue-light); color: var(--blue-dark); }
.ws-layout-menu button.active-layout { background: var(--green-light); color:#047857; }

.ws-layout-icon {
    display:flex; gap:2px; flex-shrink:0;
    width:42px; height:30px; padding:3px;
    border:1.5px solid var(--border); border-radius:5px; background:#fff;
}
.ws-layout-icon span { flex:1; background: var(--blue-light); border-radius:2px; }
.ws-layout-menu button.active-layout .ws-layout-icon span { background: var(--green); }
.wsli-2row { flex-direction: column; }
.wsli-2x2 { flex-wrap: wrap; }
.wsli-2x2 span { flex: 1 1 45%; }

/* ══════════════════════════════════════════
   PANELES DE VISTA DIVIDIDA
   ══════════════════════════════════════════ */
.ws-pane-header {
    position: absolute;
    height: var(--pane-header-h);
    display: flex; align-items: center; gap: .5rem;
    padding: 0 .6rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    z-index: 5;
}
.ws-pane-header i { color: var(--blue-mid); font-size: .85rem; flex-shrink: 0; }
.ws-pane-header select {
    flex: 1; min-width: 0; border: none; background: none;
    font-size: .8rem; font-weight: 600; color: var(--text); cursor: pointer;
}
.ws-pane-empty {
    position: absolute;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
    background: var(--surface); border: 1.5px dashed var(--border); border-top: none;
    color: var(--text-light); font-size: .8rem; font-weight: 600;
}
.ws-pane-empty i { font-size: 1.4rem; opacity: .4; }

/* ══════════════════════════════════════════
   SELECTOR DE PÁGINAS (picker)
   ══════════════════════════════════════════ */
.ws-picker {
    position: absolute;
    top: calc(var(--header-h) + var(--tabbar-h) + 8px);
    left: .75rem;
    width: min(760px, calc(100vw - 1.5rem));
    max-height: min(70vh, 640px);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wsPickerIn .15s ease;
}
@keyframes wsPickerIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.ws-picker-header {
    display:flex; align-items:center; justify-content:space-between;
    padding: .9rem 1.1rem; border-bottom:1.5px solid var(--border); flex-shrink:0;
}
.ws-picker-header h3 { font-size:1rem; color: var(--blue-dark); display:flex; align-items:center; gap:.5rem; }
.ws-picker-close {
    background:none; border:none; cursor:pointer; color: var(--text-light);
    width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; transition:.15s;
}
.ws-picker-close:hover { background:#fee2e2; color:#dc2626; }

.ws-picker-body { padding: 1rem 1.1rem 1.25rem; overflow-y: auto; }
.ws-picker-cat { margin-bottom: 1.1rem; }
.ws-picker-cat:last-child { margin-bottom: 0; }
.ws-picker-cat h4 {
    font-size:.72rem; font-weight:700; color: var(--text-light);
    text-transform:uppercase; letter-spacing:.05em; margin-bottom:.55rem;
}
.ws-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .55rem;
}
.ws-picker-item {
    position: relative;
    display:flex; flex-direction:column; align-items:center; gap:.4rem;
    padding: .8rem .5rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-mid);
    font-size:.78rem; font-weight:600; text-align:center;
    cursor:pointer; transition:.15s;
}
.ws-picker-item i:first-child { font-size:1.15rem; color: var(--blue-mid); }
.ws-picker-item:hover { border-color: var(--blue-mid); background: var(--blue-light); color: var(--blue-dark); }
.ws-picker-item.is-open { border-color: var(--green); background: var(--green-light); }
.ws-picker-item.is-open i:first-child { color: #047857; }
.ws-picker-check {
    position:absolute; top:6px; right:6px;
    width:16px; height:16px; border-radius:50%;
    background: var(--green); color:#fff;
    display:flex; align-items:center; justify-content:center; font-size:.55rem;
}

/* ══════════════════════════════════════════
   CONTENIDO / IFRAMES
   ══════════════════════════════════════════ */
.ws-content {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #dde3ec;
}
.ws-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}
.ws-iframe.active { display: block; }

.ws-empty {
    position:absolute; inset:0;
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:.85rem; padding:2rem; text-align:center; color: var(--text-light);
}
.ws-empty i { font-size:3rem; color: var(--blue-light); }
.ws-empty h2 { font-size:1.25rem; color: var(--text); }
.ws-empty p { max-width:420px; font-size:.9rem; line-height:1.5; }
.ws-quick-launch { display:flex; flex-wrap:wrap; justify-content:center; gap:.6rem; margin-top:.5rem; }
.ws-quick-launch button {
    display:flex; align-items:center; gap:.5rem;
    padding:.55rem 1.1rem; border:1.5px solid var(--border); border-radius:999px;
    background: var(--surface); color: var(--blue-dark);
    font-size:.85rem; font-weight:700; cursor:pointer; transition:.15s;
}
.ws-quick-launch button:hover { border-color: var(--blue-mid); background: var(--blue-light); }

/* ══════════════════════════════════════════
   NAVEGACIÓN INFERIOR (móvil)
   ══════════════════════════════════════════ */
.navigation-bar {
    display:none;
    height: var(--nav-h);
    flex-shrink:0;
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    align-items:center; justify-content:space-around;
}
.nav-item {
    display:flex; flex-direction:column; align-items:center; gap:.2rem;
    color: var(--text-light); text-decoration:none; font-size:.68rem; font-weight:600;
}
.nav-item i { font-size:1.05rem; }
.nav-item.active { color: var(--blue-mid); }

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.ws-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #1e293b; color:#fff; padding:.7rem 1.4rem; border-radius:999px;
    font-size:.85rem; font-weight:600; box-shadow: var(--shadow-lg);
    z-index: 2000; animation: wsToastIn .2s ease;
}
.ws-toast.error { background:#991b1b; }
@keyframes wsToastIn { from { opacity:0; transform:translate(-50%, 12px); } to { opacity:1; transform:translate(-50%,0); } }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 720px) {
    .navigation-bar { display:flex; }
    .ws-picker { left:.5rem; right:.5rem; width:auto; }
    .logo { display:none; }
    .user-info span#userName { display:none; }
}
