:root{
  --gfc-border:#e5e7eb;
  --gfc-bg:#fff;
  --gfc-muted:#6b7280;
  --gfc-black:#111827;
  --gfc-link:#2563eb;

  --gfc-btn-radius:999px;
  --gfc-btn-height:36px;
  --gfc-btn-pad-x:14px;
  --gfc-btn-font:13px;

  --gfc-input-radius:999px;
  --gfc-input-height:36px;
  --gfc-input-pad-x:14px;
  --gfc-input-font:13px;
}

#gfc-app{ font-family: inherit; }
body .gfc-modal{ font-family: inherit; }

/* =========================================================
   BASE (scoped)
   ========================================================= */
#gfc-app .gfc-card{
  background:var(--gfc-bg);
  border:1px solid var(--gfc-border);
  border-radius:10px;
  padding:12px;
  overflow:hidden; /* evita “sangrar” com tabelas largas */
}

#gfc-app .gfc-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}

#gfc-app .gfc-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

#gfc-app .gfc-path code,
#gfc-app .gfc-filesbar code{
  background:#f3f4f6;
  padding:2px 6px;
  border-radius:6px;
}

/* Botões / inputs */
#gfc-app .gfc-btn{
  border:1px solid var(--gfc-border);
  background:#f9fafb;
  cursor:pointer;
}

#gfc-app .gfc-btn--primary{
  background:var(--gfc-black);
  color:#fff;
  border-color:var(--gfc-black);
}

#gfc-app .gfc-btn:disabled{
  opacity:.5;
  cursor:not-allowed;
}

#gfc-app .gfc-input{
border:1px solid var(--gfc-border);
}

/* Inputs full width inside fields (ex: Opções templates) */
#gfc-app .gfc-field .gfc-input{width:100%; box-sizing:border-box;}
#gfc-app .gfc-field textarea.gfc-input{border-radius: 0;}

/* Path picker (input + button) */
#gfc-app .gfc-pathpick{display:flex; gap:8px; align-items:center;}
#gfc-app .gfc-pathpick .gfc-input{flex:1; min-width:0;}
#gfc-app .gfc-pathpick .gfc-btn{white-space:nowrap;}

/* Opções: WP editor full width */
#gfc-app .gfc-options .wp-editor-wrap,
#gfc-app .gfc-options .wp-editor-container{max-width:100%; width:100%; box-sizing:border-box;}
#gfc-app .gfc-options .wp-editor-area{width:100% !important; box-sizing:border-box;}


#gfc-app .gfc-small{font-size:12px;color:var(--gfc-muted);}
#gfc-app .gfc-muted{color:rgba(0,0,0,.55);}

#gfc-app .gfc-hr{height:1px;background:var(--gfc-border);margin:10px 0;}

/* Links / badges */
#gfc-app .gfc-rowlink{color:var(--gfc-link);text-decoration:none;}
#gfc-app .gfc-rowlink:hover{text-decoration:underline;}

#gfc-app .gfc-badge{
  display:inline-block;
  border:1px solid var(--gfc-border);
  border-radius:999px;
  padding:2px 8px;
  font-size:12px;
  color:var(--gfc-muted);
  white-space:nowrap;
}

/* Notices / layout */
#gfc-app .gfc-notice{
  border:1px solid var(--gfc-border);
  border-radius:10px;
  padding:10px;
  margin:0 0 10px 0;
}
#gfc-app .gfc-notice--warn{
  background:#fff7ed;
  border-color:#fed7aa;
}

#gfc-app .gfc-grid{display:grid;gap:10px;}
@media (min-width:900px){
  #gfc-app .gfc-grid{grid-template-columns:2fr 1fr;}
}

#gfc-app .gfc-list{
  max-height:540px;
  overflow:auto;
  border:1px solid var(--gfc-border);
  border-radius:10px;
}

/* Tabs */
#gfc-app .gfc-tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

#gfc-app .gfc-tab{
  border:1px solid var(--gfc-border);
  background:#f9fafb;
  cursor:pointer;
}

#gfc-app .gfc-tab.is-active,
#gfc-app .gfc-tab--active{
  background:var(--gfc-black);
  color:#fff;
  border-color:var(--gfc-black);
}

/* Drag & drop upload */
#gfc-app .gfc-drop{
  border:2px dashed var(--gfc-border);
  border-radius:10px;
  padding:10px;
  margin-bottom:10px;
  text-align:center;
  font-size:13px;
  color:var(--gfc-muted);
}
#gfc-app .gfc-drop--over{
  background:#eef2ff;
  border-color:#4f46e5;
}

/* Barra de caminho / pasta atual */
#gfc-app .gfc-filesbar{
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px 0 10px;
  flex-wrap:nowrap;
}

#gfc-app .gfc-current-folder{
  display:flex;
  align-items:center;
  gap:6px;
  min-width:0;
}

#gfc-app .gfc-current-folder code{
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:inline-block;
  margin:auto;
}

/* Preview */
#gfc-app .gfc-preview{
  border:1px solid var(--gfc-border);
  border-radius:10px;
  padding:8px;
  margin-top:10px;
  min-height:80px;
}
#gfc-app .gfc-preview__body{max-height:260px;overflow:auto;margin-top:6px;}

#gfc-app .gfc-thumb{
  width:40px;height:40px;
  object-fit:cover ;
  border-radius:6px;
  border:1px solid var(--gfc-border);
  vertical-align:middle;
}

/* Pesquisa + quota no canto inferior direito */
#gfc-app .gfc-search-row{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center;
  margin-top:8px;
}

#gfc-app .gfc-footer-row{
  display:flex;
  gap:12px;
  justify-content:space-between;
  align-items:flex-end;
  flex-wrap:wrap;
}
#gfc-app .gfc-search-wrap{flex:1 1 520px; min-width:260px;}
#gfc-app .gfc-badge--quota{ margin-left:auto; }

/* =========================================================
   MODAIS
   NOTA: o modal é injectado no <body>, por isso não pode ser 100% scoped a #gfc-app.
   ========================================================= */
body .gfc-modal-backdrop{
  position:fixed !important;
  top:0; right:0; bottom:0; left:0;
  width:100vw;
  height:100vh;
  background:rgba(0,0,0,.35);
  display:flex !important;
  align-items:center;
  justify-content:center;
  z-index:999999;
  padding:16px;
  overflow:auto;
}
@supports (inset:0){
  body .gfc-modal-backdrop{inset:0;}
}

body .gfc-modal{
  width:min(520px, 100%);
  background:#fff;
  border:1px solid var(--gfc-border);
  border-radius:14px;
  box-shadow:0 12px 30px rgba(0,0,0,.18);
  overflow:hidden;
  margin:auto;
  max-height:calc(100vh - 32px);
  display:flex;
  flex-direction:column;}

body .gfc-modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid var(--gfc-border);
  background:#fafafa;
}
body .gfc-modal__title{font-weight:700;}

body .gfc-modal__close{
  border:1px solid var(--gfc-border);
  background:#fff;
  cursor:pointer;
}

body .gfc-modal__body{
  padding:14px;
  overflow:auto;
  min-height: 110px;
}

body .gfc-modal__footer{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  padding:12px 14px;
  border-top:1px solid var(--gfc-border);
  background:#fafafa;
}

/* Variantes de largura (ex: modal de grupos) */
body .gfc-modal.gfc-modal--wide,
body .gfc-modal.gfc-modal--groups{
  width:min(980px, 100%);
}

/* Campos / ajuda (modais) */
body .gfc-field{margin-bottom:10px;}
body .gfc-label{display:block;font-size:13px;font-weight:500;color:var(--gfc-muted);margin-bottom:4px;}
body .gfc-help{font-size:12px;color:var(--gfc-muted);}

/* rows em formulários/modais */
body .gfc-form-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
}
body .gfc-form-row > .gfc-field{
  min-width:160px;
}

/* 2 colunas (campos) — usado no modal de grupos */
body .gfc-form-row--2col{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
  align-items:end;
}
@media (max-width:640px){
  body .gfc-form-row--2col{ grid-template-columns:1fr; }
}

/* Permissões inline (4 colunas) — Ler / Escrever / Apagar / Adicionar */
body .gfc-perms-row{
  display:flex;
  gap:10px;
  align-items:end;
}
body .gfc-perms-row label{
  display:flex;
  gap:8px;
  align-items:center;
  white-space:nowrap;
}
body .gfc-perms-row .gfc-btn{
  justify-self:end;
}
@media (max-width:820px){
  body .gfc-perms-row{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:10px;
    align-items:end;
  }
  body .gfc-perms-row .gfc-btn{
    justify-self:stretch;
  }
}

/* select2-like (admin modal grupos) */
body .gfc-select2{position:relative;}
body .gfc-select2 input{width:100%;}
body .gfc-select2-dd{
  position:absolute;
  left:0; right:0;
  top:calc(100% + 6px);
  background:#fff;
  border:1px solid rgba(0,0,0,.12);
  border-radius:12px;
  box-shadow:0 10px 30px rgba(0,0,0,.08);
  max-height:260px;
  overflow:auto;
  z-index:1000000;
}
body .gfc-select2-item{
  display:block;
  width:100%;
  text-align:left;
  padding:10px 12px;
  border:0;
  background:transparent;
  cursor:pointer;
}
body .gfc-select2-item:hover{background:rgba(0,0,0,.03);}

body .gfc-user-hit{
  border:1px solid rgba(0,0,0,.08);
  border-radius:10px;
  padding:10px;
  margin:8px 0;
  background:#fff;
}
body .gfc-user-hit code{font-size:12px;}

/* =========================================================
   TABELAS (scoped)
   ========================================================= */
#gfc-app table.gfc-table{
  width:100%;
  border-collapse:collapse;
  border-spacing:0;
}

/* Reset SCOPED contra temas “responsive table” */
#gfc-app table.gfc-table,
#gfc-app table.gfc-table thead,
#gfc-app table.gfc-table tbody,
#gfc-app table.gfc-table tfoot,
#gfc-app table.gfc-table tr,
#gfc-app table.gfc-table th,
#gfc-app table.gfc-table td{
  display:revert !important;
}

@supports not (display:revert){
  #gfc-app table.gfc-table{display:table !important;}
  #gfc-app table.gfc-table thead{display:table-header-group !important;}
  #gfc-app table.gfc-table tbody{display:table-row-group !important;}
  #gfc-app table.gfc-table tfoot{display:table-footer-group !important;}
  #gfc-app table.gfc-table tr{display:table-row !important;}
  #gfc-app table.gfc-table th,
  #gfc-app table.gfc-table td{display:table-cell !important;}
}

#gfc-app table.gfc-table th,
#gfc-app table.gfc-table td{
  border-top:1px solid var(--gfc-border);
  padding:8px;
  text-align:left;
  font-size:14px;
  vertical-align:middle;
  box-sizing:border-box;
  white-space:nowrap;
}

#gfc-app table.gfc-table thead th{
  background:#fafafa;
  color:var(--gfc-muted);
  font-weight:600;
}

/* Inputs dentro de células */
#gfc-app table.gfc-table input,
#gfc-app table.gfc-table select,
#gfc-app table.gfc-table textarea{
  max-width:100%;
  box-sizing:border-box;
}

/* Botões dentro de célula */
#gfc-app table.gfc-table td .gfc-btn{ margin-right:6px; }
#gfc-app table.gfc-table td .gfc-btn:last-child{ margin-right:0; }

/* ---------- Ficheiros ---------- */
#gfc-app table.gfc-table--files{
  table-layout:auto;
  min-width:920px;
}
#gfc-app table.gfc-table--files th:nth-child(1),
#gfc-app table.gfc-table--files td:nth-child(1){
  width:36px;
  min-width:36px;
  text-align:center;
}
#gfc-app table.gfc-table--files td:nth-child(1) input[type="checkbox"]{margin:0;}

#gfc-app table.gfc-table--files th:nth-child(2),
#gfc-app table.gfc-table--files td:nth-child(2){min-width:360px;}
#gfc-app table.gfc-table--files td:nth-child(2){
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#gfc-app table.gfc-table--files th:nth-child(3),
#gfc-app table.gfc-table--files td:nth-child(3){width:110px;}
#gfc-app table.gfc-table--files th:nth-child(4),
#gfc-app table.gfc-table--files td:nth-child(4){width:120px;}
#gfc-app table.gfc-table--files th:nth-child(5),
#gfc-app table.gfc-table--files td:nth-child(5){width:160px;}
#gfc-app table.gfc-table--files th:last-child,
#gfc-app table.gfc-table--files td:last-child{
  width:200px;
  min-width:200px;
  white-space:nowrap;
}

/* ---------- Partilhas ---------- */
#gfc-app table.gfc-table--shares{
  table-layout:fixed;
  min-width:1100px;
}
#gfc-app table.gfc-table--shares th:nth-child(1),
#gfc-app table.gfc-table--shares td:nth-child(1){width:60px;min-width:60px;}
#gfc-app table.gfc-table--shares th:nth-child(2),
#gfc-app table.gfc-table--shares td:nth-child(2){
  width:300px;
  min-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#gfc-app table.gfc-table--shares th:nth-child(3),
#gfc-app table.gfc-table--shares td:nth-child(3){width:190px;min-width:190px;}
#gfc-app table.gfc-table--shares th:nth-child(4),
#gfc-app table.gfc-table--shares td:nth-child(4){width:120px;min-width:120px;}
#gfc-app table.gfc-table--shares th:nth-child(5),
#gfc-app table.gfc-table--shares td:nth-child(5){min-width:420px;}
#gfc-app table.gfc-table--shares td:nth-child(5) input,
#gfc-app table.gfc-table--shares td:nth-child(5) textarea{
  width:100%;
  max-width:100%;
  box-sizing:border-box;
}
#gfc-app table.gfc-table--shares th:last-child,
#gfc-app table.gfc-table--shares td:last-child{width:240px;min-width:240px;white-space:nowrap;}

/* ---------- Clientes ---------- */
#gfc-app table.gfc-table--clients{table-layout:fixed;min-width:1100px;}
#gfc-app table.gfc-table--clients th:nth-child(1),
#gfc-app table.gfc-table--clients td:nth-child(1){width:220px;}
#gfc-app table.gfc-table--clients th:nth-child(2),
#gfc-app table.gfc-table--clients td:nth-child(2){width:240px;}
#gfc-app table.gfc-table--clients th:nth-child(3),
#gfc-app table.gfc-table--clients td:nth-child(3){width:160px;}
#gfc-app table.gfc-table--clients th:nth-child(4),
#gfc-app table.gfc-table--clients td:nth-child(4){width:180px;}
#gfc-app table.gfc-table--clients th:nth-child(5),
#gfc-app table.gfc-table--clients td:nth-child(5){width:110px;}
#gfc-app table.gfc-table--clients th:nth-child(6),
#gfc-app table.gfc-table--clients td:nth-child(6){width:140px;}
#gfc-app table.gfc-table--clients th:last-child,
#gfc-app table.gfc-table--clients td:last-child{width:140px;text-align:right;white-space:nowrap;}

/* ---------- Grupos ---------- */
#gfc-app table.gfc-table--groups{table-layout:fixed;min-width:960px;}
#gfc-app table.gfc-table--groups th:nth-child(1),
#gfc-app table.gfc-table--groups td:nth-child(1){width:240px;}
#gfc-app table.gfc-table--groups th:nth-child(2),
#gfc-app table.gfc-table--groups td:nth-child(2){width:220px;}
#gfc-app table.gfc-table--groups th:nth-child(3),
#gfc-app table.gfc-table--groups td:nth-child(3){width:120px;}
#gfc-app table.gfc-table--groups th:nth-child(4),
#gfc-app table.gfc-table--groups td:nth-child(4){width:120px;}
#gfc-app table.gfc-table--groups th:last-child,
#gfc-app table.gfc-table--groups td:last-child{width:220px;text-align:right;white-space:nowrap;}

/* ---------- Logs ---------- */
#gfc-app table.gfc-table--logs{table-layout:fixed;min-width:1300px;}
#gfc-app table.gfc-table--logs th:nth-child(1),
#gfc-app table.gfc-table--logs td:nth-child(1){width:170px;}
#gfc-app table.gfc-table--logs th:nth-child(2),
#gfc-app table.gfc-table--logs td:nth-child(2){width:110px;}
#gfc-app table.gfc-table--logs th:nth-child(3),
#gfc-app table.gfc-table--logs td:nth-child(3){width:90px;}
#gfc-app table.gfc-table--logs th:nth-child(4),
#gfc-app table.gfc-table--logs td:nth-child(4){width:120px;}
#gfc-app table.gfc-table--logs th:nth-child(5),
#gfc-app table.gfc-table--logs td:nth-child(5){
  width:420px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#gfc-app table.gfc-table--logs th:nth-child(6),
#gfc-app table.gfc-table--logs td:nth-child(6){
  width:380px;
  white-space:normal;
  word-break:break-word;
}


/* Paginação (Clientes / Logs) */
#gfc-app .gfc-pager{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:10px 0;
}
#gfc-app .gfc-pager__info{
  font-size:13px;
  color:var(--gfc-black);
  white-space:nowrap;
}
@media (max-width: 700px){
  #gfc-app .gfc-pager{flex-wrap:wrap; justify-content:flex-start;}
  #gfc-app .gfc-pager__info{width:100%;}
}

#gfc-app .gfc-btn,
#gfc-app .gfc-tab,
body .gfc-modal__close,
body .gfc-modal .gfc-btn{
  border-radius:var(--gfc-btn-radius);
  min-height:var(--gfc-btn-height);
  padding:0 var(--gfc-btn-pad-x);
  font-size:var(--gfc-btn-font);
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  box-sizing:border-box;
  white-space:nowrap;
}

/* Inputs uniformes (inclui select) */
#gfc-app .gfc-input,
body .gfc-modal .gfc-input{
  border-radius:var(--gfc-input-radius);
  min-height:var(--gfc-input-height);
  padding:0 var(--gfc-input-pad-x);
  font-size:var(--gfc-input-font);
  line-height:1.2;
  box-sizing:border-box;
}

/* Textareas: padding confortável */
#gfc-app textarea.gfc-input,
body .gfc-modal textarea.gfc-input{
  padding:10px var(--gfc-input-pad-x);
  min-height:90px;
}
textarea#gfc-opt-admin-emails {
    border-radius: 5px !important;
}
/* Selects: espaço para caret */
#gfc-app select.gfc-input,
body .gfc-modal select.gfc-input{
  padding-right:calc(var(--gfc-input-pad-x) + 14px);
}


/* Highlight de ficheiro via link (email) */
#gfc-app tr.gfc-row.gfc-row--highlight{ outline:2px solid var(--gfc-link, #2563eb); outline-offset:-2px; }
