/* =========================================================
   PROFESSIONAL INVOICE GENERATOR - HIGH PERFORMANCE STYLING
   Optimized for low-end devices, mobile phones, and 100% clean PDF
   ========================================================= */

:root {
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  --primary-glow: 0 4px 14px rgba(37, 99, 235, 0.35);
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --success-glow: 0 4px 14px rgba(16, 185, 129, 0.3);
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --app-bg: #0b1120;
  --toolbar-bg: rgba(15, 23, 42, 0.92);
  --toolbar-border: rgba(255, 255, 255, 0.09);
  --card-bg: #ffffff;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --paper-width: 210mm;
  --paper-min-height: 297mm;
  --sheet-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

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

body {
  font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 60%, #080d1a 100%);
  background-attachment: fixed;
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.lang-fr {
  font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  direction: ltr;
}

/* =========================================================
   TOP APPLICATION TOOLBAR (Sleek Glassmorphism & High Contrast)
   ========================================================= */

.app-toolbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--toolbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--toolbar-border);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  gap: 0.85rem;
  flex-wrap: wrap;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: var(--primary-gradient);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--primary-glow);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Modern Performance Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
  min-height: 36px;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Action (PDF Download) */
.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--primary-glow);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

/* Restore Sample */
.btn-restore {
  background: var(--success-gradient);
  color: #ffffff;
  box-shadow: var(--success-glow);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-restore:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

/* Secondary / Rows Actions */
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Outlines */
.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Danger / Reset */
.btn-danger-outline {
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}

/* =========================================================
   DOCUMENT WORKSPACE (Modern Canvas & Paper)
   ========================================================= */

.document-container {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.75rem 1rem 5.5rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* A4 Sheet Dimensions & Exact Styling */
.invoice-sheet {
  width: var(--paper-width);
  min-height: var(--paper-min-height);
  background: var(--card-bg);
  box-shadow: var(--sheet-shadow);
  border-radius: 4px;
  padding: 10mm 16mm 12mm 12mm; /* Safe margins: 16mm on right ensures 0% cutoff */
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: #000000;
  font-size: 11px;
  line-height: 1.35;
  position: relative;
  box-sizing: border-box;
}

/* Editable Elements in Web View */
[contenteditable="true"] {
  outline: none;
  border-radius: 3px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 15px;
  display: inline-block;
}

body:not(.exporting-pdf) [contenteditable="true"]:hover {
  background-color: #f0fdf4;
  box-shadow: 0 0 0 1px #86efac;
}

body:not(.exporting-pdf) [contenteditable="true"]:focus {
  background-color: #ffffff;
  box-shadow: 0 0 0 2px #2563eb;
}

/* =========================================================
   HEADER SECTION (EXACT ALIGNMENT & PROPORTIONS)
   ========================================================= */

.invoice-top-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
  width: 100%;
}

/* Left Supplier Info */
.supplier-info {
  width: 58%;
  display: flex;
  flex-direction: column;
}

.supplier-name {
  font-size: 13.5px;
  font-weight: bold;
  margin-bottom: 2px;
  display: block;
}

.supplier-activity {
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 2px;
  display: block;
}

.supplier-address {
  font-size: 10.5px;
  margin-bottom: 3px;
  display: block;
}

.info-line {
  font-size: 10.5px;
  margin-bottom: 2px;
  display: block;
}

.info-label {
  font-weight: 500;
}

.info-value {
  font-weight: 500;
}

.supplier-bank {
  font-size: 10.5px;
  margin-top: 2px;
  font-weight: 500;
  display: block;
}

.supplier-agency {
  font-size: 10.5px;
  font-weight: 500;
  display: block;
}

/* Top Right Meta: facture, du, délai */
.invoice-meta-right {
  width: 38%;
  padding-left: 10px;
}

.dotted-field {
  display: flex;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 11.5px;
}

.field-title {
  font-weight: 500;
  margin-right: 6px;
  white-space: nowrap;
}

.field-dots {
  flex: 1;
  font-family: inherit;
  letter-spacing: 1px;
}

.delay-field {
  display: flex;
  align-items: baseline;
  font-size: 11.5px;
  margin-top: 4px;
}

.delay-value {
  font-weight: bold;
  margin-left: 4px;
}

/* Client Demand Block (Centered directly above the table) */
.client-demand-block {
  text-align: center;
  margin: 10px auto 8px auto;
  display: block;
}

.client-demand {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 3px;
  display: block;
}

.client-service {
  font-size: 11px;
  display: block;
}

/* Table Title */
.table-title-container {
  text-align: center;
  margin: 10px 0 8px 0;
}

.table-title {
  display: inline-block;
  font-size: 13px;
  font-weight: bold;
  text-decoration: underline;
}

/* =========================================================
   TABLE DESIGN & SPACING (LEFT-SHIFTED, 100% VISIBLE ON RIGHT)
   ========================================================= */

.table-wrapper {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #000;
  font-size: 10.5px;
  table-layout: fixed;
  box-sizing: border-box;
}

.invoice-table th,
.invoice-table td {
  border: 1px solid #000;
  padding: 3px 4px;
  vertical-align: middle;
  box-sizing: border-box;
}

.invoice-table thead th {
  font-weight: bold;
  text-align: center;
  background-color: #ffffff;
  padding: 4px 3px;
}

/* Column Widths (Calibrated to never overflow) */
.col-n {
  width: 22px;
  text-align: center;
}

.col-designation {
  width: auto;
  text-align: left;
}

.col-unite {
  width: 28px;
  text-align: center;
}

.col-qte {
  width: 38px;
  text-align: center;
}

.col-prix {
  width: 74px;
  text-align: right;
}

.col-montant {
  width: 82px;
  text-align: right;
}

.col-actions {
  width: 48px;
  text-align: center;
  background: #f8fafc;
}

/* Section Header Rows */
.section-row td {
  font-weight: bold;
  background-color: #fbfbfb;
  padding: 4px 5px;
}

.section-title-cell {
  font-weight: bold;
}

.item-row td {
  height: 20px;
}

.item-row td.text-center {
  text-align: center;
}

.item-row td.text-right {
  text-align: right;
  padding-right: 5px;
  white-space: nowrap;
}

/* Inputs in table cells */
.cell-input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.table-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  padding: 1px 2px;
  outline: none;
}

body:not(.exporting-pdf) .table-input:hover {
  background-color: #eff6ff;
  border-radius: 2px;
}

body:not(.exporting-pdf) .table-input:focus {
  background-color: #ffffff;
  outline: 1.5px solid #2563eb;
  border-radius: 2px;
}

.table-input.text-center {
  text-align: center;
}

.table-input.text-right {
  text-align: right;
}

/* Action buttons per row */
.row-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 1px;
}

.btn-row-action {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-row-action:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-row-action.delete-action:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Microphone Voice Input Button */
.btn-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 1px 3px;
  font-size: 10px;
  color: #94a3b8;
  border-radius: 3px;
  transition: all 0.15s ease;
  line-height: 1;
  opacity: 0.6;
}

.cell-input-wrapper:hover .btn-mic,
.btn-mic:focus {
  opacity: 1;
  color: #2563eb;
}

.btn-mic:hover {
  opacity: 1;
  background: #e0e7ff;
  color: #1d4ed8;
  transform: scale(1.1);
}

.btn-mic.listening {
  opacity: 1 !important;
  color: #dc2626 !important;
  background: #fee2e2 !important;
  animation: micPulse 1s infinite alternate;
}

@keyframes micPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  100% { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

/* Table Totals */
.totals-tbody {
  page-break-inside: avoid;
}

.tfoot-row td {
  padding: 4px 6px;
  font-weight: bold;
  border: 1px solid #000 !important;
  color: #000000 !important;
}

.total-label {
  text-align: left !important;
  font-weight: bold !important;
  font-size: 11px !important;
  color: #000000 !important;
  padding-left: 8px !important;
}

.total-amount {
  text-align: right !important;
  font-weight: bold !important;
  font-size: 11px !important;
  color: #000000 !important;
  padding-right: 6px !important;
  user-select: text;
  white-space: nowrap;
}

.total-amount.manual-editable {
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

body:not(.exporting-pdf) .total-amount.manual-editable:hover {
  background-color: #fef3c7;
}

body:not(.exporting-pdf) .total-amount.manual-editable:focus {
  background-color: #ffffff;
  outline: 2px solid #d97706;
  border-radius: 2px;
}

/* Signatures */
.invoice-signature {
  display: flex;
  justify-content: flex-end;
  margin-top: 25px;
  padding-right: 35px;
  page-break-inside: avoid;
}

.signature-box {
  text-align: center;
  min-width: 140px;
}

.signature-title {
  font-size: 11.5px;
  font-weight: bold;
  white-space: nowrap;
}

/* =========================================================
   FLOATING SPEED CONTROLS
   ========================================================= */

.floating-controls {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
}

body.lang-ar .floating-controls {
  right: auto;
  left: 1.5rem;
}

.btn-floating {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border-radius: 50px;
  padding: 0.55rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-floating:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-floating-print {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--primary-glow);
}

.btn-floating-print:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

/* =========================================================
   FLOATING ZOOM CONTROLLER (BOTTOM CENTER)
   ========================================================= */

.zoom-toolbar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50px;
  padding: 0.35rem 0.6rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 998;
  user-select: none;
}

.btn-zoom {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn-zoom:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: scale(1.08);
}

.btn-zoom:active {
  transform: scale(0.95);
}

.btn-zoom-level {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn-zoom-level:hover {
  background: rgba(37, 99, 235, 0.35);
  color: #ffffff;
}

@media (max-width: 600px) {
  .zoom-toolbar {
    bottom: 0.75rem;
    padding: 0.25rem 0.45rem;
  }
  
  .btn-zoom {
    width: 28px;
    height: 28px;
  }

  .btn-zoom-level {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
  }
}

/* Toast */
.toast {
  position: fixed;
  top: 4.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  color: #f8fafc;
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
  z-index: 10000;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* =========================================================
   PDF EXPORT STATE (Active during html2pdf generation)
   Strict zero right clipping & left margin shift
   ========================================================= */

body.exporting-pdf .no-print,
body.exporting-pdf .col-actions,
body.exporting-pdf .row-actions-cell,
body.exporting-pdf .floating-controls,
body.exporting-pdf .app-toolbar,
body.exporting-pdf .toast,
body.exporting-pdf .btn-mic {
  display: none !important;
}

body.exporting-pdf .invoice-sheet {
  box-shadow: none !important;
  border: none !important;
  padding: 10mm 16mm 12mm 12mm !important;
  width: 210mm !important;
  max-width: 210mm !important;
  min-height: 297mm !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  background: #ffffff !important;
}

body.exporting-pdf .table-wrapper {
  width: 100% !important;
  margin: 0 !important;
}

body.exporting-pdf .invoice-table {
  width: 100% !important;
  table-layout: fixed !important;
}

body.exporting-pdf [contenteditable="true"] {
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.exporting-pdf .table-input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #000000 !important;
}

/* =========================================================
   PRINT STYLES (100% CLEAN ROW INTEGRITY - ZERO BROWSER HEADERS)
   ========================================================= */

@page {
  size: A4 portrait;
  margin: 0mm !important; /* Zero margin instructs browser to hide URL footer and date header */
}

@media print {
  *, *:before, *:after {
    box-sizing: border-box !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif !important;
  }

  .no-print,
  .col-actions,
  .row-actions-cell,
  .btn-mic,
  .floating-controls,
  .zoom-toolbar,
  .lock-screen,
  .app-toolbar,
  .toast {
    display: none !important;
  }

  .document-container {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .invoice-sheet {
    width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
    padding: 10mm 15mm 12mm 12mm !important;
    margin: 0 auto !important;
    border: none !important;
  }

  [contenteditable="true"] {
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .table-input {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #000000 !important;
  }

  .table-wrapper {
    width: 100% !important;
    margin: 0 !important;
  }

  .invoice-table {
    width: 100% !important;
    margin: 0 auto !important;
    page-break-inside: auto;
  }

  .invoice-table tr,
  .invoice-table tbody tr,
  .item-row,
  .section-row {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: auto;
  }

  .invoice-table thead {
    display: table-header-group;
  }

  .totals-tbody {
    display: table-row-group !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .invoice-signature {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-top: 25px !important;
    padding-bottom: 10px !important;
    padding-right: 35px !important;
  }
}

/* =========================================================
   RESPONSIVE DESIGN (100% MOBILE & SMALL SCREEN SUPPORT)
   ========================================================= */

@media (max-width: 900px) {
  .document-container {
    padding: 0.75rem 0.5rem 5.5rem 0.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-toolbar {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .toolbar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .toolbar-actions {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 6px 0;
    gap: 0.4rem;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .toolbar-actions::-webkit-scrollbar {
    display: none;
  }

  .btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.76rem;
    min-height: 38px;
    flex-shrink: 0;
  }
}

@media (max-width: 600px) {
  .invoice-sheet {
    font-size: 11px;
    padding: 10mm 15mm 12mm 12mm;
    margin: 0 auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .floating-controls {
    bottom: 4.5rem;
    left: 0.75rem !important;
    right: auto !important;
    gap: 0.4rem;
  }

  body.lang-fr .floating-controls {
    left: auto !important;
    right: 0.75rem !important;
  }

  .btn-floating {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  }

  .zoom-toolbar {
    bottom: 0.75rem;
    padding: 0.3rem 0.55rem;
    background: rgba(15, 23, 42, 0.95);
    gap: 0.3rem;
  }

  .btn-zoom {
    width: 30px;
    height: 30px;
  }

  .btn-zoom-level {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .lock-card {
    padding: 1.75rem 1.25rem;
    max-width: 340px;
  }

  .lock-input {
    font-size: 16px; /* Prevents unwanted iOS zoom on input focus */
  }
}

/* =========================================================
   SECURITY LOCK SCREEN OVERLAY (PASSWORD PROTECTION)
   ========================================================= */

.lock-screen {
  position: fixed;
  inset: 0;
  background: rgba(8, 13, 26, 0.94);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lock-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-card {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(37, 99, 235, 0.2);
  text-align: center;
  animation: cardPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.lock-icon-badge {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.lock-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 0.35rem;
}

.lock-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 1.75rem;
  line-height: 1.4;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lock-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.lock-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.75rem 2.8rem 0.75rem 1rem;
  font-size: 0.95rem;
  color: #ffffff;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

body.lang-fr .lock-input {
  padding: 0.75rem 1rem 0.75rem 2.8rem;
}

.lock-input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.8rem;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.15s ease;
}

body.lang-fr .btn-toggle-pwd {
  right: auto;
  left: 0.8rem;
}

.btn-toggle-pwd:hover {
  color: #ffffff;
}

.lock-error-msg {
  font-size: 0.82rem;
  color: #f87171;
  font-weight: 600;
  min-height: 20px;
  display: none;
}

.btn-lock-submit {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 0.8rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
  transition: all 0.2s ease;
}

.btn-lock-submit:hover {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.55);
  transform: translateY(-1px);
}

.btn-lock-submit:active {
  transform: scale(0.98);
}

.shake {
  animation: shakeCard 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeCard {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}
