:root{
  --app-bg:#f3f5f9;
  --app-card:#ffffff;
  --app-text:#0f172a;
  --app-muted:#64748b;
  --app-primary:#2563eb;
  --app-border:rgba(15,23,42,.12);
  --app-radius:14px;
  --app-success:#10b981;
  --app-danger:#ef4444;
  --app-warning:#f59e0b;
  --app-info:#3b82f6;
  --app-shadow:0 10px 30px rgba(2,6,23,.06);
  --app-shadow-lg:0 20px 60px rgba(2,6,23,.12);
  --app-transition:all 0.2s ease;
}

html,body{height:100%}
body{
  background:var(--app-bg);
  color:var(--app-text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.app-shell{
  min-height:100vh;
}

/* Navbar Styles */
.app-navbar{
  background:linear-gradient(180deg,#0b1220 0%, #0f172a 70%);
  color:#e2e8f0;
  box-shadow:0 2px 8px rgba(0,0,0,.1);
  position:sticky;
  top:0;
  z-index:1030;
  padding:.75rem 0;
}

.app-navbar .navbar-brand{
  color:#fff;
  text-decoration:none;
  font-weight:600;
  transition:var(--app-transition);
}
.app-navbar .navbar-brand:hover{
  color:#fff;
  opacity:.9;
}

.app-logo{
  width:36px;
  height:36px;
  font-weight:900;
  font-size:.875rem;
  flex-shrink:0;
}

.brand-name{
  font-weight:800;
  letter-spacing:.4px;
  font-size:.95rem;
  line-height:1.2;
  color:#fff;
}
.brand-subtitle{
  font-size:.7rem;
  color:rgba(255,255,255,.6);
  line-height:1;
  margin-top:2px;
}

.app-navbar .navbar-nav{
  gap:.25rem;
}
.app-navbar .nav-link{
  color:#cbd5e1;
  border-radius:8px;
  padding:.5rem .75rem;
  transition:var(--app-transition);
  position:relative;
  font-weight:500;
  display:flex;
  align-items:center;
  white-space:nowrap;
}
.app-navbar .nav-link:hover{
  background:rgba(255,255,255,.08);
  color:#fff;
}
.app-navbar .nav-link.active{
  background:rgba(37,99,235,.18);
  color:#fff;
  border:1px solid rgba(37,99,235,.35);
}
.app-navbar .nav-link.active::after{
  content:'';
  position:absolute;
  bottom:0;
  left:50%;
  transform:translateX(-50%);
  width:60%;
  height:2px;
  background:var(--app-primary);
  border-radius:2px 2px 0 0;
}

.app-navbar .navbar-toggler{
  border:1px solid rgba(255,255,255,.2);
  color:#fff;
  padding:.375rem .5rem;
}
.app-navbar .navbar-toggler:focus{
  box-shadow:0 0 0 3px rgba(255,255,255,.1);
}

.app-navbar .dropdown-menu{
  border:none;
  box-shadow:var(--app-shadow-lg);
  border-radius:var(--app-radius);
  margin-top:.5rem;
  padding:.5rem 0;
}
.app-navbar .dropdown-item{
  padding:.5rem 1rem;
  transition:var(--app-transition);
  display:flex;
  align-items:center;
}
.app-navbar .dropdown-item:hover{
  background:rgba(37,99,235,.08);
  color:var(--app-primary);
}
.app-navbar .dropdown-item-text{
  padding:.5rem 1rem;
}

.app-navbar .btn{
  border-color:rgba(255,255,255,.2);
  color:#cbd5e1;
}
.app-navbar .btn:hover{
  background:rgba(255,255,255,.1);
  border-color:rgba(255,255,255,.3);
  color:#fff;
}

.app-navbar .dropdown-toggle::after{
  margin-left:.5rem;
}

/* Navbar animations */
.app-navbar .nav-link{
  position:relative;
  overflow:hidden;
}
.app-navbar .nav-link::before{
  content:'';
  position:absolute;
  top:0;
  left:-100%;
  width:100%;
  height:100%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);
  transition:left .5s;
}
.app-navbar .nav-link:hover::before{
  left:100%;
}

/* Remove old topbar styles */
.app-topbar{
  display:none;
}

.app-card{
  background:var(--app-card);
  border:1px solid var(--app-border);
  border-radius:var(--app-radius);
  box-shadow:var(--app-shadow);
  transition:var(--app-transition);
}
.app-card:hover{
  box-shadow:var(--app-shadow-lg);
}

/* Table Styles */
.table{
  margin-bottom:0;
}
.table thead th{
  font-weight:700;
  color:#0f172a;
  background:rgba(243,245,249,.5);
  border-bottom:2px solid var(--app-border);
  text-transform:uppercase;
  font-size:.75rem;
  letter-spacing:.5px;
  padding:.75rem;
}
.table td,.table th{
  vertical-align:middle;
  padding:.75rem;
}
.table tbody tr{
  transition:var(--app-transition);
}
.table tbody tr:hover{
  background:rgba(37,99,235,.02);
}
.table tbody tr:last-child td{
  border-bottom:none;
}

/* Button Styles */
.btn{
  transition:var(--app-transition);
  font-weight:500;
  border-radius:8px;
}
.btn-primary{
  background:var(--app-primary);
  border-color:var(--app-primary);
}
.btn-primary:hover{
  background:#1d4ed8;
  border-color:#1d4ed8;
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(37,99,235,.3);
}
.btn:disabled{
  opacity:.6;
  cursor:not-allowed;
  transform:none !important;
}
.btn-sm{
  padding:.375rem .75rem;
  font-size:.875rem;
}

/* Form Styles */
.form-control,.form-select{
  border:1px solid var(--app-border);
  border-radius:8px;
  transition:var(--app-transition);
  padding:.5rem .75rem;
}
.form-select{
  padding-right:2.25rem; /* chừa chỗ mũi tên, tránh lấp nội dung */
}
.form-control:focus,.form-select:focus{
  border-color:var(--app-primary);
  box-shadow:0 0 0 3px rgba(37,99,235,.1);
  outline:none;
}
.form-control:disabled,.form-select:disabled{
  background:#f8f9fa;
  opacity:.7;
}
.form-label{
  font-weight:500;
  margin-bottom:.5rem;
  color:var(--app-text);
  font-size:.875rem;
}
.input-group-text{
  background:rgba(243,245,249,.8);
  border:1px solid var(--app-border);
  border-radius:8px 0 0 8px;
}
.input-group .form-control:first-child{
  border-radius:0 8px 8px 0;
}

/* Modal Styles */
.modal-content{
  border:none;
  border-radius:var(--app-radius);
  box-shadow:var(--app-shadow-lg);
}
.modal-header{
  border-bottom:1px solid var(--app-border);
  padding:1.25rem 1.5rem;
}
.modal-body{
  padding:1.5rem;
}
.modal-footer{
  border-top:1px solid var(--app-border);
  padding:1rem 1.5rem;
}
.modal-backdrop{
  background:rgba(15,23,42,.5);
  backdrop-filter:blur(2px);
}

/* Badge Styles */
.badge{
  padding:.35em .65em;
  font-weight:500;
  border-radius:6px;
  font-size:.75rem;
}

/* Loading Spinner */
.spinner-border-sm{
  width:1rem;
  height:1rem;
  border-width:2px;
}
.app-loading{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  color:var(--app-muted);
  font-size:.875rem;
}
.app-loading::before{
  content:'';
  width:1rem;
  height:1rem;
  border:2px solid var(--app-border);
  border-top-color:var(--app-primary);
  border-radius:50%;
  animation:spin .6s linear infinite;
}
@keyframes spin{
  to{transform:rotate(360deg)}
}

/* Loading Overlay */
.app-loading-overlay{
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(255,255,255,.9);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  border-radius:var(--app-radius);
}
.app-loading-overlay .spinner-border{
  width:3rem;
  height:3rem;
  border-width:3px;
}

/* Empty State */
.app-empty{
  text-align:center;
  padding:3rem 1rem;
  color:var(--app-muted);
}
.app-empty-icon{
  font-size:3rem;
  opacity:.3;
  margin-bottom:1rem;
}

/* Mobile Top Header - Modern Design */
.app-topbar-mobile{
  position:fixed;
  top:0;
  left:0;
  right:0;
  height:64px;
  background:rgba(255,255,255,0.8);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  border-bottom:1px solid var(--app-border);
  z-index:1020;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 1rem;
  padding-top:max(env(safe-area-inset-top, 0), 0.5rem);
  padding-bottom:max(env(safe-area-inset-top, 0), 0.5rem);
  box-shadow:0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

.app-topbar-mobile .header-title{
  font-size:1.125rem;
  font-weight:700;
  color:var(--app-text);
  letter-spacing:-0.02em;
  flex:1;
  min-width:0;
}

.app-topbar-mobile .header-actions{
  display:flex;
  align-items:center;
  gap:0.5rem;
}

.app-topbar-mobile .header-btn{
  width:40px;
  height:40px;
  border-radius:12px;
  border:none;
  background:transparent;
  color:var(--app-muted);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:all 0.2s cubic-bezier(0.4,0,0.2,1);
  position:relative;
  -webkit-tap-highlight-color:transparent;
}

.app-topbar-mobile .header-btn:active{
  transform:scale(0.95);
  background:rgba(15,23,42,0.08);
}

.app-topbar-mobile .header-btn i{
  font-size:1.25rem;
}

.app-topbar-mobile .header-btn .badge{
  position:absolute;
  top:6px;
  right:6px;
  width:8px;
  height:8px;
  border-radius:50%;
  background:#ef4444;
  border:2px solid white;
  padding:0;
  font-size:0;
}

/* Mobile Main Content */
.app-main-mobile{
  padding-top:calc(64px + max(env(safe-area-inset-top, 0), 0.5rem) * 2 + 1rem) !important;
  padding-bottom:calc(76px + max(env(safe-area-inset-bottom, 0), 0.5rem) + 1.5rem) !important;
  min-height:calc(100vh - 64px - 76px - max(env(safe-area-inset-top, 0), 0.5rem) * 2 - max(env(safe-area-inset-bottom, 0), 0.5rem));
}

/* Mobile Bottom Nav - Modern Design */
.app-bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  min-height:76px;
  background:rgba(255,255,255,0.95);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  border-top:1px solid var(--app-border);
  z-index:1030;
  box-shadow:0 -4px 12px rgba(0,0,0,0.08);
  padding:0.75rem 0.75rem;
  padding-bottom:calc(0.75rem + max(env(safe-area-inset-bottom, 0), 0.5rem));
}

.app-bottom-nav .nav-container{
  display:flex;
  justify-content:space-around;
  align-items:center;
  height:100%;
  gap:0.25rem;
}

.app-bottom-nav a{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:0.25rem;
  padding:0.375rem 0.5rem;
  border-radius:16px;
  text-decoration:none;
  color:var(--app-muted);
  font-size:0.75rem;
  font-weight:500;
  transition:all 0.3s cubic-bezier(0.4,0,0.2,1);
  position:relative;
  min-width:0;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}

.app-bottom-nav a::before{
  content:'';
  position:absolute;
  inset:0;
  border-radius:16px;
  background:var(--app-primary);
  opacity:0;
  transform:scale(0.8);
  transition:all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.app-bottom-nav a.active::before{
  opacity:0.1;
  transform:scale(1);
}

.app-bottom-nav a i{
  font-size:1.5rem;
  position:relative;
  z-index:1;
  transition:all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.app-bottom-nav a span{
  position:relative;
  z-index:1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
  transition:all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.app-bottom-nav a.active{
  color:var(--app-primary);
}

.app-bottom-nav a.active i{
  transform:scale(1.1);
}

.app-bottom-nav a.active span{
  font-weight:600;
}

.app-bottom-nav a:active{
  transform:scale(0.95);
}

/* Mobile page wrapper */
.app-page{
  /* Ensure body doesn't have extra padding that conflicts */
  padding:0;
  margin:0;
  overflow-x:hidden;
}

/* Toast Container */
.toast-container{
  z-index:1080;
}
.toast{
  border-radius:8px;
  box-shadow:var(--app-shadow-lg);
}

/* Alert Styles */
.alert{
  border-radius:8px;
  border:none;
  padding:.75rem 1rem;
}
.alert-dismissible .btn-close{
  padding:.75rem 1rem;
}

/* Pagination */
.btn-group .btn{
  border-radius:0;
}
.btn-group .btn:first-child{
  border-radius:8px 0 0 8px;
}
.btn-group .btn:last-child{
  border-radius:0 8px 8px 0;
}

/* Responsive Improvements */
@media (max-width:991px){
  .app-navbar .navbar-nav{
    margin-top:1rem;
    padding-top:1rem;
    border-top:1px solid rgba(255,255,255,.1);
  }
  .app-navbar .nav-link{
    padding:.6rem .75rem;
  }
  .app-navbar .d-flex.align-items-center.gap-2{
    margin-top:1rem;
    padding-top:1rem;
    border-top:1px solid rgba(255,255,255,.1);
    width:100%;
    justify-content:space-between;
  }
}

@media (max-width:768px){
  .app-card{
    border-radius:12px;
  }
  .table{
    font-size:.875rem;
  }
  .table thead th{
    padding:.5rem;
    font-size:.7rem;
  }
  .table td{
    padding:.5rem;
  }
  .modal-dialog{
    margin:.5rem;
  }
  .modal-content{
    border-radius:12px;
  }
  .brand-name{
    font-size:.85rem;
  }
  .brand-subtitle{
    font-size:.65rem;
  }
}

/* Print Styles */
@media print{
  .app-navbar,.app-bottom-nav,.btn,.no-print{
    display:none !important;
  }
  .app-card{
    box-shadow:none;
    border:1px solid #ddd;
  }
  .table{
    border-collapse:collapse;
  }
  .table thead th{
    background:#f5f5f5 !important;
    -webkit-print-color-adjust:exact;
    print-color-adjust:exact;
  }
}

/* Utility Classes */
.text-truncate-2{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.text-truncate-3{
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

/* Scrollbar Styles */
::-webkit-scrollbar{
  width:8px;
  height:8px;
}
::-webkit-scrollbar-track{
  background:rgba(243,245,249,.5);
}
::-webkit-scrollbar-thumb{
  background:var(--app-border);
  border-radius:4px;
}
::-webkit-scrollbar-thumb:hover{
  background:var(--app-muted);
}

/* Focus Visible */
*:focus-visible{
  outline:2px solid var(--app-primary);
  outline-offset:2px;
}

/* Animation Classes */
.fade-in{
  animation:fadeIn .3s ease-in;
}
@keyframes fadeIn{
  from{opacity:0;transform:translateY(10px)}
  to{opacity:1;transform:translateY(0)}
}

.slide-in{
  animation:slideIn .3s ease-out;
}
@keyframes slideIn{
  from{opacity:0;transform:translateX(-20px)}
  to{opacity:1;transform:translateX(0)}
}

/* Error States */
.is-invalid{
  border-color:var(--app-danger) !important;
}
.invalid-feedback{
  display:block;
  color:var(--app-danger);
  font-size:.875rem;
  margin-top:.25rem;
}

/* Success States */
.is-valid{
  border-color:var(--app-success) !important;
}
.valid-feedback{
  display:block;
  color:var(--app-success);
  font-size:.875rem;
  margin-top:.25rem;
}

/* Disabled States */
.disabled,.disabled *{
  opacity:.6;
  cursor:not-allowed;
  pointer-events:none;
}

