@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Premium Modern SaaS Palette */
  --bg-body: #f8f9fa;
  --bg-sidebar: #0f172a;
  --bg-surface: #ffffff;

  --border-light: #e2e8f0;
  --border-sidebar: #1e293b;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-hover: #ffffff;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;

  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-floating: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius: 8px;
  --radius-lg: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.8rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: all 0.2s ease;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-header h2 {
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-logo {
  width: 45px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 0.975rem;
}

.close-sidebar-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-sidebar);
  font-size: 1.375rem;
  cursor: pointer;
}

.sidebar-menu {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

/* Scrollbar styling for sidebar */
.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background-color: var(--border-sidebar);
  border-radius: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  font-weight: 500;
}

.sidebar-link svg {
  opacity: 0.7;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-sidebar-hover);
}

.sidebar-link:hover svg {
  opacity: 1;
  transform: translateX(2px);
}

.sidebar-link.active {
  background-color: var(--primary);
  color: #fff;
}

.sidebar-link.active svg {
  opacity: 1;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  /* Important for flex child truncation */
}

/* Top Header */
.top-header {
  height: 70px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 90;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.375rem;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
}

.header-title {
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* Main Content Padding */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Glass / Cards */
.glass {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

/* Dashboard Stat Cards */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.stat-card h3 {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card h2 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

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

.form-group label {
  display: block;
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.825rem;
  color: var(--text-main);
  background-color: var(--bg-body);
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row>div {
  flex: 1;
  min-width: 200px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff !important;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger) !important;
}

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

.btn-warning {
  background-color: var(--warning-light);
  color: #d97706 !important;
}

.btn-warning:hover {
  background-color: var(--warning);
  color: white !important;
}

.btn-success {
  background-color: var(--success-light);
  color: var(--success) !important;
}

.btn-success:hover {
  background-color: var(--success);
  color: white !important;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-main) !important;
}

.btn-outline:hover {
  background-color: var(--bg-body);
}

/* Tables Container - For Mobile Scroll */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th {
  background-color: var(--bg-body);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.775rem;
}

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

tr:hover td {
  background-color: rgba(248, 250, 252, 0.8);
}

/* Badges */
.badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  display: inline-block;
}

.badge-blue {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-green {
  background: var(--success-light);
  color: var(--success);
}

.badge-red {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-yellow {
  background: var(--warning-light);
  color: #d97706;
}

/* Modals (Popups) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-floating);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
}

.modal-header h3 {
  font-size: 1.025rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.375rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.btn-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

/* Overlay for Mobile Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

/* -------------------------------------
   RESPONSIVE QUERIES 
   ------------------------------------- */

/* Tablet & Smaller Desktop */
@media (max-width: 1024px) {
  .main-content {
    padding: 16px;
  }

  .glass {
    padding: 16px;
  }
}

/* Action Buttons Grouping */
.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-buttons.center {
  justify-content: center;
}

.action-buttons.right {
  justify-content: flex-end;
}

/* Mobile Devices */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  /* Sidebar becomes Off-canvas on Mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    bottom: 0;
    width: 280px;
    z-index: 110;
    box-shadow: var(--shadow-floating);
  }

  .sidebar.active {
    transform: translateX(280px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .close-sidebar-btn {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }

  .header-title {
    display: none;
  }

  .user-name {
    display: none;
  }

  .top-header {
    padding: 0 16px;
    height: 60px;
  }

  /* Flex wrap for action bars */
  .glass>div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .glass>div:first-child>div:last-child {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .glass>div:first-child>div:last-child .btn {
    flex: 1;
  }

  /* Modal adjustments for Mobile */
  .modal-overlay {
    padding: 12px;
  }

  .modal-content {
    max-height: calc(100vh - 24px);
    border-radius: var(--radius);
  }

  .modal-body {
    padding: 16px;
  }

  .form-row>div {
    min-width: 100%;
  }

  /* Stack form inputs on mobile */

  /* Table adjustments - Responsive Card View */
  table {
    border: 0;
    min-width: 100% !important;
  }

  table thead {
    display: none;
  }

  table tr {
    display: block;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: white;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  }

  table tbody tr:hover {
    background: white;
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  }

  table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--surface-border);
    padding: 10px 8px;
    text-align: right;
    font-size: 0.85rem;
    gap: 10px;
  }

  table td:last-child {
    border-bottom: 0;
    flex-direction: column;
    align-items: stretch;
    padding-top: 12px;
  }

  table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: left;
    flex-shrink: 0;
  }

  /* Bỏ style rỗng khi empty (ví dụ cột Checkbox) */
  table td[data-label=""]::before {
    display: none;
  }

  table td:last-child::before {
    display: none;
    /* Hide label on Action row to save space */
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}