/* =================================
   GLOBAL WIDTH SAFETY
================================= */

html,
body{
  max-width:100%;
  overflow-x:hidden;
}

/* WordPress admin containers */

#wpwrap,
#wpcontent,
#wpbody,
#wpbody-content{
  max-width:100%;
  overflow-x:hidden;
}

/* ensure all layout elements stay inside screen */

*,
*::before,
*::after{
  box-sizing:border-box;
}

/* =================================
   GLOBAL WRAPPER — FULL WIDTH
================================= */

.h5p-frontlib-wrap{
  width:100%;
  max-width:100%;
  margin:20px 0;
  padding:20px;
  background:#fff;
  border-radius:14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 8px 24px rgba(0,0,0,0.04);
  overflow-x:hidden;
}


/* =================================
   ADMIN HEADER
================================= */

.h5p-admin-header{
  width:100%;
  padding:24px 28px;
  border-radius:14px;
  margin-bottom:20px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  background:linear-gradient(135deg,#2563eb 0%,#7c3aed 100%);
}

.h5p-admin-header h1{
  margin:0;
  font-size:26px;
  font-weight:700;
  color:#fff;
}

.h5p-add-new-btn{
  padding:9px 20px;
  border-radius:999px;
  font-weight:600;
  font-size:13px;
  text-decoration:none;
  color:#fff;
  background:linear-gradient(135deg,#facc15,#fb923c,#ef4444);
  box-shadow:0 6px 20px rgba(0,0,0,0.25);
  transition:.2s ease;
}

.h5p-add-new-btn:hover{
  transform:translateY(-2px);
}

/* =================================
   TOOLBAR — COMPACT + BALANCED
================================= */

.h5p-toolbar{

  display:grid;

  grid-template-columns:
    auto   /* show entries */
    200px  /* scope */
    200px  /* type */
    1fr;   /* search */

  gap:24px;
  align-items:center;

  padding:12px 16px;
  margin-bottom:16px;

  background:#f8fafc;
  border-radius:12px;
  border:1px solid #eef2f7;
}

/* breathing room between filters */

.h5p-toolbar select{
  width:100%;
  height:36px;
  padding:0 10px;
}

.h5p-toolbar .dataTables_filter input{
  width:100%;
  height:36px;
  padding:0 10px;
}

/* normalize DataTables wrappers */

/* normalize DataTables wrappers */

.h5p-toolbar .dataTables_length{
  margin:0;
  height:36px;
  display:flex;
  align-items:center;
}

/* SEARCH FIX */

.h5p-toolbar .dataTables_filter{
  display:flex;
  align-items:center;
  gap:8px;
  height:36px;
}

.h5p-toolbar .dataTables_filter label{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
}

.h5p-toolbar .dataTables_filter input{
  height:36px;
  margin:0;
}

/* search input */

.h5p-toolbar .dataTables_filter input{
  width:100%;
  height:36px;
  margin-left:8px;
}

/* label alignment */

.h5p-toolbar .dataTables_length label{
  display:flex;
  align-items:center;
  gap:6px;
}


/* =================================
   TAG CLOUD
================================= */

#h5p-tag-cloud{
  margin:18px 0;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

#h5p-tag-cloud .h5p-tag-cloud-item{
  padding:6px 14px;
  background:#f6f7f7;
  border-radius:999px;
  font-weight:600;
  cursor:pointer;
  transition:.2s ease;
}

#h5p-tag-cloud .h5p-tag-cloud-item:hover{
  background:#2271b1;
  color:#fff;
}

#h5p-tag-cloud .h5p-tag-cloud-item.active-tag{
  background:#4f46e5!important;
  color:#fff!important;
  box-shadow:0 4px 14px rgba(79,70,229,0.35);
}


/* =================================
   TABLE STABILITY
================================= */

#h5p-frontlib-table{
  width:100%;
  table-layout:auto;
}

#h5p-frontlib-table th{
  white-space:nowrap;
}

#h5p-frontlib-table td{
  vertical-align:middle;
}

/* prevent datatables overflow */

.dataTables_wrapper{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

#h5p-frontlib-table{
  width:100%;
  max-width:100%;
}


/* =================================
   ACTION BUTTONS
================================= */

#h5p-frontlib-table td:nth-child(1),
#h5p-frontlib-table td:nth-child(2){
  text-align:left;
  white-space:nowrap;
  padding-left:6px;
}

/* base button style */

.h5p-view-btn,
.h5p-edit-btn{
  display:inline-block;
  padding:6px 12px;
  font-size:12px;
  font-weight:600;
  border-radius:6px;
  text-decoration:none;
  line-height:1;
  margin:0;
  border:1px solid transparent;
}

/* Student View — soft blue */

.h5p-view-btn{
  background:#e8f1ff;
  color:#2b5fb8;
  border-color:#d6e6ff;
}

.h5p-view-btn:hover{
  background:#dbe9ff;
  border-color:#c7dbff;
}

/* Teacher's Panel — soft peach */

.h5p-edit-btn{
  background:#fff1e8;
  color:#c75b1c;
  border-color:#ffd9c2;
}

.h5p-edit-btn:hover{
  background:#ffe7d6;
  border-color:#ffc9a6;
}

/* =================================
   PAGINATION
================================= */

.dataTables_paginate{
  margin-top:14px;
}

.dataTables_paginate .paginate_button{
  border-radius:6px!important;
  padding:5px 9px!important;
  margin:0 3px!important;
  border:1px solid #e5e7eb!important;
  background:#fff!important;
  font-size:13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current{
  background:#4f46e5!important;
  border-color:#4f46e5!important;
  color:#fff!important;
}


/* =================================
   MISC
================================= */

.wrap{
  max-width:100%!important;
}

#wpcontent,
#wpbody-content{
  overflow-x:hidden!important;
}

.h5p-team-dot{
  display:inline-block;
  width:9px;
  height:9px;
  border-radius:50%;
  margin-left:6px;
  vertical-align:middle;
}

/* =================================
   MOBILE CARD VIEW — FINAL
================================= */

@media (max-width:760px){

  /* --------------------------------
     GLOBAL MOBILE SAFETY
  -------------------------------- */

  .wrap,
  .h5p-frontlib-wrap{
    width:100%;
    max-width:100%;
    padding-left:12px;
    padding-right:12px;
    margin:0 auto;
  }

  .h5p-frontlib-wrap{
    padding:16px 12px;
  }


  /* --------------------------------
     TABLE → CARD CONVERSION
  -------------------------------- */

  #h5p-frontlib-table,
  #h5p-frontlib-table tbody{
    display:block;
    width:100%;
  }

  #h5p-frontlib-table thead{
    display:none;
  }


  /* --------------------------------
     CARD CONTAINER
  -------------------------------- */

  #h5p-frontlib-table tr{

    display:grid;

    grid-template-columns:1fr 1fr auto;

    grid-template-areas:
      "view edit date"
      "title title title"
      "author author author"
      "type type type"
      "tags tags tags"
      "notes notes notes";

    gap:10px;

    margin-bottom:16px;
    padding:16px;

    border:1px solid #e5e7eb;
    border-radius:12px;

    background:#ffffff;

    box-shadow:
      0 2px 6px rgba(0,0,0,0.04),
      0 8px 20px rgba(0,0,0,0.04);

    align-items:center;
  }


  /* --------------------------------
     CELL RESET
  -------------------------------- */

  #h5p-frontlib-table td{
    border:none;
    padding:0;
    width:auto!important;
  }


  /* --------------------------------
     GRID AREAS
  -------------------------------- */

  #h5p-frontlib-table td:nth-child(1){grid-area:view;}
  #h5p-frontlib-table td:nth-child(2){grid-area:edit;}

  #h5p-frontlib-table td:nth-child(3){
    grid-area:title;
    font-weight:600;
    font-size:15px;
  }

  #h5p-frontlib-table td:nth-child(4){
    grid-area:type;
    font-size:13px;
    color:#6b7280;
  }

  #h5p-frontlib-table td:nth-child(5){
    grid-area:author;
  }

  #h5p-frontlib-table td:nth-child(6){
    grid-area:date;
    text-align:right;
    align-self:center;
    font-size:12px;
    color:#6b7280;
  }

  #h5p-frontlib-table td:nth-child(7){
    display:none;
  }

  #h5p-frontlib-table td:nth-child(8){
    grid-area:tags;
    font-size:13px;
  }

  #h5p-frontlib-table td:nth-child(9){
    grid-area:notes;
    font-size:13px;
  }


  /* --------------------------------
     BUTTONS
  -------------------------------- */

  .h5p-view-btn,
  .h5p-edit-btn{
    display:flex;
    align-items:center;
    justify-content:center;
    height:36px;
    font-size:13px;
  }


  /* =================================
   MOBILE FILTER FIX
================================= */

@media (max-width:760px){

  .h5p-toolbar{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
    padding:14px;
  }

  /* align all controls to the right */

  .h5p-toolbar .dataTables_length,
  .h5p-toolbar select,
  .h5p-toolbar .dataTables_filter{
    justify-self:end;
    width:100%;
  }

  /* make inputs consistent */

  .h5p-toolbar select,
  .h5p-toolbar .dataTables_filter input{
    width:100%;
    height:36px;
  }


  /* search row full width */

  .h5p-toolbar .dataTables_filter{
    grid-column:1 / -1;
  }

  /* keep label beside search */

  .h5p-toolbar .dataTables_filter label{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:8px;
    width:100%;
  }

}

/* make "All Types" span full row */

@media (max-width:760px){

  #filter-type{
    grid-column:1 / -1;
    width:100%;
  }

}