/* app.css - Modern layout + components (matches reference look)
   NOTE: This file intentionally overrides some legacy styles from styles.css.
*/

/* --------- Layout shell --------- */
.main{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/*
 * Refined header styling inspired by the provided video.  The header
 * becomes a crisp, mostly opaque bar with generous padding and
 * increased spacing.  A subtle bottom border separates it from the
 * content below, and the blurred effect has been toned down for
 * improved legibility.
 */
.header{
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

/* Left section of the header holds the page title and meta lines. */
.header .header-left{
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
}

/* Larger page heading for a more impactful title */
.header .header-left h1{
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -.01em;
  font-weight: 900;
}

/* Greeting + date line */
/* Meta line (greeting and date) uses slightly larger text for readability */
.header .header-meta{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.header .header-meta .dot{
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(15,23,42,.28);
}

/* The right hand area of the header gains additional spacing */
.header .header-actions{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Generic icon button: increased size, solid background and subtle lift on hover */
.icon-btn{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform var(--transition-fast) ease, box-shadow var(--transition-fast) ease;
}
.icon-btn:hover{
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(15,23,42,.08);
}
.icon-btn:active{
  transform: translateY(0);
}

/* Icon sizing adjusted to match larger buttons */
.icon-btn svg{
  width: 22px;
  height: 22px;
  stroke: rgba(15,23,42,.70);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toggle-btn{
  display: none; /* visible on mobile */
}

@media (max-width: 1024px){
  .toggle-btn{ display: grid; }
  .header{ padding: 11px 14px; }
  .header .header-left h1{ font-size: 20px; }
  .header .header-meta{ display: none; }
  /* Keep the topbar clean on smaller screens */
  .header-actions .icon-btn:not(.toggle-btn){ display: none; }
  .search{ width: min(520px, 70vw); }
}

/* Search */
/* Search: pill shaped with more comfortable padding and larger icon */
.search{
  position: relative;
  /* Make the search box narrower to reflect the user's request.  The
     previous width was fairly wide (480px).  We reduce it so it does
     not dominate the header, using a smaller maximum width with a
     responsive fallback. */
  width: min(360px, 40vw);
}
.search input{
  width: 100%;
  padding: 12px 14px 12px 42px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #ffffff;
  outline: none;
  transition: box-shadow var(--transition-fast) ease, border-color var(--transition-fast) ease;
}
.search input:focus{
  border-color: rgba(var(--primary-rgb), .30);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .12);
}
.search svg{
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  stroke: rgba(15,23,42,.50);
}

/* User pill (top-right) */
/* User pill: larger avatar and updated gradient matching the new primary palette */
.user-pill{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.10);
  background: #ffffff;
}
.user-pill .avatar{
  width: 34px;
  height: 34px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: .02em;
  flex: 0 0 34px;
}
.user-pill .meta{
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.user-pill #headerUserName{
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}
.user-pill #headerUserRole{
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 1024px){
  .user-pill .meta{ display: none; }
  .user-pill{ padding: 6px; }
}

/* --------- Main content --------- */
.content{
  padding: 22px 24px 38px;
}

.content .container{
  max-width: 1180px;
  margin: 0 auto;
}

/* --------- Cards --------- */
/*
 * Cards: fully opaque surfaces with generous rounding and soft shadows.
 * Use the --surface colour defined in global.css for consistency.  The
 * border uses the global border colour and we override the standard
 * shadow to a slightly deeper variant for subtle depth.
 */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
  position: relative;
  overflow: hidden;
}

/*
 * Disable the glassy backdrop filter on cards and table containers to
 * improve clarity and match the crisp look of the reference design.
 */
.card,
.table-container{
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.card{ padding: 16px; }
.card h2, .card h3{ margin-top: 0; }

.card-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.card.stat{
  position: relative;
  overflow: hidden;
  padding: 16px 16px 14px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-fast) ease, box-shadow var(--transition-fast) ease, border-color var(--transition-fast) ease;
}

.card.stat:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(var(--primary-rgb), .18);
}
.card.stat:active{
  transform: translateY(-1px);
}

.card.stat .go{
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.72);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
}
.card.stat .go svg{
  width: 16px;
  height: 16px;
  stroke: rgba(15,23,42,.70);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.card.stat:hover .go{
  background: rgba(var(--primary-rgb), .12);
  border-color: rgba(var(--primary-rgb), .20);
}
.card.stat:hover .go svg{ stroke: rgba(15,23,42,.86); }

.card.stat .label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.card.stat .value{
  margin-top: 8px;
  font-size: 20px;
  font-weight: 900;
}
.card.stat::before{
  content: "";
  position: absolute;
  inset: 0;
  opacity: .10;
  background: linear-gradient(135deg, rgba(33,98,176,.92), rgba(94,136,198,.92));
  pointer-events: none;
}
.card.stat.blue::before{ opacity: .10; }
.card.stat.red::before{ background: linear-gradient(135deg, rgba(239,68,68,.9), rgba(245,158,11,.9)); opacity: .10; }
.card.stat.green::before{ background: linear-gradient(135deg, rgba(16,185,129,.9), rgba(37,99,235,.9)); opacity: .10; }

/* --------- Tables --------- */
.table-container{
  background: rgba(255,255,255,.90);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  overflow-x: auto;
}

table{
  width: 100%;
  border-collapse: collapse;
}

table thead th{
  text-align: left;
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: none;
  /* Use the global text colour for table headings to ensure
     sufficient contrast against the light header background. */
  color: var(--text);
  padding: 12px 12px;
  /* Use the standard border colour for table separators. */
  border-bottom: 1px solid var(--border);
  /* Subtle tint derived from the primary colour for table headers. */
  background: rgba(var(--primary-rgb), .05);
}

table tbody td{
  padding: 12px 12px;
  /* Use the global border colour for consistency across tables. */
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table tbody tr:hover{
  /* On hover, gently tint the row with the accent colour. */
  background: rgba(var(--primary-rgb), .08);
}

/* Make legacy .responsive tables behave nicely */
table.responsive{ width: 100%; border-collapse: collapse; }
table.responsive th, table.responsive td{ padding: 12px 12px; }
table.responsive thead{ background: rgba(15,23,42,.02); }

/* --------- Buttons --------- */
.btn,
button.btn,
a.btn{
  border-radius: 14px !important;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.88);
  color: rgba(15,23,42,.84);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--transition-fast) ease, box-shadow var(--transition-fast) ease, background var(--transition-fast) ease, border-color var(--transition-fast) ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(15,23,42,.08);
  background: rgba(255,255,255,.96);
}

.btn:active{ transform: translateY(0); box-shadow: none; }

.btn.primary, .btn.btn-primary{
  /* Primary buttons use a gradient of the brand colours defined in
     global.css. */
  background: linear-gradient(90deg, var(--primary-1), var(--primary-2));
  border-color: rgba(var(--primary-rgb), .18);
  color: #fff;
}

.btn.secondary, .btn.btn-secondary{
  background: var(--surface);
  border-color: var(--border);
}

.btn.danger{
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.18);
  color: rgba(15,23,42,.88);
}

/* --------- Forms --------- */
input, select, textarea{
  border-radius: 14px;
  /* Inputs use the global border and surface colours to blend with the card */
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus{
  border-color: rgba(var(--primary-rgb), .30);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .12);
  outline: none;
}

/* --------- Modals (for pages that use .modal/.modal-content) --------- */
.modal{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.42);
  z-index: 80;
  padding: 18px;
}

.modal.active{ display: flex; }
.modal.hide{ display: none !important; }

.modal .modal-content{
  width: min(720px, 96vw);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15,23,42,.10);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal .modal-header{
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15,23,42,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal .modal-body{ padding: 16px; }
.modal .modal-footer{
  padding: 14px 16px;
  border-top: 1px solid rgba(15,23,42,.08);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


/* --------- Legacy dashboard accent support --------- */
.card .accent{
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}

.card.blue .accent{ background: rgba(var(--primary-rgb), .95); }
.card.red .accent{ background: rgba(239,68,68,.95); }
.card.green .accent{ background: rgba(16,185,129,.95); }
.card.yellow .accent{ background: rgba(245,158,11,.95); }

.card .label{
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.card .value{
  font-size: 20px;
  font-weight: 900;
}

/* ===== Attachments Modal Layout ===== */
/* Layout container splits the modal body into a narrow list and a wide preview. */
.attachments-layout {
  display: flex;
  gap: 16px;
  max-height: 70vh;
  overflow: hidden;
}

/* List occupies up to 30% width and scrolls if overflowing. */
.attachments-list {
  flex: 1 1 30%;
  min-width: 160px;
  max-width: 240px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding-right: 8px;
}

/* Preview area uses remaining space and scrolls vertically if needed. */
.attachments-preview {
  flex: 1 1 70%;
  overflow-y: auto;
  padding-left: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Individual list items show file name and basic actions. */
.attachments-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.attachments-list-item:hover {
  background: rgba(15, 23, 42, 0.04);
}
.attachments-list-item.active {
  background: rgba(15, 23, 42, 0.08);
  font-weight: 600;
}

/* Buttons inside preview header */
.attachments-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Preview embed or image should take available width */
.attachments-preview embed,
.attachments-preview img {
  width: 100%;
  height: 60vh;
  object-fit: contain;
  border: 1px solid var(--border);
}
