:root{
  --admin-accent: #5DADE2;
  --admin-danger: #e74c3c;
  --admin-bg: #ffffff;
  --admin-card-shadow: 0 6px 18px rgba(18,38,63,0.06);
  --admin-radius: 10px;
  --admin-gap: 14px;
}

/* ======================
   Card / Admin layout
   ====================== */
.admin-card {
  background: var(--admin-bg);
  border-radius: var(--admin-radius);
  padding: 18px;
  box-shadow: var(--admin-card-shadow);
  margin-bottom: 18px;
}

/* Title row inside cards */
.admin-card .admin-title {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.admin-card .admin-title h3 {
  margin:0;
  font-size: 18px;
  color: #172b3a;
}

/* Controls and search */
.admin-controls {
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.admin-search {
  display:flex;
  gap:8px;
  align-items:center;
}
.admin-search input[type="search"]{
  padding:8px 12px;
  border-radius:8px;
  border:1px solid #e0e6eb;
  min-width: 220px;
  box-sizing:border-box;
}

/* Badges for role/status */
.badge {
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  color:#fff;
}
.badge.role-admin { background: linear-gradient(90deg,#ff9c91,#e64f3f); color:#fff; }
.badge.role-control { background:#3498DB; }
.badge.status-active { background:#28a745; }
.badge.status-hidden { background:#6c757d; }

/* Table polish */
#users-table {
  width:100%;
  border-collapse: collapse;
  overflow: hidden;
}
#users-table thead th {
  background: #f7fbfd;
  color: #0f2a36;
  font-weight:700;
  font-size:13px;
  padding:10px;
  text-align:left;
  border-bottom: 2px solid #eef6fb;
}
#users-table tbody tr {
  transition: background .12s ease, transform .06s ease;
}
#users-table tbody tr:hover {
  background: #f6fbff;
}
#users-table td {
  padding:10px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f8;
}

/* Action group/buttons */
.action-group {
  display:flex;
  gap:6px;
  align-items:center;
  justify-content:flex-end;
}
.action-btn {
  padding:6px 10px;
  border-radius:8px;
  border: none;
  font-size:13px;
  cursor:pointer;
}
.action-btn.info { background:#17a2b8; color:white; }
.action-btn.edit { background:#5DADE2; color:white; }
.action-btn.delete { background:#e74c3c; color:white; }

/* Responsive: make rows stack on small screens */
@media (max-width: 720px) {
  .action-group { gap:4px; }
  .admin-search input[type="search"]{ min-width: 140px; }
  #users-table thead { display:none; }
  #users-table tbody tr { display:block; margin-bottom: 10px; border-radius:8px; box-shadow: var(--admin-card-shadow); padding: 10px; background: #fff; }
  #users-table tbody td { display:flex; justify-content:space-between; padding:6px 8px; border-bottom: none; }
  #users-table tbody td.label { font-weight:700; color:#1f2937; }
}

/* ======================
   Collapsible (details/summary) styling
   ====================== */
.admin-collapsible {
  border-radius: 10px;
  padding: 0;
  margin-bottom: 16px;
  background: white;
  overflow: visible;
  box-shadow: 0 6px 18px rgba(18,38,63,0.04);
}
.admin-collapsible summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border: 1px solid #eef6fb;
  box-shadow: 0 2px 6px rgba(18,38,63,0.03);
  margin: 12px;
}
.admin-collapsible summary::-webkit-details-marker { display: none; }
.admin-collapsible summary::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-right: 2px solid #4b5563;
  border-bottom: 2px solid #4b5563;
  transform: rotate(45deg);
  transition: transform .18s ease;
  margin-left: 10px;
  opacity: 0.85;
}
.admin-collapsible[open] summary::after {
  transform: rotate(-135deg);
}
.admin-collapsible .admin-content {
  overflow: hidden;
  transition: max-height .26s ease, opacity .18s ease, padding .18s ease;
  opacity: 1;
  max-height: 1000px; 
  margin: 0 12px 12px 12px;
}
.admin-collapsible:not([open]) .admin-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0 12px;
}
.admin-collapsible .admin-content > * {
  padding: 14px 0;
}
.admin-collapsible .table-wrapper {
  padding: 8px 0;
}
.admin-meta { color:#6b7280; font-size:13px; }


/* ======================
   Large Schedule Dialog Styles
   ====================== */

/* Gör dialogen EXTREMT bred när klassen 'large' finns på content */
.dialog-content.large {
    max-width: 1400px; 
    width: 98%;
    padding: 25px;
}

/* Shift Badges (DAG/NATT) */
.shift-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    vertical-align: middle;
}
.shift-badge.DAG { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.shift-badge.NATT { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }
.shift-badge.LEDIG { background: #f5f5f5; color: #999; border: 1px solid #e0e0e0; }
.shift-badge.HELG { background: #fff5f5; color: #c62828; border: 1px solid #ffcdd2; }

/* Admin Edit Table in Schedule Dialog */
.admin-edit-table {
    width: 100%;
    border-collapse: collapse; /* Standard collapse */
    font-size: 13px;
}
.admin-edit-table th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}
.admin-edit-table td {
    padding: 6px 4px; 
    border-bottom: 1px solid #f1f1f1;
    vertical-align: middle;
    background: #fff; 
}
.admin-edit-table tr:hover td {
    background-color: #fafbfc;
}

/* Kompaktare inputs i admin-tabellen */
.admin-edit-table input[type="number"] {
    padding: 4px;
    font-size: 13px;
    height: 30px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
.admin-edit-table select {
    padding: 4px 20px 4px 6px;
    font-size: 13px;
    height: 30px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

/* Snabbsummering i toppen av dialogen */
.dialog-summary-bar {
    display: flex;
    gap: 15px;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}
.ds-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}
.ds-badge {
    background: #fff;
    border: 1px solid #ddd;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* ======================
   RAPPORT-DIALOGEN (Admin/Kontrollant)
   Här fixar vi bredderna och utseendet
   ====================== */

/* Badge för röd dag i detaljlistan */
.badge-red-day {
    display: inline-block;
    font-size: 10px;
    color: #c62828;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    padding: 1px 5px;
    border-radius: 4px;
    margin-top: 2px;
    white-space: nowrap;
}

/* Summary-box i report dialog */
#report-payroll-summary #summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: start;
}

/* Enskild summeringsruta */
#report-payroll-summary #summary-grid > div,
#report-payroll-summary .report-summary-box {
    min-width: 220px;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #eee;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* "Övrigt"-container (tydlig och lätt att läsa) */
#report-payroll-summary .report-other-container {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #fff9f3;
    border: 1px solid #ffe8cc;
    color: #6b3d00;
    font-size: 13px;
    line-height: 1.35;
}

/* --- TABELLJUSTERINGAR: Bredd och Layout --- */

/* Grundinställning för tabellen */
#report-detail-rows {
    /* (Tabellens body) */
}

/* 1. Datum-kolumnen: Bred nog för datum + dag + badge */
#report-detail-rows td:first-child { 
    width: 1%;          /* Tvingar den att vara så smal som innehållet tillåter (min-width styr) */
    min-width: 140px;   /* Säkerställ att texten får plats */
    white-space: nowrap; 
    color: #1f2d3d; 
    font-weight: 700; 
}

/* 2. Status-kolumnen: Tvinga till minimal bredd */
#report-detail-rows td:nth-child(2) { 
    width: 1%;
    min-width: 100px;
    white-space: nowrap; 
}

/* 3. Timmar & Övertid: Tvinga till minimal bredd */
#report-detail-rows td:nth-child(3), 
#report-detail-rows td:nth-child(4) { 
    width: 1%;
    min-width: 80px; 
    white-space: nowrap;
    text-align: right; 
    color: #2C3E50; 
    font-weight: 700; 
}

/* 4. Övrigt / Kommentar (Sista kolumnen): Får ta all resterande plats */
#report-detail-rows td:last-child {
    width: auto; /* Tar upp resten */
    min-width: 250px; /* Så den inte blir pytte-liten */
    font-size: 13px; 
    color: #333;
    white-space: normal; /* Tillåt radbrytning */
    word-break: break-word;
}

/* Färger för olika statusrader (används av JS eller backend-logik) */
#report-detail-rows tr { background: #fff; }
#report-detail-rows tr.semester-row { background:#e3f2fd; color:#0d47a1; }
#report-detail-rows tr.sick-row { background:#ffebee; color:#c62828; }
#report-detail-rows tr.overtime-row { background:#fff8e1; color:#e65100; }

/* --- Röd dag-logik --- */
/* Ljusröd bakgrund för röd dag */
#report-detail-rows tr.red-day-row {
    background-color: #fff5f5; /* Ljus röd/rosa */
}
/* Mörkare röd om det också finns en ändring */
#report-detail-rows tr.red-day-row.has-change,
#report-detail-rows tr.has-change {
    background-color: #ffe0e0; /* Mörkare röd */
    border-left: 4px solid #e74c3c; /* Röd kantlinje */
}

/* Responsivt: på smal skärm ger vi mer utrymme åt text-kolumnen */
@media (max-width: 900px) {
    #report-detail-rows td:first-child, 
    #report-detail-rows td:nth-child(2) { 
        width: auto; 
        min-width: 80px; 
    }
    #report-payroll-summary #summary-grid { 
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); 
    }
}