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

:root {
  --primary-color: #3b82f6;
  --secondary-color: #1e293b;
  --bg-color: #0f172a;
  --text-color: #f8fafc;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Motion Background */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(59,130,246,0.1) 0%, rgba(15,23,42,0) 70%);
  animation: bgPulse 15s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes bgPulse {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.2) translate(5%, 5%); }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

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

a:hover {
  color: #60a5fa;
}

/* Glassmorphism Utilities */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  padding: 1.5rem;
  transition: transform 0.3s, box-shadow 0.3s;
}

.glass-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar .logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  text-align: center;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-links li a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-color);
  font-weight: 500;
  transition: all 0.3s;
}

.nav-links li a:hover, .nav-links li a.active {
  background: rgba(59, 130, 246, 0.2);
  border-left: 4px solid var(--primary-color);
}

.main-content {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* Dashboard Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-card h3 {
  font-size: 0.875rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .amount {
  font-size: 2rem;
  font-weight: 700;
}

.stat-card.sales .amount { color: var(--primary-color); }
.stat-card.purchases .amount { color: var(--warning-color); }
.stat-card.bank .amount { color: #8b5cf6; }
.stat-card.pl .amount { color: var(--success-color); }

/* Forms & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #cbd5e1;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-color);
  font-family: 'Inter', sans-serif;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  text-align: center;
}

.btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: #94a3b8;
}

tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* File Upload Zone */
.upload-zone {
  border: 2px dashed var(--glass-border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-icon {
  font-size: 3rem;
  color: #94a3b8;
  margin-bottom: 1rem;
}

/* Utilities */
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.loader {
  border: 3px solid rgba(255,255,255,0.1);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* -------------------------------------------------------------
   MOBILE & TABLET RESPONSIVE SYSTEM (FOR CA ON MOBILE & IPAD)
------------------------------------------------------------- */

/* Mobile UI Elements (Default Hidden on Desktop > 1024px) */
.mobile-top-bar {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-drawer-header {
  display: none;
}

.mobile-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* TABLET RESPONSIVE DESIGN (769px - 1024px) */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }

  /* Mobile App Bar Header */
  .mobile-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 62px;
  }

  .mobile-menu-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
  }

  .mobile-menu-btn:active {
    background: rgba(59, 130, 246, 0.3);
  }

  .mobile-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .mobile-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .mobile-client-name {
    font-size: 0.72rem;
    color: #38bdf8;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
  }

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

  .mobile-action-pill {
    padding: 0.35rem 0.65rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #38bdf8;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
  }

  .mobile-action-pill.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
  }

  /* Off-Canvas Sliding Drawer Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 310px;
    max-width: 85vw;
    height: 100vh;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem 1rem;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .desktop-logo {
    display: none;
  }

  .mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
  }

  .mobile-drawer-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.5rem;
  }

  .mobile-drawer-close:active {
    color: #fff;
  }

  /* Tablet Content Padding */
  .main-content {
    padding: 1.5rem 1.25rem;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .top-header > div:last-child {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
  }
}

/* SMARTPHONE RESPONSIVE DESIGN (<= 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari input zoom */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Main Content Padding (Room for bottom nav) */
  .main-content {
    padding: 1rem 0.75rem 85px 0.75rem;
  }

  /* Typography */
  h2 { font-size: 1.35rem; }
  h3 { font-size: 1.15rem; }

  /* Dashboard Cards - Single Column Stack */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .stat-card .amount {
    font-size: 1.6rem;
  }

  .glass-panel {
    padding: 1rem;
    border-radius: 12px;
  }

  /* Top Header Action Buttons Horizontal Chip Bar */
  .top-header {
    margin-bottom: 1.25rem;
  }

  .top-header > div:last-child {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
  }

  .top-header > div:last-child::-webkit-scrollbar {
    display: none;
  }

  .top-header .btn {
    white-space: nowrap;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  /* Table Containers with Touch Scroll Hints */
  .table-container {
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
    position: relative;
    box-shadow: inset -8px 0 10px -8px rgba(255, 255, 255, 0.1);
  }

  th, td {
    padding: 0.65rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Mobile Bottom Quick Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border);
    z-index: 1500;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    min-width: 50px;
    height: 100%;
    transition: color 0.2s;
  }

  .mobile-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    margin-bottom: 0.2rem;
  }

  .mobile-nav-item.active,
  .mobile-nav-item:active {
    color: #38bdf8;
  }

  /* Sticky Bulk Action Bar Docked at Bottom for Thumb Reach */
  #bankBulkActionBar,
  #purBulkActionBar {
    position: fixed !important;
    bottom: 64px !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
    z-index: 1600 !important;
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.75) !important;
  }

  /* Mobile Form Controls */
  .form-control, input, select {
    min-height: 42px;
  }

  /* Mobile Upload Zone */
  .upload-zone {
    padding: 1.75rem 1rem;
  }

  .upload-icon {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
  }

  /* Responsive Modals on Mobile & Tablet */
  div[style*="position: fixed"][style*="z-index: 9999"] {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  div[style*="position: fixed"][style*="z-index: 9999"] > .glass-panel {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    padding: 1.5rem 1.25rem 2.5rem 1.25rem !important;
    animation: slideUpModal 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

