/* ============================================================
   workspace-main.css — Efficius Workspace Design System
   ============================================================ */

/* ------------------------------------------------------------
   1. Tokens
   ------------------------------------------------------------ */
:root {
  --blue:       #0071e3;
  --blue-dark:  #0064c8;
  --blue-light: #eff6ff;
  --green:      #059669;
  --green-light:#ecfdf5;
  --red:        #dc2626;
  --red-light:  #fef2f2;
  --amber:      #d97706;
  --amber-light:#fffbeb;

  --text:       #111827;
  --text-2:     #374151;
  --muted:      #6b7280;
  --subtle:     #9ca3af;

  --bg:         #f3f4f6;
  --bg-card:    #ffffff;
  --border:     #e5e7eb;
  --border-2:   #d1d5db;

  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-full:980px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  --topbar-h:   56px;
  --sidebar-w:  240px;
  --font:       'Public Sans', 'Segoe UI', Arial, sans-serif;
}

/* ------------------------------------------------------------
   2. Reset
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul, ol { list-style: none; }

/* ------------------------------------------------------------
   3. Layout
   ------------------------------------------------------------ */
.ws-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

.ws-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--topbar-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.ws-sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.ws-main {
  grid-column: 2;
  grid-row: 2;
  padding: 28px 32px;
  min-width: 0;
  overflow-x: hidden;
}

/* No sidebar variant */
.ws-layout.no-sidebar { grid-template-columns: 1fr; }
.ws-layout.no-sidebar .ws-main { grid-column: 1; }

/* ------------------------------------------------------------
   4. Topbar
   ------------------------------------------------------------ */
.ws-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.2px;
  text-decoration: none;
  flex-shrink: 0;
}

.ws-topbar-brand:hover { text-decoration: none; color: var(--text); }

.ws-topbar-brand-icon {
  width: 28px;
  height: 28px;
  background: var(--bg);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.ws-topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.ws-topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.ws-topbar-link:hover,
.ws-topbar-link.active {
  background: rgba(0,0,0,.05);
  color: var(--text);
  text-decoration: none;
}

.ws-topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Avatar + dropdown */
.ws-avatar-wrap { position: relative; }

.ws-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}

.ws-avatar-btn:hover { background: var(--blue-dark); }

.ws-user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 9999;
  overflow: hidden;
}

.ws-user-menu.open { display: block; }

.ws-user-menu-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.ws-user-menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ws-user-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.ws-user-menu-email {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.ws-user-menu-divider { height: 1px; background: var(--bg); }

.ws-user-menu-item {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: background .1s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.ws-user-menu-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.ws-user-menu-item.danger { color: var(--red); }
.ws-user-menu-item.danger:hover { background: var(--red-light); color: var(--red); }

/* Empresa selector */
.ws-topbar-empresa {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
  font-family: var(--font);
  max-width: 200px;
}

.ws-topbar-empresa:focus { border-color: var(--blue); }

.ws-topbar-empresa-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Icon button in topbar */
.ws-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  position: relative;
}

.ws-icon-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }

.ws-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid #fff;
}

/* ------------------------------------------------------------
   5. Sidebar
   ------------------------------------------------------------ */
.ws-sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--subtle);
  padding: 6px 8px 4px;
  margin-top: 12px;
}

.ws-sidebar-label:first-child { margin-top: 0; }

.ws-sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background .1s, color .1s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.ws-sidebar-item svg { flex-shrink: 0; color: var(--muted); }

.ws-sidebar-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.ws-sidebar-item:hover svg { color: var(--text-2); }

.ws-sidebar-item.active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

.ws-sidebar-item.active svg { color: var(--blue); }

/* ------------------------------------------------------------
   5b. Sidebar collapse toggle
   ------------------------------------------------------------ */
.ws-layout { transition: grid-template-columns .25s ease; }

.ws-layout.sidebar-collapsed { grid-template-columns: 0px 1fr; }

.ws-layout.sidebar-collapsed .ws-sidebar {
  overflow: hidden;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
}

.ws-sidebar { transition: padding .25s ease, opacity .18s ease, border-color .18s ease; }

.ws-sidebar-toggle {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ws-sidebar-toggle:hover { background: var(--bg); color: var(--text); }

/* ------------------------------------------------------------
   6. Page header
   ------------------------------------------------------------ */
.ws-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.ws-page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  line-height: 1.3;
}

.ws-page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* ------------------------------------------------------------
   7. Cards
   ------------------------------------------------------------ */
.ws-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.ws-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.ws-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.ws-card-body { font-size: 13px; color: var(--text-2); }

/* Stat card */
.ws-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.ws-stat-value { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -.5px; line-height: 1; }
.ws-stat-meta  { font-size: 12px; color: var(--muted); }
.ws-stat-meta .up   { color: var(--green); font-weight: 600; }
.ws-stat-meta .down { color: var(--red);   font-weight: 600; }

/* ------------------------------------------------------------
   8. Buttons
   ------------------------------------------------------------ */
.ws-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, opacity .15s, transform .12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  font-family: inherit;
}

.ws-btn:hover { text-decoration: none; }
.ws-btn:disabled { opacity: .55; pointer-events: none; }

.ws-btn-primary  { background: var(--blue); color: #fff; box-shadow: 0 2px 16px rgba(0,113,227,.28); }
.ws-btn-primary:hover  { background: var(--blue-dark); box-shadow: 0 4px 24px rgba(0,113,227,.38); transform: scale(1.02); }
.ws-btn-primary:active { background: var(--blue-dark); transform: scale(.99); }

.ws-btn-outline  { background: transparent; color: var(--text-2); border: 1.5px solid var(--border-2); }
.ws-btn-outline:hover { border-color: var(--muted); color: var(--text); }

.ws-btn-danger   { background: var(--red);    color: #fff; }
.ws-btn-danger:hover { background: #b91c1c; }

.ws-btn-secondary { background: var(--bg-card); color: var(--text-2); border: 1.5px solid var(--border); }
.ws-btn-secondary:hover { background: var(--bg); color: var(--text); border-color: var(--border-2); }

.ws-btn-ghost    { background: transparent; color: var(--text-2); }
.ws-btn-ghost:hover { background: var(--bg); color: var(--text); }

.ws-btn-sm { padding: 5px 12px; font-size: 12px; }
.ws-btn-lg { padding: 11px 22px; font-size: 14px; }

/* Loading state */
.ws-btn.loading { opacity: .7; pointer-events: none; }
.ws-btn .ws-spinner { display: none; animation: ws-spin .7s linear infinite; }
.ws-btn.loading .ws-spinner { display: block; }

@keyframes ws-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   9. Forms
   ------------------------------------------------------------ */
.ws-form-group { margin-bottom: 16px; }

.ws-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ws-input,
.ws-select,
.ws-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.ws-input::placeholder,
.ws-textarea::placeholder { color: var(--subtle); }

.ws-input:focus,
.ws-select:focus,
.ws-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10,102,194,.1);
}

.ws-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

.ws-input-wrap { position: relative; display: flex; align-items: center; }
.ws-input-wrap .ws-input { padding-right: 38px; }

.ws-input-icon {
  position: absolute;
  right: 10px;
  color: var(--subtle);
  display: flex;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  transition: color .15s;
}

.ws-input-icon:hover { color: var(--text-2); }

.ws-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.ws-hint.error { color: var(--red); }

/* ------------------------------------------------------------
   10. Badges
   ------------------------------------------------------------ */
.ws-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ws-badge-blue   { background: var(--blue-light);  color: var(--blue);  }
.ws-badge-green  { background: var(--green-light); color: var(--green); }
.ws-badge-red    { background: var(--red-light);   color: var(--red);   }
.ws-badge-amber  { background: var(--amber-light); color: var(--amber); }
.ws-badge-gray   { background: var(--bg);          color: var(--muted); }

/* ------------------------------------------------------------
   11. Tables
   ------------------------------------------------------------ */
.ws-table-wrap { overflow-x: auto; }

.ws-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ws-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ws-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

.ws-table tbody tr:last-child td { border-bottom: none; }
.ws-table tbody tr:hover td { background: var(--bg); }

/* ------------------------------------------------------------
   12. Modals
   ------------------------------------------------------------ */
.ws-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.ws-overlay.open { opacity: 1; pointer-events: all; }

.ws-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform .2s;
}

.ws-overlay.open .ws-modal { transform: translateY(0); }

.ws-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.ws-modal-title { font-size: 16px; font-weight: 700; color: var(--text); }

.ws-modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.ws-modal-close:hover { background: var(--bg); color: var(--text); }

.ws-modal-body { padding: 16px 24px 24px; }

.ws-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 20px;
}

/* ------------------------------------------------------------
   13. Alerts / Toasts
   ------------------------------------------------------------ */
.ws-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}

.ws-alert-blue   { background: var(--blue-light);  color: #1e40af; border-color: #bfdbfe; }
.ws-alert-green  { background: var(--green-light); color: #065f46; border-color: #a7f3d0; }
.ws-alert-red    { background: var(--red-light);   color: #991b1b; border-color: #fecaca; }
.ws-alert-amber  { background: var(--amber-light); color: #78350f; border-color: #fde68a; }

/* Toast stack */
#ws-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ws-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  min-width: 240px;
  max-width: 360px;
  pointer-events: all;
  animation: ws-toast-in .25s ease;
}

.ws-toast.success { background: var(--green); }
.ws-toast.error   { background: var(--red);   }
.ws-toast.warning { background: var(--amber); }

@keyframes ws-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   14. Divider
   ------------------------------------------------------------ */
.ws-divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ------------------------------------------------------------
   15. Grid helpers
   ------------------------------------------------------------ */
.ws-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.ws-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ws-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 1024px) {
  .ws-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .ws-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .ws-grid-4,
  .ws-grid-3,
  .ws-grid-2 { grid-template-columns: 1fr; }

  .ws-layout {
    grid-template-columns: 1fr;
  }

  .ws-sidebar { display: none; }
  .ws-main { grid-column: 1; padding: 16px; }
}

/* ------------------------------------------------------------
   16. Utilities
   ------------------------------------------------------------ */
.ws-flex   { display: flex; }
.ws-flex-center { display: flex; align-items: center; justify-content: center; }
.ws-gap-8  { gap: 8px; }
.ws-gap-12 { gap: 12px; }
.ws-gap-16 { gap: 16px; }

.ws-text-sm  { font-size: 12px; }
.ws-text-md  { font-size: 14px; }
.ws-text-muted { color: var(--muted); }
.ws-text-bold  { font-weight: 700; }

.ws-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.ws-mt-8  { margin-top: 8px; }
.ws-mt-16 { margin-top: 16px; }
.ws-mt-24 { margin-top: 24px; }
.ws-mb-8  { margin-bottom: 8px; }
.ws-mb-16 { margin-bottom: 16px; }
.ws-mb-24 { margin-bottom: 24px; }
