/* ============================================================
   BASE.CSS — Reset, layout, navigation, containers
   ============================================================ */

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── Body ── */
body {
  font-family: var(--font-body);
  background: #0f172a; /* Solid professional dark navy */
  min-height: 100vh;
  padding: 0; /* Removing padding from body to avoid double padding with modal */
  margin: 0;
  color: var(--dark);
}

/* ── Animations ── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px)
  }

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

@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0
  }

  to {
    transform: translateX(0);
    opacity: 1
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px)
  }

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

@keyframes pulse {

  0%,
  100% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.05)
  }
}

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

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  25% {
    transform: translateX(-10px)
  }

  75% {
    transform: translateX(10px)
  }
}

/* ── Navigation ── */
.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  margin: 0 auto 30px;
  max-width: 1100px;
  position: sticky;
  top: 10px;
  z-index: var(--z-nav);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.nav-brand:hover {
  transform: scale(1.02);
}

.nav-logo {
  font-size: 24px;
  filter: drop-shadow(0 0 10px var(--primary-light));
}

.nav-title {
  font-size: 16px;
  font-weight: 900;
  color: white;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 2px;
}

.nav-tab {
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.nav-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Session Indicator ── */
/* ── User Profile Menu ── */
.user-profile-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-avatar:hover {
  transform: scale(1.05);
  border-color: white;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 240px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-nav);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown.show {
  display: flex;
}

.user-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.user-info-name {
  color: white;
  font-weight: 800;
  font-size: 14px;
}

.user-info-plan {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.user-info-plan .sub-pill {
  margin: 0;
  font-size: 9px;
}

.dropdown-item {
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.dropdown-item i {
  font-style: normal;
  font-size: 16px;
}

.dropdown-item.logout {
  color: #fca5a5;
}

.dropdown-item.logout:hover {
  background: rgba(239, 68, 68, 0.2);
}

.sub-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 800;
  text-transform: uppercase;
}

.sub-pill.ok {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.sub-pill.warn {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.sub-pill.bad {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ── Header Currency Control ── */
.header-currency-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 50px;
  transition: var(--transition);
}

.header-currency-control:hover {
  background: rgba(255, 255, 255, 0.2);
}

.currency-flag-icon {
  font-size: 14px;
}

.header-currency-select {
  background: transparent;
  border: none;
  color: white;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  width: auto;
  outline: none;
}

.header-currency-select option {
  color: black;
}

.nav-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* ── Two-column layout (Form + Preview) ── */
.container {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 500px 1fr;
  gap: 30px;
  animation: fadeIn 0.5s ease-in;
}

/* ── Form Panel ── */
.form-panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  height: fit-content;
  position: sticky;
  top: 20px;
  max-height: 95vh;
  overflow-y: auto;
  animation: slideIn 0.6s ease-out;
}

.form-panel::-webkit-scrollbar {
  width: 8px;
}

.form-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.form-panel::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--primary);
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 3px;
  background: var(--primary-light);
  border-radius: 3px;
}

.header h1 {
  color: #1e3c72;
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #1e3c72, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  font-size: 13px;
  color: #64748b;
}

/* ── Preview Panel ── */
.preview-panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  min-height: 800px;
  animation: slideIn 0.7s ease-out;
}

/* ── Form Sections ── */
.form-section {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--light);
  border-radius: var(--radius-md);
  border: 1px solid #e5e7eb;
  transition: var(--transition);
}

.form-section:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(126, 34, 206, .1);
}

.form-section h2 {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section h2::before {
  content: '●';
  color: var(--primary);
  font-size: 10px;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 5px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font-body);
  background: white;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(126, 34, 206, .1);
  transform: translateY(-1px);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* ── Page Sections ── */
.page-section {
  animation: fadeIn 0.4s ease-in;
}

.page-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 10px 40px;
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

/* ── A4 Preview ── */
.a4-outer-clip {
  height: calc(100vh - 120px);
  overflow: auto;
  position: relative;
  border-radius: var(--radius-sm);
  background: #e8eaf6;
}

.a4-scale-wrap {
  transform-origin: top center;
  transition: transform .2s ease;
}

.a4-preview-shell {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: white;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .13);
  border-radius: 4px;
  overflow: visible;
  position: relative;
}

.a4-preview-shell .invoice-wrap {
  padding: 32px 36px 28px;
  min-height: 1123px;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.a4-ruler {
  position: absolute;
  right: -28px;
  top: 0;
  width: 22px;
  height: 1123px;
  display: flex;
  flex-direction: column;
  font-size: 8px;
  color: rgba(255, 255, 255, .5);
  pointer-events: none;
}

.a4-ruler-label {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  text-align: center;
  background: rgba(255, 255, 255, .15);
  border-radius: 3px;
  padding: 4px 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  width: 18px;
  margin: auto;
}

.preview-zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(126, 34, 206, .12);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* ── Sub-forms ── */
.sub-form {
  background: #f8fafc;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}

.sub-form-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 14px;
}

/* ── Misc ── */
.search-input {
  padding: 8px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  width: 200px;
}

.empty-state {
  color: #94a3b8;
  text-align: center;
  padding: 18px 0;
  font-size: 13px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid #e5e7eb;
}

.share-btn:hover {
  border-color: var(--primary);
  background: #ede9fe;
  transform: translateY(-2px);
}

.share-icon {
  font-size: 22px;
}

.share-sub {
  font-size: 10px;
  color: #94a3b8;
}

/* ── Page Hero Banner ── */
.page-hero-banner {
  background: linear-gradient(135deg, #1e3c72, #2a5298, var(--primary));
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}

.page-hero-banner::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 160px;
  height: 160px;
  background: rgba(255, 255, 255, .05);
  border-radius: 50%;
  pointer-events: none;
}

.page-hero-banner h2 {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 4px;
}

.page-hero-banner p {
  opacity: .7;
  font-size: 13px;
}

/* ── Notification panel ── */
.notif-bell {
  position: relative;
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 800;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-panel {
  position: fixed;
  top: 70px;
  right: 15px;
  width: 320px;
  background: white;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-notif);
  border: 1.5px solid #e5e7eb;
}

/* ── Doc type tabs ── */
.doc-type-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-tab {
  flex: 1;
  padding: 9px 12px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  background: white;
  font-family: var(--font-body);
  transition: var(--transition);
}

.doc-tab:hover {
  border-color: var(--primary);
}

.doc-tab.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}

/* ── History item ── */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--primary);
  background: white;
}

.hist-item-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.history-btn {
  padding: 6px 10px;
  font-size: 11px;
}

.doc-type-badge {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 800;
  display: inline-block;
}

.doc-type-badge.invoice {
  background: #ede9fe;
  color: #7e22ce;
}

.doc-type-badge.quote {
  background: #e0f2fe;
  color: #0369a1;
}

.doc-type-badge.delivery {
  background: #dcfce7;
  color: #166534;
}

/* ── Onboarding ── */
.onboard-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
}

.onboard-box {
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp .6s ease-out;
}

.onboard-box h2 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #1e3c72, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Print ── */
@page {
  size: A4 portrait;
  margin: 10mm 12mm 10mm 12mm;
}

@media print {

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  .form-panel,
  .auth-overlay,
  .session-indicator,
  .loading-overlay,
  .toast,
  .modal-overlay,
  .page-nav,
  .dark-toggle,
  .notif-bell,
  .notif-panel,
  .onboard-overlay,
  #dashboardPage,
  #clientsPage,
  #catalogPage,
  #revTrackerPage,
  #expensesPage,
  #adminPage {
    display: none !important;
  }

  .container {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .preview-panel {
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  body {
    background: white !important;
    padding: 0 !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #a4OuterClip {
    height: auto !important;
    overflow: visible !important;
  }

  .a4-scale-wrap {
    transform: none !important;
    height: auto !important;
  }

  .a4-preview-shell {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .invoice-wrap {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
  }
} 


/* Advanced GST & Rich Text Styles */
#gstSpecificFields .form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 10px;
}
.ql-toolbar.ql-snow {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.ql-container.ql-snow {
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  background: #ffffff;
  font-family: inherit;
  font-size: 14px;
}
.ql-editor { min-height: 80px; }
#notesEditor .ql-editor { min-height: 150px; }
.item-desc-editor .ql-editor { min-height: 60px; }
.ql-editor.ql-blank::before { color: #94a3b8; font-style: normal; }
.ql-snow.ql-toolbar button:hover .ql-stroke { stroke: var(--primary); }
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }
