/**
 * Invoices & Quotes Styles
 */

.invoice-items-section {
  margin: 20px 0;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.invoice-items-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 15px;
  align-items: end;
}

.invoice-items-grid > div {
  display: flex;
  flex-direction: column;
}

.invoice-items-grid label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  margin-bottom: 5px;
}

.invoice-items-grid input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.invoice-items-grid input:focus {
  outline: none;
  border-color: #00a149;
  box-shadow: 0 0 0 2px rgba(0, 161, 73, 0.1);
}

.invoice-items-grid input[readonly] {
  background: #e9ecef;
  cursor: not-allowed;
}

.btn-add-item {
  padding: 10px 20px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-add-item:hover {
  background: #218838;
}

.btn-remove-item {
  padding: 8px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.2s;
}

.btn-remove-item:hover {
  background: #c82333;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-draft {
  background: #e0e0e0;
  color: #666;
}

.status-sent {
  background: #fff3cd;
  color: #856404;
}

.status-viewed {
  background: #d1ecf1;
  color: #0c5460;
}

.status-accepted {
  background: #d4edda;
  color: #155724;
}

.status-rejected {
  background: #f8d7da;
  color: #721c24;
}

.status-paid {
  background: #d4edda;
  color: #155724;
}

.status-cancelled {
  background: #f8d7da;
  color: #721c24;
}

.status-archived {
  background: #e0e0e0;
  color: #666;
}

.btn-icon {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  margin: 0 2px;
}

.btn-icon:hover {
  background: #f8f9fa;
  border-color: #00a149;
}

.btn-icon.btn-delete {
  color: #dc3545;
  border-color: #dc3545;
}

.btn-icon.btn-delete:hover {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #00a149;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 20px;
  background: #00a149;
  color: white;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
}

.close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
}

.close-btn:hover {
  opacity: 0.8;
}

.modal-body {
  padding: 30px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

.data-table thead {
  background: #f8f9fa;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

.data-table th {
  font-weight: 600;
  color: #ebebeb;
  font-size: 13px;
  text-transform: uppercase;
}

.data-table tr:hover {
  background: #f8f9fa;
}

@media (max-width: 768px) {
  .invoice-items-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 95%;
  }

  .modal-body {
    padding: 20px;
  }
}

/* Toggle Switch Styles for Payment Methods - Specific to Invoice Modal */
/* High specificity to override other toggle styles */
#createInvoiceModal .payment-methods-toggles .toggle-switch,
#createInvoiceModal .toggle-switch,
.modal .payment-methods-toggles .toggle-switch {
  position: relative !important;
  display: inline-block !important;
  width: 48px !important;
  height: 24px !important;
  vertical-align: middle !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-switch input,
#createInvoiceModal .toggle-switch input,
.modal .payment-methods-toggles .toggle-switch input {
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-slider,
#createInvoiceModal .toggle-slider,
.modal .payment-methods-toggles .toggle-slider {
  position: absolute !important;
  cursor: pointer !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-color: #ccc !important;
  transition: 0.3s !important;
  border-radius: 24px !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-slider:before,
#createInvoiceModal .toggle-slider:before,
.modal .payment-methods-toggles .toggle-slider:before {
  position: absolute !important;
  content: "" !important;
  height: 18px !important;
  width: 18px !important;
  left: 3px !important;
  bottom: 3px !important;
  background-color: white !important;
  transition: 0.3s !important;
  border-radius: 50% !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-switch input:checked + .toggle-slider,
#createInvoiceModal .toggle-switch input:checked + .toggle-slider,
.modal .payment-methods-toggles .toggle-switch input:checked + .toggle-slider {
  background-color: #00a149 !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-switch input:checked + .toggle-slider:before,
#createInvoiceModal .toggle-switch input:checked + .toggle-slider:before,
.modal .payment-methods-toggles .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px) !important;
}

#createInvoiceModal .payment-methods-toggles .toggle-switch input:focus + .toggle-slider,
#createInvoiceModal .toggle-switch input:focus + .toggle-slider,
.modal .payment-methods-toggles .toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 1px #00a149 !important;
}

.payment-methods-toggles {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 20px !important;
}

.payment-methods-toggles > div {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

/* Tab Styles */
.tabs-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 10px;
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #00a149;
  border-bottom-color: #00a149;
}

.tab-btn.active {
  color: #00a149;
  border-bottom-color: #00a149;
}

.tab-count {
  font-size: 12px;
  color: #999;
}

.tab-btn.active .tab-count {
  color: #00a149;
}

/* Row States */
.row-rejected {
  background-color: #fff5f5 !important;
}

.row-disabled {
  opacity: 0.6;
  background-color: #f5f5f5 !important;
}

/* Invoice Tax Section */
.invoice-tax-section {
  position: relative;
}

.invoice-tax-section label::after {
  content: " (%)";
  font-size: 12px;
  color: #999;
}

/* Message Editor Styles */
.message-editor-toolbar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.editor-btn {
  padding: 6px 12px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-btn:hover {
  background: #f0f0f0;
  border-color: #00a149;
}

.editor-btn:active {
  background: #e0e0e0;
  transform: scale(0.95);
}

.editor-btn strong,
.editor-btn em,
.editor-btn s,
.editor-btn code {
  font-size: 14px;
  font-weight: bold;
}

#whatsappMessageEditor {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
}

#whatsappMessageEditor:focus {
  outline: none;
  border-color: #00a149;
  box-shadow: 0 0 0 2px rgba(0, 161, 73, 0.1);
}

#messagePreview {
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
}

#messagePreview strong {
  font-weight: 600;
  color: #1a1a1a;
}

#messagePreview em {
  font-style: italic;
  color: #333;
}

#messagePreview s {
  text-decoration: line-through;
  color: #666;
}

#messagePreview code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
}

/* Placeholder info box */
.message-editor-toolbar + textarea + div {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
