/* ============================================================
   PROTEL SUBEMPREITEIRA - Complete System Stylesheet
   Colors: Blue #1a3a6e | Blue #1e5799 | Orange #f57c00
           Green #4caf50 | Gray #f5f7fa | Dark #2c3e50
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --primary-dark: #1a3a6e;
  --primary: #1e5799;
  --primary-light: #2a6bc4;
  --accent-orange: #f57c00;
  --accent-orange-hover: #e06800;
  --accent-green: #4caf50;
  --accent-green-hover: #43a047;
  --bg-light: #f5f7fa;
  --white: #ffffff;
  --dark-text: #2c3e50;
  --muted-text: #6c757d;
  --border-color: #e0e6ed;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --warning: #f39c12;
  --info: #3498db;
  --sidebar-width: 280px;
  --sidebar-collapsed: 70px;
  --header-height: 60px;
  --transition-speed: 0.3s;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--dark-text);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition-speed); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #2a6bc4 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 70%, rgba(245,124,0,0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 30%, rgba(76,175,80,0.06) 0%, transparent 50%);
  animation: loginBgPulse 15s ease-in-out infinite alternate;
}

@keyframes loginBgPulse {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(5deg) scale(1.05); }
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 48px 40px 40px;
  position: relative;
  z-index: 1;
  animation: loginFadeIn 0.6s ease-out;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo img {
  max-width: 140px;
  height: auto;
  border-radius: var(--radius);
}

.login-company-name {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.login-subtitle {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted-text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 32px;
  line-height: 1.4;
}

.login-form .form-group {
  margin-bottom: 20px;
  position: relative;
}

.login-form .input-icon-wrapper {
  position: relative;
}

.login-form .input-icon-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-text);
  font-size: 0.95rem;
  transition: color var(--transition-speed);
  z-index: 2;
}

.login-form .form-control {
  padding: 12px 14px 12px 42px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: all var(--transition-speed);
  background: var(--bg-light);
}

.login-form .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,87,153,0.12);
  background: var(--white);
}

.login-form .form-control:focus ~ .input-icon,
.login-form .input-icon-wrapper:focus-within .input-icon {
  color: var(--primary);
}

.login-form .password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted-text);
  cursor: pointer;
  padding: 4px;
  z-index: 2;
  transition: color var(--transition-speed);
}

.login-form .password-toggle:hover {
  color: var(--primary);
}

.login-form .btn-login {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--accent-orange);
  border: none;
  border-radius: var(--radius);
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition-speed);
  margin-top: 8px;
}

.login-form .btn-login:hover {
  background: var(--accent-orange-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(245,124,0,0.35);
}

.login-form .btn-login:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 0.78rem;
  color: var(--muted-text);
}

.login-slogan {
  text-align: center;
  font-size: 0.82rem;
  color: var(--accent-orange);
  font-style: italic;
  margin-top: 16px;
  font-weight: 500;
}

/* ============================================================
   LAYOUT - Sidebar + Header + Main
   ============================================================ */

/* --- Sidebar --- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary-dark);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-speed) ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 70px;
  flex-shrink: 0;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-text small {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav .nav-label {
  padding: 10px 24px 6px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}

.sidebar-nav .nav-item {
  list-style: none;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 11px 24px;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-speed);
  border-left: 3px solid transparent;
  gap: 12px;
  white-space: nowrap;
  text-decoration: none;
}

.sidebar-nav .nav-link i {
  width: 22px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.07);
  border-left-color: rgba(245,124,0,0.5);
}

.sidebar-nav .nav-link.active {
  color: var(--white);
  background: rgba(255,255,255,0.1);
  border-left-color: var(--accent-orange);
  font-weight: 600;
}

.sidebar-nav .nav-link.active i {
  color: var(--accent-orange);
}

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 8px 20px;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* --- Top Header Bar --- */
.top-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1030;
  transition: left var(--transition-speed) ease;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left .mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--dark-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background var(--transition-speed);
}

.header-left .mobile-toggle:hover {
  background: var(--bg-light);
}

.header-page-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark-text);
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dark-text);
}

.header-role-badge {
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.header-role-badge.role-admin {
  background: rgba(30,87,153,0.1);
  color: var(--primary);
}

.header-role-badge.role-employee {
  background: rgba(108,117,125,0.1);
  color: var(--muted-text);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--muted-text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed);
  text-decoration: none;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(231,76,60,0.04);
}

/* --- Main Content Area --- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  transition: margin-left var(--transition-speed) ease;
}

.content-wrapper {
  padding: 28px;
  max-width: 1400px;
  animation: contentFadeIn 0.4s ease-out;
}

@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.main-footer {
  text-align: center;
  padding: 20px 28px;
  font-size: 0.78rem;
  color: var(--muted-text);
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-left: 4px solid var(--primary);
  transition: all var(--transition-speed);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card.stat-blue { border-left-color: var(--primary); }
.stat-card.stat-green { border-left-color: var(--accent-green); }
.stat-card.stat-orange { border-left-color: var(--accent-orange); }
.stat-card.stat-danger { border-left-color: var(--danger); }

.stat-card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-blue .stat-card-icon { background: rgba(30,87,153,0.1); color: var(--primary); }
.stat-green .stat-card-icon { background: rgba(76,175,80,0.1); color: var(--accent-green); }
.stat-orange .stat-card-icon { background: rgba(245,124,0,0.1); color: var(--accent-orange); }
.stat-danger .stat-card-icon { background: rgba(231,76,60,0.1); color: var(--danger); }

.stat-card-info h3 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--dark-text);
  margin: 0 0 2px;
  line-height: 1;
}

.stat-card-info p {
  font-size: 0.82rem;
  color: var(--muted-text);
  margin: 0;
  font-weight: 500;
}

/* ============================================================
   CARDS (General)
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-speed), transform var(--transition-speed);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 18px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-header h5,
.card-header h4 {
  margin: 0;
  font-weight: 700;
  color: var(--dark-text);
  font-size: 1rem;
}

.card-header h5 i,
.card-header h4 i {
  margin-right: 8px;
  color: var(--primary);
}

.card-body {
  padding: 24px;
}

.card-body.p-0 { padding: 0; }

.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}

.table thead th {
  background: var(--bg-light);
  color: var(--dark-text);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  font-size: 0.88rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--dark-text);
}

.table tbody tr:nth-child(even) {
  background: rgba(245,247,250,0.5);
}

.table tbody tr:hover {
  background: rgba(30,87,153,0.03);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .actions-cell {
  white-space: nowrap;
  text-align: right;
}

.table .text-muted { color: var(--muted-text) !important; }

.table-empty {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--muted-text);
}

.table-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}

.table-empty p {
  margin: 0;
  font-size: 0.95rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-speed);
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
}

.btn i { font-size: 0.9em; }

.btn-primary {
  background: var(--primary-dark);
  color: var(--white);
  border-color: var(--primary-dark);
}
.btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(26,58,110,0.3);
}

.btn-accent {
  background: var(--accent-orange);
  color: var(--white);
  border-color: var(--accent-orange);
}
.btn-accent:hover {
  background: var(--accent-orange-hover);
  border-color: var(--accent-orange-hover);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(245,124,0,0.3);
}

.btn-success {
  background: var(--accent-green);
  color: var(--white);
  border-color: var(--accent-green);
}
.btn-success:hover {
  background: var(--accent-green-hover);
  border-color: var(--accent-green-hover);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--white);
}

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

.btn-outline-accent {
  background: transparent;
  color: var(--accent-orange);
  border-color: var(--accent-orange);
}
.btn-outline-accent:hover {
  background: var(--accent-orange);
  color: var(--white);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: var(--white);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--muted-text);
  border-color: var(--border-color);
}
.btn-outline-secondary:hover {
  background: var(--bg-light);
  color: var(--dark-text);
  border-color: var(--muted-text);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.85rem;
}

.btn-icon.btn-sm { width: 30px; height: 30px; font-size: 0.78rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 24px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title:first-child { margin-top: 0; }

.form-section-title i { color: var(--accent-orange); }

.form-group {
  margin-bottom: 20px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark-text);
  margin-bottom: 6px;
  display: inline-block;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control,
.form-select {
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--dark-text);
  transition: all var(--transition-speed);
  background-color: var(--white);
  width: 100%;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,87,153,0.1);
  outline: none;
}

.form-control::placeholder { color: #b0b8c4; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-text {
  font-size: 0.78rem;
  color: var(--muted-text);
  margin-top: 4px;
}

.invalid-feedback {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

/* Input group with icon */
.input-group-icon {
  position: relative;
}

.input-group-icon .form-control {
  padding-left: 40px;
}

.input-group-icon .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-text);
  z-index: 2;
}

/* File upload drag & drop area */
.file-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  background: var(--bg-light);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.file-upload-area:hover,
.file-upload-area.dragover {
  border-color: var(--primary);
  background: rgba(30,87,153,0.03);
}

.file-upload-area i {
  font-size: 2rem;
  color: var(--muted-text);
  margin-bottom: 10px;
  display: block;
}

.file-upload-area p {
  margin: 0;
  color: var(--muted-text);
  font-size: 0.88rem;
}

.file-upload-area .btn {
  margin-top: 12px;
}

/* Image preview */
.image-preview-area {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.image-preview-item {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border-color);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Password strength */
.password-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border-color);
  margin-top: 6px;
  overflow: hidden;
}

.password-strength .strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s, background 0.4s;
  width: 0;
}

.strength-weak { width: 25% !important; background: var(--danger) !important; }
.strength-fair { width: 50% !important; background: var(--warning) !important; }
.strength-good { width: 75% !important; background: var(--info) !important; }
.strength-strong { width: 100% !important; background: var(--accent-green) !important; }

.password-strength-text {
  font-size: 0.72rem;
  margin-top: 3px;
  font-weight: 600;
}

/* Two-column form layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-admin { background: rgba(30,87,153,0.1); color: var(--primary); }
.badge-employee { background: rgba(108,117,125,0.1); color: var(--muted-text); }
.badge-active { background: rgba(76,175,80,0.1); color: var(--accent-green); }
.badge-blocked { background: rgba(231,76,60,0.1); color: var(--danger); }
.badge-pending { background: rgba(245,124,0,0.1); color: var(--accent-orange); }
.badge-info { background: rgba(52,152,219,0.1); color: var(--info); }

/* ============================================================
   ALERTS / TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-message {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 20px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: 450px;
  pointer-events: all;
  animation: toastSlideIn 0.4s ease-out;
  border-left: 4px solid var(--primary);
}

.toast-message.toast-success { border-left-color: var(--accent-green); }
.toast-message.toast-error { border-left-color: var(--danger); }
.toast-message.toast-warning { border-left-color: var(--warning); }
.toast-message.toast-info { border-left-color: var(--info); }

.toast-message .toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--accent-green); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-message .toast-text {
  flex: 1;
  font-size: 0.88rem;
  color: var(--dark-text);
}

.toast-message .toast-close {
  background: none;
  border: none;
  color: var(--muted-text);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  flex-shrink: 0;
  transition: color var(--transition-speed);
}

.toast-message .toast-close:hover { color: var(--dark-text); }

.toast-dismiss {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* Also support inline alerts */
.alert-inline {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.alert-inline i { flex-shrink: 0; }

.alert-inline-success { background: rgba(76,175,80,0.08); color: #2e7d32; border: 1px solid rgba(76,175,80,0.2); }
.alert-inline-error { background: rgba(231,76,60,0.08); color: #c0392b; border: 1px solid rgba(231,76,60,0.2); }
.alert-inline-warning { background: rgba(243,156,18,0.08); color: #e67e22; border: 1px solid rgba(243,156,18,0.2); }
.alert-inline-info { background: rgba(52,152,219,0.08); color: #2980b9; border: 1px solid rgba(52,152,219,0.2); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop.show { background: rgba(0,0,0,0.5); }

.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header .modal-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--dark-text);
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  gap: 8px;
}

.modal-confirm-icon {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 16px;
}

.modal-confirm-icon.icon-danger { color: var(--danger); }
.modal-confirm-icon.icon-warning { color: var(--warning); }

.modal-confirm-text {
  text-align: center;
  font-size: 0.95rem;
  color: var(--dark-text);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--muted-text);
}

.pagination {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pagination .page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--dark-text);
  background: var(--white);
  border: 1px solid var(--border-color);
  transition: all var(--transition-speed);
  text-decoration: none;
}

.pagination .page-link:hover {
  background: var(--bg-light);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .page-item.active .page-link {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--white);
}

.pagination .page-item.disabled .page-link {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================================
   SEARCH / FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.filter-bar .filter-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-bar .filter-group {
  flex: 1;
  min-width: 180px;
}

.filter-bar .filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted-text);
  margin-bottom: 4px;
  display: block;
}

.filter-bar .filter-group .form-control,
.filter-bar .filter-group .form-select {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.filter-bar .filter-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   PDF PREVIEW
   ============================================================ */
.pdf-preview-container {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
}

.pdf-preview-container .pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid var(--primary-dark);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.pdf-preview-container .pdf-company {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.pdf-preview-container .pdf-company small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted-text);
}

.pdf-preview-container .pdf-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-dark);
  text-align: right;
}

.pdf-preview-container table th {
  background: var(--primary-dark);
  color: var(--white);
  font-size: 0.78rem;
  padding: 10px 12px;
}

.pdf-preview-container table td {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.pdf-preview-container .pdf-total {
  font-size: 1.2rem;
  font-weight: 800;
  text-align: right;
  color: var(--primary-dark);
  padding: 16px 0;
  border-top: 2px solid var(--primary-dark);
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinRotate 0.7s linear infinite;
}

.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

@keyframes spinRotate {
  to { transform: rotate(360deg); }
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  flex-direction: column;
  gap: 16px;
  color: var(--muted-text);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state i {
  font-size: 3.5rem;
  color: var(--border-color);
  margin-bottom: 16px;
}

.empty-state h5 {
  color: var(--dark-text);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted-text);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

/* ============================================================
   DETAIL VIEW (Client view, etc)
   ============================================================ */
.detail-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.detail-card .detail-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--white);
  padding: 24px;
}

.detail-card .detail-header h3 {
  margin: 0 0 4px;
  font-weight: 700;
}

.detail-card .detail-header p {
  margin: 0;
  opacity: 0.8;
  font-size: 0.88rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-item {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.detail-item:nth-child(odd) {
  border-right: 1px solid var(--border-color);
}

.detail-item label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted-text);
  margin-bottom: 4px;
  display: block;
}

.detail-item span {
  font-size: 0.92rem;
  color: var(--dark-text);
  font-weight: 500;
}

.detail-item.full-width {
  grid-column: 1 / -1;
  border-right: none;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-primary { color: var(--primary-dark) !important; }
.text-accent { color: var(--accent-orange) !important; }
.text-success { color: var(--accent-green) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--muted-text) !important; }

.bg-primary { background-color: var(--primary-dark) !important; }
.bg-accent { background-color: var(--accent-orange) !important; }
.bg-success { background-color: var(--accent-green) !important; }
.bg-light { background-color: var(--bg-light) !important; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }

.fw-bold { font-weight: 700; }
.text-end { text-align: right; }
.text-center { text-align: center; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.admin-only { /* Shown/hidden via PHP logic */ }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  #sidebar,
  .sidebar-overlay,
  .top-header,
  .main-footer,
  .btn,
  .quick-actions,
  .filter-bar,
  .pagination-wrapper,
  .toast-container,
  .actions-cell,
  .mobile-toggle {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
  }

  .content-wrapper {
    padding: 0 !important;
    max-width: 100% !important;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .card {
    border: 1px solid #ddd;
    box-shadow: none;
    break-inside: avoid;
  }

  .stat-card { page-break-inside: avoid; }

  .table thead th {
    background: #eee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a { color: black; text-decoration: none; }
}

/* ============================================================
   RESPONSIVE: TABLET (768px - 1200px)
   ============================================================ */
@media (max-width: 1200px) {
  #sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar-brand-text,
  .sidebar-nav .nav-link span,
  .sidebar-user-name,
  .sidebar-user-role,
  .sidebar-nav .nav-label {
    display: none;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 18px 10px;
  }

  .sidebar-nav .nav-link {
    justify-content: center;
    padding: 14px 10px;
    border-left: none;
    border-right: 3px solid transparent;
  }

  .sidebar-nav .nav-link:hover {
    border-left: none;
    border-right-color: rgba(245,124,0,0.5);
  }

  .sidebar-nav .nav-link.active {
    border-left: none;
    border-right-color: var(--accent-orange);
  }

  .sidebar-nav .nav-link i {
    margin: 0;
    font-size: 1.15rem;
  }

  .sidebar-user {
    display: flex;
    justify-content: center;
    padding: 16px 8px;
  }

  .sidebar-user .sidebar-user-info {
    justify-content: center;
  }

  .top-header {
    left: var(--sidebar-collapsed);
  }

  .main-content {
    margin-left: var(--sidebar-collapsed);
  }

  .content-wrapper {
    padding: 24px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-item:nth-child(odd) {
    border-right: none;
  }
}

/* ============================================================
   RESPONSIVE: MOBILE (< 768px)
   ============================================================ */
@media (max-width: 767.98px) {
  #sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  #sidebar.show {
    transform: translateX(0);
  }

  /* Restore full sidebar when open on mobile */
  #sidebar.show .sidebar-brand-text,
  #sidebar.show .sidebar-nav .nav-link span,
  #sidebar.show .sidebar-user-name,
  #sidebar.show .sidebar-user-role,
  #sidebar.show .sidebar-nav .nav-label {
    display: block;
  }

  #sidebar.show .sidebar-brand {
    justify-content: flex-start;
    padding: 18px 20px;
  }

  #sidebar.show .sidebar-nav .nav-link {
    justify-content: flex-start;
    padding: 11px 24px;
    border-right: none;
    border-left: 3px solid transparent;
  }

  #sidebar.show .sidebar-nav .nav-link:hover {
    border-right: none;
    border-left-color: rgba(245,124,0,0.5);
  }

  #sidebar.show .sidebar-nav .nav-link.active {
    border-right: none;
    border-left-color: var(--accent-orange);
  }

  #sidebar.show .sidebar-user {
    justify-content: flex-start;
    padding: 16px 20px;
  }

  #sidebar.show .sidebar-user .sidebar-user-info {
    justify-content: flex-start;
  }

  .top-header {
    left: 0;
  }

  .header-left .mobile-toggle {
    display: flex;
  }

  .header-user-name {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .content-wrapper {
    padding: 20px 16px;
  }

  .stat-card {
    padding: 18px;
  }

  .stat-card-icon {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }

  .stat-card-info h3 {
    font-size: 1.35rem;
  }

  .filter-bar .filter-row {
    flex-direction: column;
  }

  .filter-bar .filter-group {
    min-width: 100%;
  }

  .filter-bar .filter-actions {
    width: 100%;
  }

  .filter-bar .filter-actions .btn {
    flex: 1;
  }

  .quick-actions {
    flex-direction: column;
  }

  .quick-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .pagination-wrapper {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .card-header {
    padding: 14px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .card-body { padding: 18px; }

  .table thead th,
  .table tbody td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-item:nth-child(odd) {
    border-right: none;
  }

  .toast-message {
    min-width: auto;
    max-width: calc(100vw - 40px);
  }

  .toast-container {
    right: 10px;
    left: 10px;
  }

  .login-card {
    margin: 20px;
    padding: 32px 24px;
  }

  .pdf-preview-container {
    padding: 20px;
  }
}

/* ============================================================
   RESPONSIVE: Extra small (< 480px)
   ============================================================ */
@media (max-width: 479.98px) {
  .login-company-name { font-size: 1.2rem; }
  .login-subtitle { font-size: 0.65rem; }

  .header-page-title { font-size: 0.95rem; }

  .btn-logout span { display: none; }

  .header-role-badge { display: none; }
}
