/* ============================================================
   CPR Internal Staff Portal — Global Stylesheet
   Brand: CPR Cell Phone Repair by Assurant
   Font:  Avenir (Book, Medium, Heavy, Black)
   Colors: Red #C8102E | Dark #2D2D2D | Light gray #F5F5F5
   ============================================================ */

/* --- Avenir Font Faces ------------------------------------ */
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Book.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Roman.ttf') format('truetype');
  font-weight: 450;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Heavy.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'Avenir';
  src: url('../fonts/avenir/Avenir-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
}

/* --- CSS Variables ---------------------------------------- */
:root {
  --red:         #C8102E;
  --red-dark:    #a30d24;
  --red-light:   #f8e5e8;
  --dark:        #2D2D2D;
  --dark-mid:    #444444;
  --gray:        #888888;
  --gray-light:  #e8e8e8;
  --bg:          #F2F2F2;
  --white:       #FFFFFF;
  --green:       #22c55e;
  --green-light: #f0fdf4;
  --amber:       #f59e0b;
  --amber-light: #fffbeb;

  --font:        'Avenir', 'Helvetica Neue', Arial, sans-serif;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.10);
  --shadow:      0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.14);
  --radius:      8px;
  --radius-lg:   12px;

  --nav-h:       60px;
  --sidebar-w:   240px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--dark);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

/* --- Top Navigation --------------------------------------- */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--red);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.topnav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.topnav__logo img {
  height: 36px;
  width: auto;
}

.topnav__brand {
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* Store Switcher */
.store-switcher {
  position: relative;
}
.topnav__store--btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.topnav__store--btn:hover {
  background: rgba(255,255,255,0.15);
}
.store-switcher__drop {
  display: none;
  position: fixed;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 99999;
  overflow: hidden;
}
/* store-switcher open state handled by JS */
.store-switcher__item {
  display: block;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--dark);
  text-decoration: none;
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
}
.store-switcher__item:last-child {
  border-bottom: none;
}
.store-switcher__item:hover {
  background: var(--bg);
}
.store-switcher__item--active {
  font-weight: 700;
  color: var(--red);
  background: var(--red-light);
}

.topnav__store {
  margin-left: 20px;
  background: rgba(255,255,255,0.18);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.topnav__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav__user {
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  font-weight: 500;
}

.topnav__logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.topnav__logout:hover {
  background: rgba(255,255,255,0.28);
  text-decoration: none;
}

/* Role badge */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.role-badge--employee { background: rgba(255,255,255,0.2); color: var(--white); }
.role-badge--manager  { background: var(--amber); color: #7c4700; }
.role-badge--admin    { background: var(--dark); color: var(--white); }

/* --- Sidebar Navigation ----------------------------------- */
:root {
  --sidebar-collapsed-w: 54px;
}

.sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-light);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  padding-top: 16px;
  transition: width 0.2s ease;
}

/* Collapsed state */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
  padding-top: 12px;
}
body.sidebar-collapsed .main {
  margin-left: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed footer {
  margin-left: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .sidebar__link span.link-label {
  display: none;
}
body.sidebar-collapsed .sidebar__link {
  justify-content: center;
  padding: 10px 0;
  border-radius: 0;
}
body.sidebar-collapsed .sidebar__divider {
  margin: 6px 4px;
}
body.sidebar-collapsed .sidebar__collapse-btn {
  justify-content: center;
}
body.sidebar-collapsed .sidebar__collapse-btn .link-label {
  display: none;
}

.sidebar__section {
  padding: 0 12px 8px;
}

.sidebar__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray);
  padding: 12px 8px 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--dark-mid);
  font-size: 0.875rem;
  font-weight: 450;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

/* Tooltip for collapsed icons */
body.sidebar-collapsed .sidebar__link::after {
  content: attr(data-tooltip);
  position: fixed;
  left: calc(var(--sidebar-collapsed-w) + 8px);
  background: var(--dark);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
body.sidebar-collapsed .sidebar__link:hover::after {
  opacity: 1;
}

.sidebar__link:hover {
  background: var(--red-light);
  color: var(--red);
  text-decoration: none;
}

.sidebar__link.active {
  background: var(--red);
  color: var(--white);
  font-weight: 700;
}

.sidebar__link .icon {
  font-size: 1.1rem;
  width: 22px;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__divider {
  height: 1px;
  background: var(--gray-light);
  margin: 8px 12px;
}

/* --- Main Content Area ------------------------------------ */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--nav-h);
  padding: 28px 32px 40px;
  flex: 1;
  position: relative;
  z-index: 1;
  transition: margin-left 0.2s ease;
}

/* --- Page Header ------------------------------------------ */
.page-header {
  margin-bottom: 24px;
}

.page-header__title {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.page-header__sub {
  font-size: 0.9rem;
  color: var(--gray);
  margin-top: 4px;
}

.page-header__actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* --- Cards ------------------------------------------------ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-light);
  overflow: hidden;
}

.card__header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
}

.card__body {
  padding: 20px;
}

/* --- Grid Layout ------------------------------------------ */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--red);
  color: var(--white);
}
.btn-primary:hover { background: var(--red-dark); color: var(--white); }

.btn-secondary {
  background: var(--white);
  color: var(--dark);
  border: 1.5px solid var(--gray-light);
}
.btn-secondary:hover { background: var(--bg); }

.btn-dark {
  background: var(--dark);
  color: var(--white);
}
.btn-dark:hover { background: #111; color: var(--white); }

.btn-success {
  background: var(--green);
  color: var(--white);
}
.btn-success:hover { background: #16a34a; color: var(--white); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Forms ----------------------------------------------- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dark-mid);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.12);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-error {
  font-size: 0.8rem;
  color: var(--red);
  margin-top: 4px;
}

/* --- Alert / Flash Messages ------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #86efac; }
.alert-warning { background: var(--amber-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray);
  border-bottom: 2px solid var(--gray-light);
}

table.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-light);
  vertical-align: middle;
}

table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #fafafa; }

/* --- Status Dots ----------------------------------------- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot--green  { background: var(--green); }
.status-dot--red    { background: var(--red); }
.status-dot--gray   { background: #ccc; }
.status-dot--amber  { background: var(--amber); }

/* --- Checklist Specific ---------------------------------- */
.checklist-period-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.period-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--gray-light);
  background: var(--white);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--gray);
  min-width: 110px;
}
.period-tab:hover { border-color: var(--red); color: var(--red); }
.period-tab.active { border-color: var(--red); background: var(--red); color: var(--white); }

.period-tab .period-count {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
}

.checklist-category {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray);
  padding: 14px 0 6px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-light);
  transition: opacity 0.2s;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item.checked { opacity: 0.5; }
.checklist-item.checked .item-label { text-decoration: line-through; }

.checklist-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-light);
  border-radius: 50%;
  cursor: pointer;
  accent-color: var(--green);
  flex-shrink: 0;
}

.item-label { font-size: 0.9rem; flex: 1; }

.progress-bar-wrap {
  background: var(--gray-light);
  border-radius: 100px;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 100px;
  transition: width 0.4s ease;
}

/* --- Login Page ------------------------------------------ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.login-card__header {
  background: var(--red);
  padding: 32px 32px 24px;
  text-align: center;
}

.login-card__body {
  padding: 32px;
}

.login-card__title {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 14px;
  letter-spacing: 0.5px;
}

.pin-display {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 12px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gray-light);
  background: transparent;
  transition: all 0.15s;
}
.pin-dot.filled {
  background: var(--red);
  border-color: var(--red);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.pin-key {
  aspect-ratio: 1;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.pin-key:hover  { background: var(--red-light); border-color: var(--red); color: var(--red); }
.pin-key:active { transform: scale(0.93); background: var(--red); color: var(--white); }
.pin-key--clear { font-size: 0.85rem; color: var(--gray); }
.pin-key--submit {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
  font-size: 0.9rem;
}
.pin-key--submit:hover { background: var(--red-dark); }

/* --- Utility -------------------------------------------- */
.text-red   { color: var(--red); }
.text-gray  { color: var(--gray); }
.text-green { color: var(--green); }
.text-bold  { font-weight: 700; }
.text-sm    { font-size: 0.8rem; }
.text-center { text-align: center; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1        { gap: 8px; }
.gap-2        { gap: 16px; }

.hidden { display: none; }

/* --- Responsive ------------------------------------------ */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 32px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  footer { margin-left: 0 !important; padding: 12px 16px; }
}

/* ── OneSignal: prevent any injected elements from affecting layout ── */
#onesignal-slidedown-container,
#onesignal-popover-container,
.onesignal-slidedown-container,
.onesignal-popover-container,
#onesignal-bell-container,
.onesignal-reset {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
  position: fixed !important;
  pointer-events: none !important;
}
