/**
 * Reports page styles
 * Responsive table design for inventory reports
 */

/* ──────────────────────────────────────────
   Movement Table - Main Styling
   ────────────────────────────────────────── */

.movement-table {
    font-size: 0.9rem;
    border-collapse: collapse;
}

.movement-table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
}

.movement-table thead th {
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding: 12px 8px !important;
    white-space: nowrap;
    vertical-align: middle;
}

.movement-table tbody td {
    padding: 10px 8px !important;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

.movement-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ──────────────────────────────────────────
   Right-Aligned Numeric Columns
   ────────────────────────────────────────── */

.movement-table .text-right {
    text-align: right;
    padding-right: 12px !important;
}

/* Monospace font for numbers to ensures proper alignment */
.movement-table td.text-right {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

/* ──────────────────────────────────────────
   Price & Currency Formatting
   ────────────────────────────────────────── */

.price-cell {
    text-align: right;
    font-weight: 500;
    color: #212529;
}

/* ──────────────────────────────────────────
   Type & Discount Badge Styling
   ────────────────────────────────────────── */

.movement-table .badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
}

.movement-table i[class*="fa-arrow"] {
    margin-right: 4px;
}

/* ──────────────────────────────────────────
   Empty Cell Indicator (— em dash)
   ────────────────────────────────────────── */

.movement-table td:contains("—") {
    color: #79b8b9;
    text-align: center;
    font-style: italic;
}

/* ──────────────────────────────────────────
   Responsive Design
   ────────────────────────────────────────── */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
    .movement-table {
        font-size: 0.85rem;
    }

    .movement-table thead th {
        padding: 10px 6px !important;
    }

    .movement-table tbody td {
        padding: 8px 6px !important;
    }

    /* Hide User column on tablet */
    .movement-table th:last-child,
    .movement-table td:last-child {
        display: none;
    }
}

/* Mobile: Less than 768px */
@media (max-width: 768px) {
    .movement-table {
        font-size: 0.8rem;
    }

    .movement-table thead th {
        padding: 8px 4px !important;
    }

    .movement-table tbody td {
        padding: 6px 4px !important;
    }

    /* Show only essential columns on mobile */
    .movement-table th:nth-child(n+4):last-of-type,
    .movement-table th:nth-child(n+5),
    .movement-table th:last-child {
        display: none;
    }

    .movement-table td:nth-child(n+4):last-of-type,
    .movement-table td:nth-child(n+5),
    .movement-table td:last-child {
        display: none;
    }

    /* Adjust Date column on mobile */
    .movement-table th:nth-child(1),
    .movement-table td:nth-child(1) {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Adjust Product column on mobile */
    .movement-table th:nth-child(2),
    .movement-table td:nth-child(2) {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Make Type column center aligned on mobile */
    .movement-table th:nth-child(3),
    .movement-table td:nth-child(3) {
        text-align: center;
    }

    /* Make Qty column right aligned on mobile */
    .movement-table th:nth-child(4),
    .movement-table td:nth-child(4) {
        text-align: right;
        padding-right: 8px !important;
    }
}

/* Extra small mobile: Less than 480px */
@media (max-width: 480px) {
    .movement-table {
        font-size: 0.75rem;
    }

    .movement-table thead th {
        padding: 6px 3px !important;
    }

    .movement-table tbody td {
        padding: 4px 3px !important;
    }

    .movement-table th:nth-child(1),
    .movement-table td:nth-child(1) {
        max-width: 80px;
        font-size: 0.7rem;
    }

    .movement-table th:nth-child(2),
    .movement-table td:nth-child(2) {
        max-width: 80px;
        font-size: 0.7rem;
    }
}

/* ──────────────────────────────────────────
   Report Card Styling
   ────────────────────────────────────────── */

.report-card {
    position: sticky;
    top: 20px;
    z-index: 10;
}

.row.mb-4:has(.report-card) {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ──────────────────────────────────────────
   Grand Total Row Styling
   ────────────────────────────────────────── */

.table-grand-total {
    background-color: #f0f0f0;
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
    font-weight: 600;
    color: #1a1a1a;
}

.table-grand-total td {
    padding: 12px 8px !important;
    vertical-align: middle;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

.table-grand-total td:first-child {
    border-left: none;
}

.table-grand-total td:last-child {
    border-right: none;
}

/* ──────────────────────────────────────────
   Form Styling
   ────────────────────────────────────────── */

.form-label {
    font-size: 0.95rem;
    color: #2c3e50;
    display: block;
    margin-bottom: 8px;
}

.form-control-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
}

.form-control-sm:focus {
    border-color: #17a2b8;
    box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.25);
}

/* ──────────────────────────────────────────
   Period Button Styling
   ────────────────────────────────────────── */

.period-btn {
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    white-space: nowrap;
}

.period-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.period-btn.btn-primary {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

.period-btn.btn-outline-primary {
    color: #17a2b8;
    border-color: #17a2b8;
    background-color: transparent;
}

.period-btn.btn-outline-primary:hover {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* ──────────────────────────────────────────
   Responsive Design for Form/Filter Controls
   ────────────────────────────────────────── */

@media (max-width: 1200px) {
    .col-lg-2, .col-lg-3, .col-lg-4 {
        margin-bottom: 12px;
    }
}

@media (max-width: 768px) {
    .row {
        flex-direction: column;
    }

    .col-lg-2, .col-lg-3, .col-lg-4 {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px;
    }

    .period-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    .d-flex {
        flex-direction: column;
    }

    .d-flex > div {
        width: 100% !important;
        margin-bottom: 8px;
    }
}

/* ──────────────────────────────────────────
   Desktop Table with horizontal scroll fallback
   ────────────────────────────────────────── */

@media (max-width: 1200px) {
    .card-body.table-responsive {
        overflow-x: auto;
    }

    .movement-table {
        min-width: 900px;
    }
}

/* ──────────────────────────────────────────
   Print Styles
   ────────────────────────────────────────── */

@media print {
    .movement-table {
        font-size: 9pt;
        page-break-inside: avoid;
    }

    .movement-table thead {
        display: table-header-group;
        page-break-inside: avoid;
    }

    .movement-table tbody tr {
        page-break-inside: avoid;
    }

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

    .movement-table .price-cell {
        border-bottom: 0.5pt solid #000;
    }
}

/* ──────────────────────────────────────────
   Accessibility & Hover Effects
   ────────────────────────────────────────── */

.movement-table tbody tr {
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.movement-table tbody tr:focus-within {
    outline: 2px solid #79b8b9;
    outline-offset: -2px;
    background-color: #79b8b9;
}

/* ──────────────────────────────────────────
   Report Summary Cards - Full Width Layout
   ────────────────────────────────────────── */

.report-summary-cards {
  display: flex !important;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  margin: 0 0 1rem 0 !important;
  padding: 0 !important;
}

.report-summary-cards .col-md-2 {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 6px !important;
  margin: 0 !important;
  max-width: none !important;
  flex-basis: 0 !important;
}

.report-summary-cards .small-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 15px !important;
  text-align: center;
  height: 100%;
  width: 100%;
  position: relative;
}

.report-summary-cards .small-box .inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  z-index: 2;
  position: relative;
}

.report-summary-cards .small-box .inner h3 {
  margin: 8px 0;
  font-size: 1.8rem;
  font-weight: bold;
}

.report-summary-cards .small-box .inner p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.report-summary-cards .small-box .icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
  z-index: 1;
}

.report-summary-cards .small-box .icon i {
  font-size: 2.5rem;
}

.movement-table th {
    user-select: none;
}

/* Tooltip for discount type abbrev (optional) */
.movement-table .discount-abbrev {
    cursor: help;
    border-bottom: 1px dotted #79b8b9;
}

/* ──────────────────────────────────────────
   Summary Cards Styling
   ────────────────────────────────────────── */

.report-card {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 120px !important;
    padding: 20px !important;
    cursor: default;
}

.report-card:hover {
    transform: none !important;
    transition: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.report-card:hover .inner h3,
.report-card:hover .inner p,
.report-card:hover .icon i {
    opacity: inherit !important;
    color: inherit !important;
}

.report-card .inner {
    flex: 0 1 auto;
    z-index: 2;
    min-width: 0;
    margin-right: 20px;
}

.report-card .inner h3 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    word-break: break-word;
}

.report-card .inner p {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.report-card .icon {
    flex-shrink: 0;
    font-size: 4rem;
    opacity: 0.15;
    z-index: 1;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
}

.report-card .icon i {
    display: inline-block;
}
/* ──────────────────────────────────────────
   Stock In/Out Indicators
   ────────────────────────────────────────── */

.badge-success {
    background-color: #28a745 !important;
    color: white;
    font-weight: 500;
}

.badge-success:hover {
    background-color: #218838 !important;
}

.badge-danger {
    background-color: #dc3545 !important;
    color: white;
    font-weight: 500;
}

.badge-danger:hover {
    background-color: #c82333 !important;
}

/* Stock In Indicator - Green/Down arrow */
.stock-in-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid #c3e6cb;
}

.stock-in-indicator i {
    font-size: 14px;
}

/* Stock Out Indicator - Red/Up arrow */
.stock-out-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid #f5c6cb;
}

.stock-out-indicator i {
    font-size: 14px;
}

/* Quantity text styling for stock movements */
.stock-in-qty {
    color: #28a745;
    font-weight: 600;
}

.stock-out-qty {
    color: #dc3545;
    font-weight: 600;
}/* ──────────────────────────────────────────
   Improved Inventory Movement Report Styles
   ────────────────────────────────────────── */

/* Main inventory movement table */
.inventory-movement-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  table-layout: fixed;
}

.inventory-movement-table thead {
  background-color: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.inventory-movement-table thead th {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
  vertical-align: middle;
  background-color: #e8f0f1;
  color: #2c3e50;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-movement-table tbody tr {
  border-bottom: 1px solid #e9ecef;
  transition: background-color 0.15s ease;
  height: 40px;
}

.inventory-movement-table tbody tr:hover {
  background-color: #f8f9fa;
}

.inventory-movement-table tbody tr.deleted-row {
  background-color: #fff5f5;
}

.inventory-movement-table tbody td {
  padding: 8px;
  vertical-align: middle;
  font-size: 0.9rem;
  overflow: hidden;
  border-bottom: 1px solid #e9ecef;
}

/* Product name cell with truncation */
.inventory-movement-table .product-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-movement-table .product-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: #2c3e50;
}

/* Right-aligned numeric columns - handled by inline styles */

/* Date and time formatting - handled by inline styles */

.inventory-movement-table .text-muted {
  color: #6c757d;
  font-size: 0.85rem;
}

/* Badge styling - removed (using plain text now) */

/* Text colors for quantity changes - removed (using plain text) */

/* Reference code styling */
.inventory-movement-table code {
  background-color: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  color: #666;
}

/* Summary section styling */
.summary-box {
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  border-left: 4px solid #79b8b9;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.95rem;
}

.summary-row:not(:last-child) {
  border-bottom: 1px solid #e9ecef;
}

.summary-label {
  font-weight: 600;
  color: #2c3e50;
}

.summary-value {
  text-align: right;
  font-weight: 600;
}

.card-footer.bg-light {
  background-color: #f8f9fa !important;
}

.card-footer h5 {
  color: #2c3e50;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
}

/* Full width container */
.card-body.table-responsive {
  width: 100%;
  overflow-x: auto;
  padding: 0 !important;
}

/* Responsive design for inventory movement table */
@media (max-width: 1200px) {
  .inventory-movement-table thead th {
    font-size: 0.85rem;
    padding: 10px 6px !important;
  }

  .inventory-movement-table tbody td {
    font-size: 0.85rem;
    padding: 8px 6px !important;
  }

  .inventory-movement-table .product-cell {
    max-width: 180px;
  }
}

@media (max-width: 992px) {
  .inventory-movement-table thead th:nth-child(n+7) {
    display: none;
  }

  .inventory-movement-table tbody td:nth-child(n+7) {
    display: none;
  }

  .inventory-movement-table {
    font-size: 0.8rem;
  }

  .summary-box {
    margin-bottom: 15px;
  }

  .card-footer .row {
    flex-direction: column;
  }

  .card-footer .col-md-6 {
    width: 100% !important;
    margin-bottom: 15px;
  }
}

@media (max-width: 768px) {
  .inventory-movement-table thead th {
    font-size: 0.8rem;
    padding: 8px 4px !important;
  }

  .inventory-movement-table tbody td {
    font-size: 0.75rem;
    padding: 6px 4px !important;
  }

  .inventory-movement-table thead th:nth-child(n+5) {
    display: none;
  }

  .inventory-movement-table tbody td:nth-child(n+5) {
    display: none;
  }

  .inventory-movement-table .product-cell {
    max-width: 120px;
  }

  .inventory-movement-table .text-right {
    font-size: 0.75rem;
  }

  .summary-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-value {
    text-align: left;
    margin-top: 4px;
  }
}

@media (max-width: 480px) {
  .inventory-movement-table {
    font-size: 0.7rem;
  }

  .inventory-movement-table thead th {
    font-size: 0.7rem;
    padding: 6px 2px !important;
  }

  .inventory-movement-table tbody td {
    font-size: 0.65rem;
    padding: 4px 2px !important;
  }

  .inventory-movement-table thead th:nth-child(n+3) {
    display: none;
  }

  .inventory-movement-table tbody td:nth-child(n+3) {
    display: none;
  }

  .summary-label,
  .summary-value {
    font-size: 0.85rem;
  }
}

/* Print styles - IMPORTANT for full-width PDF export */
@media print {
  .inventory-movement-table {
    width: 100%;
    font-size: 9pt;
    page-break-inside: avoid;
    table-layout: fixed;
  }

  .inventory-movement-table thead {
    display: table-header-group;
    page-break-inside: avoid;
  }

  .inventory-movement-table tbody {
    width: 100%;
  }

  .inventory-movement-table tbody tr {
    page-break-inside: avoid;
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .inventory-movement-table thead th,
  .inventory-movement-table tbody td {
    border: 1px solid #999;
    padding: 6px 4px !important;
  }

  .inventory-movement-table thead th {
    background-color: #e8f0f1;
    color: #2c3e50;
    font-weight: bold;
  }

  .inventory-movement-table .text-right {
    text-align: right;
  }

  .card-body.table-responsive {
    overflow: visible !important;
  }

  .card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .card-footer {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .summary-box {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Hide scrollbar container styling in print */
  .card-body {
    overflow: visible !important;
  }
}
