@font-face {
    font-family: 'IRANSansWeb';
    src: url('../fonts/IRANSansWeb.eot');
    src: url('../fonts/IRANSansWeb.eot?#iefix') format('embedded-opentype'),
         url('../fonts/IRANSansWeb.woff') format('woff'),
         url('../fonts/IRANSansWeb.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'IRANSansWeb', Tahoma, Arial, sans-serif;
}

body {
    font-family: 'IRANSansWeb';
    background-color: #f4f4f4;
    padding: 20px;
    direction: rtl;
}

.invoice-container {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    padding: 10px;
    border-radius: 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

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

.company-name {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
}

.invoice-number {
    border: 1px solid #000;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    margin-right: 10px;
}

.logo {
    width: 50px;
    height: 50px;
    background-color: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.id-section {
    display: flex;
    margin-bottom: 20px;
}

.id-box {
    border: 1px solid #000;
    padding: 10px;
    flex: 1;
    margin: 0 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 5px;
}

.phone-icon {
    width: 12px; /* Half the original 24px */
    height: 12px; /* Half the original 24px */
    margin-right: 10px;
    margin-top: 10px;
}

.customer-date-row {
    display: flex;
    margin-bottom: 20px;
}

.label {
    width: 80px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90px;
}

.value-box {
    border: 1px solid #000;
    padding: 10px;
    flex: 1;
    margin: 0 5px;
    border-radius: 5px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 5px;
    margin-bottom: 20px;
}

tr {
    border-radius: 5px;
    overflow: hidden;
}

th, td {
    border: 1px solid #000;
    padding: 8px;
    text-align: center;
    margin-bottom: 5px;
    border-radius: 5px;
}

th {
    background-color: #f9f9f9;
}

.summary-row {
    display: flex;
    margin-bottom: 10px;
}

.summary-label {
    width: 100px;
    text-align: left;
    font-weight: bold;
}

.summary-value {
    flex: 1;
}

.payment-box, .total-box, .discount-box, .balance-box, .notes-box, .signature-box {
    border: 1px solid #000;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.payment-row {
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
}

.notes-box {
    margin-bottom: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    /* Remove flex: 1 and min-width to allow #notes to be as wide as possible */
}

.bold {
    font-weight: bold;
}

.signature-box {
    text-align: right;
flex-direction: row;
}

    input, textarea {
      border: none;
      background: transparent;
      width: 100%;
      font-family: inherit;
      font-size: inherit;
      text-align: center;
    }

    input:focus, textarea:focus {
      outline: none;
    }

    .invoice-container {
      max-width: 1000px;
      padding: 20px;
      background-color: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .header {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      align-items: center;
      margin-bottom: 20px;
      gap: 10px;
    }

    .invoice-number-box {
      display: flex;
      flex-direction: row;
      align-items: center;
    }

    .logo {
      background-color: #f0f0f0;
      border-radius: 50%;
      width: 50px;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: auto;
    }

    .value-box input, .notes-box textarea, .signature-box input {
      width: 100%;
    }

    .value-box, .notes-box, .signature-box {
      flex: 1;
      min-width: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .label, .bold {
      width: 80px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 600;
      color: #374151;
    }

    .total-box {
      margin-top: 20px;
      font-weight: bold;
      font-size: 1.1em;
      color: #1f2937;
      text-align: left;
      padding: 10px;
      background-color: #f3f4f6;
      border-radius: 5px;
    }

    .words-box {
      margin-top: 10px;
      background-color: #f9f9f9;
      padding: 12px;
      border-radius: 5px;
      color: #374151;
    }

    .notes-box {
      margin-top: 15px;
      background-color: #f9fafb;
      padding: 15px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      display: flex;
      gap: 10px;
    }

    .notes-box textarea {
      height: 80px;
      resize: none;
      text-align: right;
      background-color: #fff;
      border: 1px solid #d1d5db;
      border-radius: 5px;
      padding: 8px;
      color: #1f2937;
      font-size: 0.95em;
    }

    .signature-box {
      margin-top: 15px;
      background-color: #f9fafb;
      padding: 15px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      display: flex;
      gap: 10px;
      align-items: flex-start;
      flex-direction: column;
    }

    .signature-box .value-box {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .signature-box input {
      background-color: #fff;
      border: 1px solid #d1d5db;
      border-radius: 5px;
      padding: 8px;
      color: #1f2937;
      font-size: 0.95em;
      text-align: right;
    }

    .buttons {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      margin: 20px 0;
      max-width: 1000px;
      margin-left: auto;
      margin-right: auto;
    }

    .export-buttons {
      display: flex;
      gap: 10px;
    }

    button {
      padding: 8px 16px;
      background-color: #2563eb;
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 0.95em;
      transition: background-color 0.2s;
    }

    button:hover {
      background-color: #1d4ed8;
    }

    table {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0 5px;
    }

    th, td {
      padding: 8px 12px;
    }

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }

    .invoice-container {
        max-width: 100%;
        padding: 15px;
        margin: 0;
        box-shadow: none;
        border: none;
    }

    .header {
        grid-template-columns: 1fr;
        gap: 15px;
        text-align: center;
    }

    .invoice-number-box {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .company-name {
        font-size: 20px;
        order: -1;
    }

    .logo {
        width: 40px;
        height: 40px;
        margin: 0 auto;
        display: none !important;
    }

    .id-section, .customer-date-row {
        flex-direction: row !important;
        gap: 5px;
    }
    .label {
        width: 36px;
        font-size: 9px;
        max-width: 40px;
        margin-bottom: 0;
        padding: 1px 0;
    }
    .value-box {
        padding: 3px;
        font-size: 10px;
        margin: 0 2px;
    }
    .value-box input {
      font-size: 9px;
      height: 18px;
      padding: 1px 3px;
      min-height: unset;
      max-width: 40px;
      width: 40px;
    }

    /* Table responsive design */
    table {
        font-size: 12px;
        border-spacing: 2px;
    }

    th, td {
        padding: 6px 4px;
        font-size: 11px;
        word-wrap: break-word;
    }

    th:nth-child(2), td:nth-child(2) {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        word-break: break-word;
        white-space: normal;
        overflow-wrap: break-word;
    }

    th:nth-child(3), td:nth-child(3),
    th:nth-child(4), td:nth-child(4) {
        min-width: 50px;
    }

    th:nth-child(5), td:nth-child(5),
    th:nth-child(6), td:nth-child(6) {
        min-width: 70px;
    }

    /* Input fields in table */
    td input {
        width: 100%;
        min-width: 0;
        font-size: 11px;
        padding: 2px;
    }

    td input[type="number"] {
        -webkit-appearance: none;
        -moz-appearance: textfield;
        appearance: none;
    }

    /* Buttons responsive */
    .buttons {
        flex-direction: column;
        gap: 15px;
        margin: 15px 0;
    }

    .export-buttons {
        justify-content: center;
    }

    button {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px;
        touch-action: manipulation;
    }

    /* Text areas and inputs */
    .notes-box textarea {
        height: 60px;
        font-size: 13px;
    }

    .signature-box {
        flex-direction: column;
        align-items: flex-start;
    }

    .signature-box .value-box {
        width: 100%;
    }

    .signature-box input {
        font-size: 13px;
        padding: 10px;
    }

    .signature-box .value-box input {
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box;
      font-size: 14px;
      padding: 8px;
    }

    /* Total and words boxes */
    .total-box, .words-box {
        font-size: 14px;
        padding: 12px;
        text-align: center;
    }

    /* Improve touch targets */
    input, textarea, button {
        min-height: 44px;
    }

    input:focus, textarea:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
    }

    #phone,
    #ecoCode,
    #customer,
    #date {
      font-size: 9px;
      height: 18px;
      padding: 1px 3px;
      min-height: unset;
      max-width: 120px !important;
      width: 120px !important;
      flex: unset !important;
      display: inline-block;
      margin: 0 auto;
    }
    .id-section .value-box,
    .customer-date-row .value-box {
      flex: unset !important;
      width: auto !important;
      min-width: unset !important;
      max-width: unset !important;
      padding: 3px;
      font-size: 10px;
      margin: 0 2px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .invoice-number {
      border: none !important;
    }
    #invoiceNumber {
      width: 70px !important;
      max-width: 70px !important;
      font-size: 11px !important;
      height: 15px !important;
      padding: 1px 4px !important;
      border: 1px solid #bbb !important;
      background: transparent !important;
      box-shadow: none !important;
      text-align: center;
      border-radius: 4px;
    }
    .id-section,
    .customer-date-row {
      justify-content: center !important;
      text-align: center !important;
    }
    .notes-box {
      flex-direction: column !important;
      align-items: flex-start !important;
    }
    .signature-box {
      flex-direction: column !important;
      align-items: flex-start !important;
    }
}

/* Extra small screens */
@media screen and (max-width: 480px) {
    body {
        padding: 5px;
        font-size: 13px;
    }

    .invoice-container {
        padding: 10px;
    }

    .company-name {
        font-size: 18px;
    }

    table {
        font-size: 10px;
    }

    th, td {
        padding: 4px 2px;
        font-size: 10px;
    }

    td input {
        font-size: 10px;
        padding: 1px;
    }

    button {
        padding: 10px 15px;
        font-size: 13px;
    }

    .total-box, .words-box {
        font-size: 13px;
        padding: 10px;
    }

    .notes-box textarea {
        font-size: 12px;
    }

    .signature-box input {
        font-size: 12px;
        padding: 8px;
    }
}

.notes-box {
  margin-bottom: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 15px;
  gap: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}
.notes-box .value-box {
  width: 100%;
  flex: unset;
  min-width: 0;
  display: block;
  margin: 0;
  padding: 0;
}
#notes {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  display: block;
  overflow: hidden !important;
  resize: none !important;
  margin: 0;
  padding: 8px;
  font-size: 14px;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
}
@media screen and (max-width: 768px) {
  #notes {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0;
    margin-right: 0;
  }
}

td:nth-child(2) textarea {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  resize: vertical !important;
  overflow-x: hidden !important;
  display: block !important;
}

@media screen and (max-width: 768px) {
  td:nth-child(2) textarea {
    resize: none !important;
  }
}
/* Medium screens - intermediate text size */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  td:nth-child(2) textarea {
    font-size: 14px !important;
    line-height: 1.5;
    padding: 4px 6px;
  }
}

@media screen and (max-width: 768px) {
  td:nth-child(2) textarea {
    width: auto !important;
    min-width: 60px !important;
    max-width: 98vw !important;
    font-size: 15px !important;
    padding: 6px 4px;
    box-sizing: border-box;
    white-space: pre-wrap !important;
    overflow-wrap: break-word !important;
    resize: none !important;
    min-height: 22px !important;
    height: auto !important;
    max-height: 80px !important;
    line-height: 1.6 !important;
    overflow: hidden !important;
    display: block !important;
    text-align: center !important;
  }
}

.signature-box input {
  width: 100%;
  box-sizing: border-box;
  display: block;
  padding: 8px;
  font-size: 14px;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  margin: 0;
}

@media screen and (min-width: 769px) {
  .signature-box .value-box {
    width: 100%;
    flex: unset;
    min-width: 0;
    display: block;
    margin: 0;
    padding: 0;
  }
  .signature-box input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  
  /* Make the عنوان column wider on large screens */
  th:nth-child(2), td:nth-child(2) {
    width: 35%;
    min-width: 200px;
  }
  
  /* Larger text for عنوان column on large screens */
  th:nth-child(2), td:nth-child(2) {
    font-size: 16px;
  }
  
  /* Responsive text sizing for عنوان textarea */
  td:nth-child(2) textarea {
    font-size: 16px !important;
    line-height: 1.4;
    padding: 6px 8px;
  }
  
  /* Adjust other columns to accommodate the wider عنوان column */
  th:nth-child(1), td:nth-child(1) {
    width: 8%;
  }
  
  th:nth-child(3), td:nth-child(3) {
    width: 12%;
  }
  
  th:nth-child(4), td:nth-child(4) {
    width: 15%;
  }
  
  th:nth-child(5), td:nth-child(5) {
    width: 15%;
  }
  
  th:nth-child(6), td:nth-child(6) {
    width: 15%;
  }
}

/* Remove .table-responsive rules */
.table-responsive {
  width: 100%;
  overflow-x: unset;
}

@media screen and (max-width: 768px) {
  /* Remove .table-responsive scroll and force table to fit */
  .table-responsive {
    width: 100%;
    margin: 0;
    overflow-x: unset;
  }
  table {
    table-layout: fixed;
    width: 100%;
    min-width: unset;
    font-size: 10px;
  }
  th, td {
    padding: 2px 1px;
    font-size: 10px;
    word-break: break-word;
    white-space: normal;
    min-width: 0;
    max-width: 100vw;
  }
  th:nth-child(2), td:nth-child(2) {
    font-size: 12px !important;
    min-width: 60px !important;
    max-width: 30vw !important;
  }
  td input, td textarea {
    font-size: 10px !important;
    padding: 2px 2px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: block !important;
  }
}

/* Generic: all table textareas always fit their cell */
td textarea {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  resize: vertical !important;
  overflow-x: hidden !important;
  display: block !important;
  font-size: 1.1em;
  padding: 6px 4px;
  line-height: 1.6;
  text-align: center;
  transition: font-size 0.2s, text-align 0.2s;
  min-height: 22px;
  height: auto;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 5px;
}

@media screen and (max-width: 768px) {
  td textarea {
    font-size: 13px !important;
    padding: 4px 2px !important;
    resize: none !important;
    min-height: 20px !important;
  }
}