/* assets/css/ui-framework.css
   Modern component-based UI for company portal
   - Themeable via CSS variables (set by server)
   - UI variants controlled by body.ui-apple | body.ui-material | body.ui-glass
   - This is the single source of truth for application UI.
*/

/* Base variables (sensible defaults; overridden by inline :root in header) */
:root{
  --bg: #f6f7fb;
  --surface: #ffffff;
  --muted: #7b7f88;
  --text: #0f172a;
  --accent: #3751ff;
  --accent-2: #60a5fa;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-1: 0 6px 20px rgba(15,23,42,0.06);
  --shadow-2: 0 12px 40px rgba(15,23,42,0.08);
  --glass: rgba(255,255,255,0.6);
}

/* Reset & base */
*{box-sizing:border-box}
html,body{height:100%;margin:0;font-family:Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,"Helvetica Neue",Arial;color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}

/* App container */
.app-frame{max-width:1320px;margin:28px auto;padding:18px;}

/* Topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-radius:12px;
  background:var(--surface);
  box-shadow:var(--shadow-1);
}
.topbar .brand{display:flex;gap:12px;align-items:center}
.brand .logo{
  width:48px;height:48px;border-radius:12px;background:linear-gradient(135deg,var(--dark, #222),var(--accent));box-shadow:0 6px 14px rgba(0,0,0,0.04);
  display:inline-block;
}
.topbar h1{font-size:18px;margin:0;font-weight:700}
.topbar .meta{font-size:13px;color:var(--muted)}





/************ SIDEBAR (MODERN, SPACED, SHADOWED, ANIMATED) *****************/

.sidebar {
    width: 240px;
    flex-shrink: 0;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Nav list */
.sidebar .nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* TOP-LEVEL MENU ITEMS */
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 4px 0;
    border-radius: 10px;
    font-weight: 600;
    color: var(--text);
    transition: background .15s;
}

.sidebar .nav-link:hover {
    background: rgba(0,0,0,0.03);
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.03));
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.02);
    color: var(--dark);
}

/* TOP-LEVEL ICON (shaded) */
.sidebar .menu-icon-bg {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.sidebar .menu-icon-bg i {
    font-size: 17px;
    color: var(--accent);
}

/* ACCORDION HEADER */
.sidebar .accordion-toggle {
    width: 100%;
    padding: 12px 6px 12px 4px;
    border: none;
    background: none;
    color: var(--dark);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-radius: 10px;
    transition: background .15s;
}

.sidebar .accordion-toggle:hover {
    background: rgba(0,0,0,0.03);
}

.sidebar .accordion-toggle .acc-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Remove old default caret from sidebar accordion headers */
.sidebar .accordion-toggle::after {
    content: none !important;
}


/* CARET ROTATION */
.sidebar .acc-caret {
    font-size: 14px;
    color: var(--muted);
    transition: transform .25s ease;
}

.sidebar .accordion-body.open + .acc-caret,
.sidebar .accordion-toggle.active .acc-caret {
    transform: rotate(90deg);
}

/* SUBMENU WRAPPER */
.sidebar .accordion-body {
    margin: 4px 0 10px 0;
    padding-left: 10px;

    display: none;
}

.sidebar .accordion-body.open {
    display: block;
}

/* SUBMENU ITEM WRAPPER */
.sidebar .accordion-body ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* SUBMENU LINK – NEW MODERN LOOK */
.sidebar .submenu-link {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 10px 14px;
    margin: 3px 0;

    border-radius: 10px;
    color: var(--text);
    transition: background .12s, transform .12s;
}

/* Hover micro-move and shadow effect */
.sidebar .submenu-link:hover {
    background: rgba(0,0,0,0.04);
    transform: translateX(2px);
}

/* ACTIVE SUBMENU */
.sidebar .submenu-link.active {
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.03));
    font-weight: 600;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.02);
}

/* SUBMENU ICON (mini shadowed container for beauty) */
.sidebar .submenu-icon {
    width: 28px;
    height: 28px;

    border-radius: 8px;
    background: rgba(0,0,0,0.05);

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--accent);
    box-shadow: 0 3px 6px rgba(0,0,0,0.06);
    flex-shrink: 0;
}













/* KPI grid */
.kpi-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:18px}
.kpi{background:var(--surface);padding:18px;border-radius:12px;box-shadow:var(--shadow-1);display:flex;flex-direction:column;gap:8px}
.kpi .label{font-size:13px;color:var(--muted)}
.kpi .value{font-size:28px;font-weight:800;color:var(--dark)}

/* Cards & blocks */
.card{background:var(--surface);padding:16px;border-radius:12px;box-shadow:var(--shadow-1)}
.card .card-title{font-weight:700;margin-bottom:8px}

/* Buttons */
.btn{display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:10px;border:0;cursor:pointer;font-weight:600}
.btn-primary{background:linear-gradient(90deg,var(--accent),var(--accent-2));color:#fff;box-shadow:var(--shadow-2)}
.btn-ghost{background:transparent;border:1px solid rgba(0,0,0,0.06);color:var(--text)}
.btn-accent{background:var(--accent);color:#fff}

/* Tables */
.table { width:100%; border-collapse:collapse; }
.table th, .table td { padding:10px 12px; border-bottom:1px solid rgba(0,0,0,0.04); text-align:left; }

/* Responsive */
@media(max-width:1020px){
  .kpi-grid{grid-template-columns:repeat(2,1fr)}
  .sidebar{width:200px}
}
@media(max-width:700px){
  .app-layout{flex-direction:column}
  .sidebar{width:100%;min-height:auto;max-height:none}
  .kpi-grid{grid-template-columns:1fr}
}

/* UI variant specifics */
/* Apple — soft rounded */
body.ui-apple .topbar { border-radius:18px; }
body.ui-apple .kpi { border-radius:14px; }

/* Material — elevated */
body.ui-material .topbar { box-shadow:0 8px 30px rgba(0,0,0,0.08) }
body.ui-material .card, body.ui-material .kpi { box-shadow:0 12px 40px rgba(2,6,23,0.08); border-radius:12px; }

/* Glass — improved translucent; ensure frost covers entire page while scrolling */
body.ui-glass{
  /* keep gradient but also rely on fixed overlay to avoid sharp edge while scrolling */
  background: linear-gradient(180deg,var(--bg),#ffffffcc);
  -webkit-font-smoothing:antialiased;
}

/* frozen / frost overlay fixed to viewport so it covers full page even when content scrolls */
body.ui-glass::before{
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(255,255,255,0.18);      /* light frosted veil */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 0; /* behind content; content z-index should be > 0 if necessary */
}

/* ensure surface components keep semi-translucent look */
body.ui-glass .topbar,
body.ui-glass .sidebar,
body.ui-glass .card,
body.ui-glass .kpi {
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.24);
  position: relative;
  z-index: 1; /* sit above the page-level frost overlay */
}

.app-frame, 
.app-layout,
.content {
  position: relative;
  z-index: 2; /* above background frost and above frosted components */
}

.app-layout{display:flex;gap:20px;margin-top:16px; align-items:flex-start;}

.content {
    flex: 1;           /* expands naturally */
    min-width: 0;      /* prevents overflow from forcing shrink */
}

/* Page header bar inside content — prevent background blur showing through */
.page-header {
  background: var(--surface);
  padding: 12px 0;
  margin-bottom: 18px;
  position: relative;
  z-index: 3; 
}
@supports (-webkit-overflow-scrolling: touch) {
  .page-header {
    background: var(--surface) !important;
  }
}


/* small utilities */
.hint{color:var(--muted);font-size:13px}
.center{display:flex;align-items:center;justify-content:center}



/* -------------------------
   Accordion + Form (app-wide)
   ------------------------- */

/* Card-like accordion container — consistent with employee-view style */
.accordion {
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
  overflow: hidden;
}

.accordion-toggle {
  display:flex;
  justify-content:space-between;
  align-items:center;
  width:100%;
  background:none;
  border:0;
  padding:16px 20px;
  font-weight:700;
  font-size:15px;
  cursor:pointer;
}
.accordion-toggle::after{ content:'▸'; opacity:0.6; transition:transform .15s; }
.accordion.open .accordion-toggle::after{ transform: rotate(90deg); }

/* body */
.accordion-body { padding:20px; display:none; color:var(--muted); font-size:14px; background:transparent; }
.accordion.open .accordion-body { display:block; }

/* form grid utility (2-3 columns depending on width) */
.form-grid {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap:16px 20px;
  margin-top:10px;
}
.form-grid label{ display:flex; flex-direction:column; gap:6px; font-weight:600; color:var(--dark); }

/* form inputs */
.ess-form input, .ess-form select, .ess-form textarea {
  width:100%;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid rgba(0,0,0,0.1);
  background:var(--surface);
}

/* login box (used inside accordions) */
.login-box { padding:14px; border-radius:10px; border:1px solid rgba(0,0,0,0.06); background:var(--bg); margin-top:12px; }

/* contract row */
.contractRow { display:flex; gap:10px; align-items:center; margin-bottom:8px; }

/* small helpers for pages */
.card .card-title { margin-bottom: 12px; font-weight:700; }

/* toast (placed at top-right by JS) - default neutral theme; overrideable */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 14px;
  border-radius:8px;
  color:#fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  z-index: 99999;
  cursor: pointer;
}
.toast-success { background: linear-gradient(90deg,var(--accent),var(--dark)); }
.toast-error { background: #d63a3a; }

/* utility: small responsive */
@media(max-width:700px){
  .form-grid{ grid-template-columns: 1fr; gap:10px; }
  .app-frame{ padding:12px; }
  .accordion-toggle{ padding:12px 14px; }
}

/* ============================
   ROLES PAGE — Action Row Layout
   Safe, isolated, non-conflicting
============================ */

/* Wrapper holding rename, permissions, delete */
.role-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

/* Rename form (input + button inline) */
.rename-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Consistent text box for renaming */
.rename-input {
    padding: 9px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    width: 180px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

/* Create role form aligned horizontally */
.role-create-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Mobile stacking */
@media (max-width: 700px) {
    .role-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 0;
    }

    .rename-input,
    .role-create-form {
        width: 100%;
    }

    .role-create-form {
        flex-direction: column;
    }
}


.contracts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.contract-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 10px 12px;
}

.contract-meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.contract-meta .icon {
  font-size: 20px;
  opacity: 0.8;
}

.contract-label {
  font-size: 13px;
  font-weight: 600;
}

.contract-expiry {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.contract-actions {
  display: flex;
  gap: 6px;
}

.contractRow {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}

.contractRow textarea {
  grid-column: span 2;
}

.contractRow .removeContractRow {
  color: #991b1b;
}

