@import './tokens.css';

/* Layout Container */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar (RTL: right side) */
.app-sidebar {
  width: 260px;
  background-color: var(--centrly-white);
  border-left: 1px solid var(--centrly-line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--centrly-line);
}

.brand-logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--centrly-blue-700), var(--centrly-blue-900));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--centrly-white);
  font-weight: 900;
  font-size: 1.25rem;
  font-family: var(--font-family-heading);
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--centrly-ink);
  font-family: var(--font-family-heading);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--centrly-text);
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--centrly-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.15s ease-in-out;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
}

.nav-link:hover {
  background-color: var(--centrly-blue-100);
  color: var(--centrly-blue-800);
}

.nav-link.active {
  background-color: var(--centrly-blue-100);
  color: var(--centrly-blue-800);
  border-right: 4px solid var(--centrly-blue-700);
  font-weight: 700;
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--centrly-surface);
}

/* Top Navbar */
.app-topbar {
  height: 64px;
  background-color: var(--centrly-white);
  border-bottom: 1px solid var(--centrly-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content-body {
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Card Component */
.card {
  background-color: var(--centrly-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--centrly-line);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--centrly-line);
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--centrly-ink);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  text-decoration: none;
  font-family: var(--font-family-arabic);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Universal Button Tactile Click Feedback */
button,
.btn,
a.btn,
.nav-link,
.tab,
.action-btn,
.table-btn,
.icon-btn,
input[type="button"],
input[type="submit"] {
  transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

button:active,
.btn:active,
a.btn:active,
.nav-link:active,
.tab:active,
.action-btn:active,
.table-btn:active,
.icon-btn:active,
input[type="button"]:active,
input[type="submit"]:active {
  transform: scale(0.94) translateY(1.5px) !important;
  filter: brightness(0.90) contrast(1.05) !important;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.28) !important;
}

.btn-primary {
  background-color: var(--centrly-blue-700);
  color: var(--centrly-white);
  box-shadow: 0 2px 5px rgba(41, 73, 186, 0.25);
}

.btn-primary:hover {
  background-color: var(--centrly-blue-800);
  box-shadow: 0 4px 10px rgba(41, 73, 186, 0.35);
}

.btn-secondary {
  background-color: var(--centrly-white);
  border-color: var(--centrly-line);
  color: var(--centrly-ink);
}

.btn-secondary:hover {
  background-color: var(--centrly-surface);
  border-color: #cbd5e1;
}

.btn-success {
  background-color: #16a34a !important;
  color: #ffffff !important;
  border: 1px solid #15803d !important;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  background-color: #15803d !important;
  border-color: #166534 !important;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.btn-danger {
  background-color: var(--centrly-danger);
  color: var(--centrly-white);
  box-shadow: 0 2px 5px rgba(201, 65, 77, 0.25);
}

.btn-danger:hover {
  background-color: #b91c1c;
  box-shadow: 0 4px 10px rgba(201, 65, 77, 0.35);
}

.btn-warning {
  background-color: #d97706 !important;
  color: #ffffff !important;
  border: 1px solid #b45309 !important;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
}

.btn-warning:hover {
  background-color: #b45309 !important;
  border-color: #92400e !important;
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.4);
}

.btn-amber {
  background-color: var(--centrly-amber-600);
  color: var(--centrly-white);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
}

/* Form Controls */
.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--centrly-ink);
}

.form-input, .form-select, .form-textarea {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--centrly-line);
  background-color: var(--centrly-white);
  color: var(--centrly-ink);
  font-family: var(--font-family-arabic);
  font-size: 0.875rem;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--centrly-blue-600);
  box-shadow: 0 0 0 3px rgba(70, 101, 211, 0.15);
}

/* Password Visibility Toggle Button */
.password-toggle-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  outline: none !important;
  box-shadow: none !important;
  cursor: pointer;
  color: var(--centrly-text);
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: color 0.15s ease, background-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.password-toggle-btn:hover {
  color: var(--centrly-blue-700);
  background-color: rgba(70, 101, 211, 0.08);
}

.password-toggle-btn:focus,
.password-toggle-btn:focus-visible,
.password-toggle-btn:active {
  outline: none !important;
  box-shadow: none !important;
  background-color: rgba(70, 101, 211, 0.12);
}

.password-toggle-btn svg {
  display: block;
  pointer-events: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success {
  background-color: var(--centrly-success-light);
  color: var(--centrly-success);
}

.badge-warning {
  background-color: var(--centrly-warning-light);
  color: var(--centrly-warning);
}

.badge-danger {
  background-color: var(--centrly-danger-light);
  color: var(--centrly-danger);
}

.badge-blue {
  background-color: var(--centrly-blue-100);
  color: var(--centrly-blue-700);
}

/* Data Table Styles - Clean Spacing & Non-stick Cells */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.875rem;
  background-color: var(--centrly-white);
  border-radius: var(--radius-md);
}

.data-table th {
  background-color: #f8fafc;
  color: var(--centrly-text);
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid var(--centrly-line);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--centrly-line);
  color: var(--centrly-ink);
  vertical-align: middle;
  line-height: 1.5;
}

.data-table tbody tr:hover {
  background-color: #f1f5f9;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Actions Spacing */
.data-table td .btn {
  margin: 0.15rem 0.25rem;
}

/* ==========================================================================
   Modal Dialogs & Responsive Scrolling System
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.modal-dialog {
  background-color: var(--centrly-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 2rem) !important;
  max-height: calc(100dvh - 2rem) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  margin: auto !important;
  animation: modalIn 0.2s ease-out;
  border: 1px solid var(--centrly-line);
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--centrly-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* Custom smooth scrollbar for modal-body */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--centrly-line);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  background-color: #fafbfc;
}

#sidebarToggle {
  display: none;
}

/* Responsive Drawer & Comprehensive Mobile Optimizations */
@media (max-width: 768px) {
  #sidebarToggle {
    display: inline-flex !important;
  }
  .app-sidebar {
    position: fixed;
    right: -290px;
    top: 0;
    bottom: 0;
    height: 100vh;
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .app-sidebar.open {
    right: 0;
    box-shadow: -6px 0 25px rgba(0, 0, 0, 0.2);
  }
  .app-sidebar .mobile-close-btn {
    display: inline-flex !important;
  }

  /* Prevent iOS Safari from automatically zooming into inputs on focus */
  input, select, textarea, .form-input, .form-select, .form-textarea, .filter-select {
    font-size: 16px !important;
  }

  /* Rapid touch response without 300ms tap delay */
  button, a, .btn, .nav-link, input, select, label {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Mobile container padding & clean card spacing */
  .content-body {
    padding: 0.85rem 0.65rem !important;
  }
  .app-topbar {
    padding: 0 0.85rem !important;
  }
  .card {
    padding: 1rem 0.85rem !important;
    max-width: 100% !important;
    border-radius: var(--radius-md) !important;
  }

  /* Table horizontal scrolling without breaking mobile layout */
  .card:has(table), .card:has(.data-table), .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modals full-width & max-height control on mobile */
  .modal-overlay {
    padding: 0.5rem !important;
  }
  .modal-dialog {
    max-height: calc(100dvh - 1rem) !important;
    width: 100% !important;
    margin: auto 0 !important;
  }
}

/* Scanner Laser Line Animation */
@keyframes centrlyLaserScan {
  0% { top: 6%; opacity: 0.6; }
  50% { top: 92%; opacity: 1; }
  100% { top: 6%; opacity: 0.6; }
}

.scanner-laser-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #10b981, #34d399, #10b981, transparent);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.9);
  animation: centrlyLaserScan 2s infinite ease-in-out;
  pointer-events: none;
  z-index: 10;
}

/* Sleek Top Progress Bar for Instant Page Feedback */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8, #38bdf8, #2563eb);
  background-size: 200% 100%;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.top-progress-bar.active {
  opacity: 1;
  animation: centrlyProgressPulse 1.2s infinite linear;
}

@keyframes centrlyProgressPulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Centrly Shimmer Skeleton Loaders */
@keyframes centrlyShimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-box {
  display: inline-block;
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.65) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  border-radius: 6px;
  animation: centrlyShimmer 1.4s infinite ease-in-out;
}

.skeleton-row td {
  padding: 1rem 1rem !important;
  vertical-align: middle;
}

.skeleton-card {
  background: var(--centrly-white);
  border: 1px solid var(--centrly-line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

@keyframes centrlyPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}



