/* ==========================================================================
   Custom WooCommerce Invoice Generator - Complete Styles
   Version: 3.9.0 (Vertical Middle Fix, Desc Size, Currency)
   ========================================================================== */

.invoice-wrapper {
  font-family: 'FiraGO', sans-serif;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border: 1px solid #eee;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  background: #fff;
}

.invoice-wrapper input,
.invoice-wrapper textarea,
.invoice-wrapper select,
.invoice-wrapper button {
  font-family: 'FiraGO', sans-serif;
}

.invoice-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.company-logo { width: 140px; margin-bottom: 0; }
.company-logo img { width: 100%; height: auto; display: block; }

.invoice-title {
  text-align: right;
  font-weight: 700;
  color: #50529d;
  font-size: 20px;
  text-transform: capitalize;
  margin: 0;
}
.invoice-title input[type='text'] {
  border: none;
  font-weight: 700;
  color: #50529d;
  text-align: right;
  width: 140px;
  font-size: 20px;
  text-transform: capitalize;
  background: transparent;
}
.invoice-title input[type='text']:focus { outline: 1px dashed #50529d; outline-offset: 2px; }

.color-bar { height: 10px; background-color: #50529d; margin: 20px 0; }

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
}
.company-details,
.buyer-details {
  font-size: 14px;
  line-height: 1.6;
  width: 330px;
  flex-shrink: 0;
}
.company-details strong,
.buyer-details strong.editable-field {
  color: #333;
  font-weight: bold;
  display: inline-block;
}
.company-details ul,
.buyer-details ul { list-style: none; padding-left: 0; margin-top: 10px; margin-bottom: 0; }
.company-details li,
.buyer-details li {
  padding-left: 28px;
  position: relative;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  min-height: 22px;
}
.company-details li .icon-svg,
.buyer-details li .icon-svg {
  position: absolute; left: 0; width: 16px; height: 16px; fill: #555; flex-shrink: 0;
}

.buyer-details .editable-field,
.buyer-details .editable-value {
  cursor: text; padding: 1px 4px; border-radius: 3px; border: 1px dashed transparent; transition: all 0.2s ease;
}
.buyer-details .editable-field:hover,
.buyer-details .editable-value:hover { border: 1px dashed #ccc; background: #f9f9f9; }
.buyer-details .is-empty { color: #999 !important; font-style: italic; font-weight: 400 !important; }
.buyer-field-input { padding: 3px 5px; border: 1px solid #50529d; border-radius: 4px; font-size: 14px; width: 100%; box-sizing: border-box; }
.buyer-details strong.buyer-field-input { font-weight: bold; }

/* =====================
   TABLE
   ===================== */
#invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
  font-size: 12px;
  table-layout: fixed;
  border: 1px solid rgba(80, 82, 157, 0.5);
}
#invoice-table thead th {
  border: 1px solid rgba(80, 82, 157, 0.5);
  padding: 10px 8px;
  background-color: rgba(80, 82, 157, 0.1);
  text-align: center;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  text-transform: capitalize;
  color: #333;
  vertical-align: middle !important;
}
#invoice-table tbody td {
  border: 1px solid rgba(80, 82, 157, 0.5);
  padding: 6px 6px;
  vertical-align: middle !important; /* Force middle alignment */
  word-wrap: break-word;
}
#invoice-table tbody tr:first-child .btn-remove-row { display: none; }

/* Column widths */
#invoice-table .col-n { width: 3%; text-align: center; font-weight: bold; }
#invoice-table .col-name { width: 20%; }
#invoice-table .col-image { width: 12%; text-align: center; }
#invoice-table .col-brand { width: 10%; }
#invoice-table .col-desc { width: 18%; }
#invoice-table .col-qty { width: 7%; position: relative; }
#invoice-table .col-price { width: 9%; }
#invoice-table .col-total { width: 12%; }
#invoice-table .col-status { width: 7%; }
#invoice-table .col-actions { width: 2%; }

/* Smaller Font for Description (Specifications) */
#invoice-table td.col-desc {
    font-size: 10px; /* Smaller than standard 12px */
    line-height: 1.3;
}

/* Name column SKU subline */
.name-sub { margin-top: 4px; font-size: 11px; color: #666; line-height: 1.2; }
.name-sku-label { color: #888; margin-right: 4px; }
.name-sku-value { font-family: 'FiraGO', monospace; color: #333; }

/* Image cell */
#invoice-table td.col-desc,
#invoice-table td.col-image { padding-left: 8px; padding-right: 8px; }
#invoice-table .col-image img {
  width: 100%; height: auto; max-height: 70px; object-fit: contain; border: 1px solid #eee; display: block; margin: 0 auto;
}

/* Inputs */
#invoice-table input[type='text'],
#invoice-table input[type='number']:not(.quantity):not(.reservation-days),
#invoice-table textarea,
#invoice-table select {
  width: 100%; border: 1px solid #ccc; box-sizing: border-box; font-size: 12px; border-radius: 3px;
}
#invoice-table input[type='text'],
#invoice-table input[type='number']:not(.quantity):not(.reservation-days) { height: 22px; padding: 2px 4px; }
#invoice-table input:focus,
#invoice-table textarea:focus,
#invoice-table select:focus { border-color: #50529d; outline: none; box-shadow: 0 0 0 1px rgba(80, 82, 157, 0.2); }

textarea.product-desc { min-height: 80px; max-height: 240px; overflow: auto; resize: vertical; padding: 6px; line-height: 1.4; }

.product-status { width: 100%; padding: 3px 5px; border: 1px solid #ccc; border-radius: 3px; font-size: 11px; }
.reservation-days { width: 100%; padding: 3px 5px; border: 1px solid #ccc; border-radius: 3px; font-size: 11px; margin-top: 3px; }

.status-badge {
  display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 11px; font-weight: bold; text-align: center; line-height: 1.2;
}

/* Quantity stepper */
.quantity-wrapper { display: flex; align-items: center; width: 100%; justify-content: center; }
.quantity-wrapper input.quantity { flex-grow: 1; width: 30px; max-width: 40px; text-align: center; padding: 2px 4px; border: 1px solid #ccc; border-radius: 3px; height: 22px; }
.qty-btn-group { display: flex; flex-direction: column; flex-shrink: 0; margin-left: 5px; }
.qty-btn { width: 15px; height: 11px; padding: 0; font-size: 8px; line-height: 11px; text-align: center; border: none; background: transparent; color: #555; border-radius: 0; cursor: pointer; transition: all 0.15s ease; }
.qty-btn:hover { background: #f0f0f0; color: #000; }

/* Hide default arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Stock validation */
.stock-error { border-color: #dc3545 !important; background-color: #fff5f5 !important; animation: shake 0.3s ease; }
.stock-warning { display: inline-block; font-size: 10px; margin-left: 5px; white-space: nowrap; }
@keyframes shake { 0%, 100% { transform: translateX(0);} 25% { transform: translateX(-3px);} 75% { transform: translateX(3px);} }

/* Buttons */
.btn-remove-row { background: #e74c3c; color: white; border: none; cursor: pointer; padding: 5px 8px; border-radius: 3px; font-size: 10px; transition: background 0.2s ease; }
.btn-remove-row:hover { background: #c0392b; }
.invoice-actions { text-align: right; margin-top: 20px; }
.btn-add-row, .btn-save-invoice, .btn-print-invoice, .btn-remove-row, .btn-save-fictive, .btn-save-standard {
  padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: 500; margin: 0 5px; transition: all 0.2s ease;
}
.btn-add-row { background-color: #2ecc71; color: white; }
.btn-add-row:hover { background-color: #27ae60; }
.btn-save-invoice { background-color: #3498db; color: white; }
.btn-save-invoice:hover { background-color: #2980b9; }
.btn-save-invoice:disabled { background-color: #95a5a6; cursor: not-allowed; }
.btn-print-invoice { background-color: #9b59b6; color: white; }
.btn-print-invoice:hover { background-color: #8e44ad; }
.invoice-final-actions { text-align: center; margin-top: 40px; }

/* Summary */
.invoice-summary { display: flex; justify-content: flex-end; margin-top: 20px; }
.totals-table { width: 300px; font-size: 14px; border-collapse: collapse; }
.totals-table td { padding: 8px; border: 1px solid rgba(80, 82, 157, 0.5); }
.totals-table td:first-child { font-weight: bold; background-color: rgba(80, 82, 157, 0.1); }
#grand-total { font-weight: bold; font-size: 16px; color: #333; }

/* Footer */
.invoice-footer-bank { border-top: 2px solid #f0f0f0; padding-top: 20px; margin-top: 30px; align-items: flex-start; display: flex; justify-content: space-between; gap: 24px; }
.bank-details { font-size: 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.bank-details > strong { color: #333; margin-bottom: 2px; display: block; }
.bank-cards-row { display: flex; flex-direction: column; gap: 6px; }
.bank-card { border: 1px solid #e6e6ef; border-radius: 6px; padding: 6px 10px; background: #fff; max-width: 380px; transition: box-shadow 0.2s ease; display: flex; align-items: center; gap: 10px; }
.bank-card:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); }
.bank-card-header { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bank-card .bank-logo { max-width: 28px; max-height: 20px; width: auto; height: auto; object-fit: contain; }
.bank-card .bank-name { font-weight: 600; color: #333; font-size: 12px; white-space: nowrap; }
.bank-card .bank-iban { font-size: 13px; letter-spacing: 0.2px; color: #222; word-break: break-all; font-family: 'Courier New', monospace; }
.director-signature { font-size: 14px; text-align: right; flex-shrink: 0; }
.director-signature strong { color: #333; display: block; margin-bottom: 10px; }
.signature-image { display: block; margin-left: auto; margin-right: 0; max-height: 50px; width: auto; max-width: 200px; margin-top: 10px; }

/* Autocomplete */
.ui-autocomplete {
  max-height: 200px; overflow-y: auto; overflow-x: hidden; padding: 2px; border: 1px solid #ccc; background: #fff; box-shadow: 0 5px 10px rgba(0,0,0,0.1); font-size: 13px; z-index: 9999 !important; font-family: 'FiraGO', sans-serif;
}
.ui-menu-item { padding: 5px 8px; cursor: pointer; transition: background 0.15s ease; }
.ui-menu-item:hover, .ui-state-active { background-color: #f0f0f0; }

/* Payment section */
.invoice-payment-section { margin-top: 20px; padding: 15px; background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; }
.payment-type-selector { margin-bottom: 15px; }
.payment-type-selector label { display: block; margin-bottom: 5px; color: #333; }
.payment-type-select { width: 100%; max-width: 350px; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; font-family: 'FiraGO', sans-serif; }
.payment-details { margin-top: 15px; }
.payment-split-row { display: flex; gap: 15px; margin-bottom: 10px; }
.payment-split-item { flex: 1; }
.payment-split-item label { display: block; margin-bottom: 5px; font-weight: 500; color: #555; }
.payment-split-item input { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; font-family: 'FiraGO', sans-serif; }
.payment-split-total { padding: 10px; background: #fff; border: 1px solid #ddd; border-radius: 4px; display: flex; align-items: center; gap: 10px; }
.payment-split-total > span:first-child { font-weight: 600; }
.split-total-amount { font-size: 16px; font-weight: bold; color: #333; }
.split-validation { margin-left: auto; font-size: 13px; }

.payment-consignment-fields label { display: block; margin-bottom: 5px; font-weight: 500; color: #555; }
.payment-comment { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; font-family: 'FiraGO', sans-serif; resize: vertical; }

/* Partial Payment Styles */
.partial-payment-options input[type="checkbox"] {
  accent-color: #50529d;
}
#partial-payment-fields {
  display: none;
}
#payment-paid-amount, #payment-remaining-amount {
  font-family: 'FiraGO', sans-serif;
}
#payment-remaining-amount {
  cursor: not-allowed;
}

.invoice-payment-info { margin-top: 20px; padding: 15px; background: #f0f7ff; border-left: 4px solid #50529d; border-radius: 4px; }
.payment-info-row { display: flex; gap: 10px; margin-bottom: 10px; }
.payment-info-row strong { color: #333; min-width: 120px; }
.payment-split-display { display: flex; gap: 20px; margin-top: 10px; padding: 10px; background: #fff; border-radius: 4px; }
.payment-split-display .payment-split-item { display: flex; gap: 8px; align-items: center; }
.payment-comment-display { margin-top: 10px; }
.payment-comment-display p { margin: 5px 0 0 0; padding: 10px; background: #fff; border-radius: 4px; color: #555; line-height: 1.5; }

/* Print */
@media print {
  @page { size: A4 portrait; margin: 1.5cm; }
  body, html { width: 100%; margin: 0; padding: 0; font-size: 10pt; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  .btn-add-row, .btn-save-invoice, .btn-print-invoice, .btn-remove-row, .qty-btn,
  .invoice-actions, .invoice-final-actions, .no-print, .invoice-payment-section, .invoice-payment-info, .cig-status-switcher,
  .cig-fictive-stamp, .partial-payment-options /* Explicitly hide fictive stamp & partial controls */
  { display: none !important; }
  
  .buyer-details .is-empty { display: none !important; }
  #invoice-table .col-actions, #invoice-table .col-status { display: none !important; }

  .invoice-wrapper { width: 100%; max-width: 100%; border: none; box-shadow: none; padding: 0; margin: 0; }
  .invoice-top-bar, .invoice-header, .invoice-footer-bank, .invoice-summary { page-break-inside: avoid; }

  .color-bar { background-color: #50529d !important; height: 10px; margin: 15px 0; }
  .invoice-title, .invoice-title input { color: #50529d !important; font-size: 20px !important; text-transform: capitalize !important; text-align: right !important; }

  #invoice-table { font-size: 9pt; border: 1px solid rgba(80, 82, 157, 0.5) !important; }
  #invoice-table thead th {
    padding: 5px 4px; background-color: rgba(80, 82, 157, 0.1) !important;
    border: 1px solid rgba(80, 82, 157, 0.5) !important; color: #333 !important; text-transform: capitalize !important;
    vertical-align: middle !important;
  }
  #invoice-table tbody td { padding: 3px; border: 1px solid rgba(80, 82, 157, 0.5) !important; vertical-align: middle !important; }

  /* Smaller Font for Description (Specifications) in Print */
  #invoice-table td.col-desc {
      font-size: 9px !important; /* Force small size in print */
  }

  /* Adjusted widths without Code/Status/Actions columns for PRINT (Updated for new column order) */
  #invoice-table .col-qty { width: 5% !important; text-align: center !important; }
  #invoice-table .col-image { width: 15% !important; } /* Wider image col */
  #invoice-table .col-name { width: 20% !important; }
  #invoice-table .col-price { width: 8% !important; text-align: center !important; }
  #invoice-table .col-total { width: 10% !important; text-align: center !important; }

  .totals-table td { border: 1px solid rgba(80, 82, 157, 0.5) !important; }
  .totals-table td:first-child { background-color: rgba(80, 82, 157, 0.1) !important; }

  *:focus { outline: none !important; box-shadow: none !important; }
  #invoice-table input, #invoice-table textarea, #invoice-table select, .invoice-title input, .buyer-field-input {
    border: none !important; background: transparent !important; box-shadow: none !important; padding: 1px; font-size: 9pt; width: 100%; font-family: 'FiraGO', sans-serif !important; caret-color: transparent !important; outline: none !important;
  }

  .buyer-details .editable-field, .buyer-details .editable-value {
    display: inline-block !important; font-size: 10pt; padding: 1px; color: #333 !important; font-style: normal !important; font-weight: normal !important; border: none !important; background: transparent !important;
  }
  .buyer-details strong.editable-field { font-weight: bold !important; }

  .bank-cards-row { display: flex !important; flex-direction: column !important; gap: 4px !important; }
  .bank-card { border-color: rgba(80, 82, 157, 0.3) !important; padding: 4px 8px !important; display: flex !important; align-items: center !important; gap: 8px !important; }
  .bank-card .bank-name { font-size: 11px !important; }
  .bank-card .bank-iban { font-size: 12px !important; letter-spacing: 0.2px !important; color: #222 !important; word-break: break-all !important; font-family: Arial, sans-serif !important; font-weight: bold !important; }
  .signature-image { max-height: 40px !important; margin-top: 5px !important; }

  .status-badge { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .stock-warning { display: none !important; }
}

/* Responsive */
@media screen and (max-width: 768px) {
  .invoice-wrapper { padding: 15px; }
  .invoice-header { flex-direction: column; gap: 20px; }
  .company-details, .buyer-details { width: 100%; }
  #invoice-table { font-size: 10px; }
  #invoice-table thead th { padding: 5px 3px; font-size: 9px; }
  #invoice-table tbody td { padding: 4px 3px; }
  .invoice-footer-bank { flex-direction: column; }
  .bank-details { width: 100%; }
  .director-signature { text-align: left; }
  .signature-image { margin-left: 0; }
  .payment-split-row { flex-direction: column; gap: 10px; }
}

/* Util */
.cig-hidden { display: none !important; }
.cig-placeholder-img { opacity: 0.3; }


/* ეს კოდი დაამატეთ ფაილის ბოლოში */

/* ვიზუალი ეკრანზე: წითელი და ბოლდი, როცა არაფერია არჩეული */
.warranty-period option[value=""] {
    color: red;
    font-weight: bold;
}

/* ბეჭდვის ლოგიკა */
@media print {
    /* თუ არჩეულია ცარიელი მნიშვნელობა (გარანტიის არჩევა), ტექსტი გახდეს გამჭვირვალე */
    select.warranty-period:has(option[value=""]:checked) {
        color: transparent !important;
    }
    
    /* ძველი ბრაუზერებისთვის (Fallback) */
    select.warranty-period option[value=""] {
        display: none;
    }
}