/* paymentplans.component.scss */
// Main container styling
.payment-plans-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f8f9fa;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 20px;
}

// Header section
.header-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e9ecef;
  
  .header-content {
    .main-title {
      font-size: 24px;
      font-weight: 600;
      color: #2c3e50;
      margin: 0 0 4px 0;
    }
    
    .subtitle {
      font-size: 14px;
      color: #6c757d;
      margin: 0;
    }
  }
  
  .create-btn {
    display: flex;
    align-items: center;
    background-color: #4361ee;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    
    &:hover {
      background-color: #3651de;
    }
    
    .plus-icon {
      margin-right: 6px;
      font-size: 18px;
      font-weight: bold;
    }
  }
}

// Filters section
.filters-section {
  margin-bottom: 24px;
  
  .filters-container {
    display: flex;
    gap: 16px;
    
    .search-container {
      flex: 1;
      
      .search-input-wrapper {
        position: relative;
        
        .search-icon {
          position: absolute;
          left: 12px;
          top: 50%;
          transform: translateY(-50%);
          width: 18px;
          height: 18px;
          color: #6c757d;
        }
        
        .search-input {
          width: 100%;
          padding: 10px 12px 10px 40px;
          border: 1px solid #ced4da;
          border-radius: 6px;
          font-size: 14px;
          
          &:focus {
            outline: none;
            border-color: #4361ee;
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
          }
        }
      }
    }
    
    .filter-container {
      position: relative;
      min-width: 180px;
      
      .filter-select {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #ced4da;
        border-radius: 6px;
        font-size: 14px;
        background-color: white;
        appearance: none;
        
        &:focus {
          outline: none;
          border-color: #4361ee;
          box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
        }
      }
      
      .dropdown-icon {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 18px;
        height: 18px;
        color: #6c757d;
        pointer-events: none;
      }
    }
  }
}

// Table section
.table-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  
  .table-container {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    
    // Table header
    .table-header {
      background-color: #f8f9fa;
      border-bottom: 1px solid #e9ecef;
      
      .header-grid {
        display: grid;
        grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr;
        padding: 16px;
        
        .header-col {
          font-size: 12px;
          font-weight: 600;
          color: #6c757d;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }
    }
    
    // Table body
    .table-body {
      .table-row {
        border-bottom: 1px solid #f1f3f5;
        transition: background-color 0.2s;
        
        &:last-child {
          border-bottom: none;
        }
        
        &.row-hover {
          background-color: #f8f9fa;
        }
        
        .row-grid {
          display: grid;
          grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr;
          padding: 16px;
          
          .row-col {
            display: flex;
            flex-direction: column;
            justify-content: center;
            
            // Plan details column
            &.col-plan-details {
              .plan-id {
                font-weight: 600;
                color: #2c3e50;
                margin-bottom: 4px;
              }
              
              .plan-due-date {
                font-size: 13px;
                color: #6c757d;
              }
            }
            
            // Type & currency column
            &.col-type-currency {
              .plan-type {
                font-weight: 500;
                color: #2c3e50;
                margin-bottom: 4px;
              }
              
              .plan-currency {
                font-size: 13px;
                color: #6c757d;
              }
            }
            
            // Amount column
            &.col-amount {
              .plan-amount {
                font-weight: 600;
                color: #2c3e50;
                margin-bottom: 4px;
              }
              
              .plan-available {
                font-size: 13px;
                color: #6c757d;
              }
            }
            
            // Status column
            &.col-status {
              .status-badge {
                display: inline-flex;
                align-items: center;
                padding: 4px 8px;
                border-radius: 12px;
                font-size: 12px;
                font-weight: 500;
                
                .status-icon {
                  margin-right: 4px;
                }
                
                &.status-approved {
                  background-color: rgba(40, 167, 69, 0.1);
                  color: #28a745;
                }
                
                &.status-planned {
                  background-color: rgba(255, 193, 7, 0.1);
                  color: #ffc107;
                }
                
                &.status-draft {
                  background-color: rgba(108, 117, 125, 0.1);
                  color: #6c757d;
                }
              }
            }
            
            // Created by column
            &.col-created-by {
              .created-by-name {
                color: #2c3e50;
              }
            }
            
            // Actions column
            &.col-actions {
              .actions-container {
                display: flex;
                gap: 8px;
                
                .action-btn {
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  width: 32px;
                  height: 32px;
                  border-radius: 6px;
                  background-color: transparent;
                  border: 1px solid #e9ecef;
                  color: #6c757d;
                  cursor: pointer;
                  transition: all 0.2s;
                  
                  &:hover {
                    background-color: #f8f9fa;
                    border-color: #ced4da;
                    color: #495057;
                  }
                  
                  svg {
                    width: 16px;
                    height: 16px;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  
  // Export button
  .export-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    
    .export-btn {
      display: flex;
      align-items: center;
      background-color: white;
      color: #495057;
      border: 1px solid #ced4da;
      border-radius: 6px;
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s;
      
      &:hover {
        background-color: #f8f9fa;
        border-color: #adb5bd;
      }
      
      .export-icon {
        margin-right: 6px;
        width: 16px;
        height: 16px;
      }
    }
  }
}

// Form view styling
.form-header-section {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  
  .back-btn {
    display: flex;
    align-items: center;
    background-color: transparent;
    color: #4361ee;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-right: 16px;
    transition: background-color 0.2s;
    
    &:hover {
      background-color: rgba(67, 97, 238, 0.1);
    }
    
    .back-icon {
      margin-right: 6px;
      width: 16px;
      height: 16px;
    }
  }
  
  h2 {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
  }
}

.FormOverView {
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    &.scrollbar {
        /* Custom scrollbar styling */
        &::-webkit-scrollbar {
            width: 8px;
        }
        &::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 4px;
        }
        &::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 4px;
            &:hover {
                background: #a8a8a8;
            }
        }
    }
}
.form-header {
    margin-bottom: 30px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 15px;
    h2 {
        margin: 0;
        color: #333;
        font-size: 24px;
        font-weight: 600;
    }
}
.form-content {
    .form-row {
        display: flex;
        gap: 20px;
        margin-bottom: 20px;
        @media (max-width: 768px) {
            flex-direction: column;
            gap: 15px;
        }
        .form-group {
            flex: 1;
            min-width: 0;
            &.full-width {
                flex: 100%;
            }
            label {
                display: block;
                margin-bottom: 5px;
                font-weight: 500;
                color: #555;
                font-size: 14px;
                &::after {
                    content: " *";
                    color: #dc3545;
                    display: none;
                }
            }
            .form-control {
                width: 100%;
                padding: 10px 12px;
                border: 1px solid #ddd;
                border-radius: 4px;
                font-size: 14px;
                transition: border-color 0.3s, box-shadow 0.3s;
                &:focus {
                    outline: none;
                    border-color: #007bff;
                    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
                }
                &:invalid {
                    border-color: #dc3545;
                }
                &::placeholder {
                    color: #999;
                }
            }
            textarea.form-control {
                resize: vertical;
                min-height: 80px;
            }
            select.form-control {
                cursor: pointer;
                background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
                background-position: right 8px center;
                background-repeat: no-repeat;
                background-size: 16px;
                padding-right: 32px;
            }
        }
    }
}
// Form validation styles
.form-group {
    .form-control {
        &.ng-invalid.ng-touched {
            border-color: #dc3545;
            &:focus {
                border-color: #dc3545;
                box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
            }
        }
        &.ng-valid.ng-touched {
            border-color: #28a745;
        }
    }
}
// Required field indicator
label[for="planName"]::after,
label[for="planCode"]::after,
label[for="duration"]::after {
    display: inline;
}
// Loading state
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #e9ecef;
        border-top: 4px solid #007bff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 20px;
    }
    p {
        color: #666;
        font-size: 16px;
        margin: 0;
    }
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
// Responsive design
@media (max-width: 576px) {
    .FormOverView {
        padding: 15px;
    }
    .form-header {
        h2 {
            font-size: 20px;
        }
    }
    .form-content .form-row {
        margin-bottom: 15px;
    }
}
// Print styles
@media print {
    .FormOverView {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    .form-control {
        border: none !important;
        border-bottom: 1px solid #000 !important;
        border-radius: 0 !important;
        background: transparent !important;
        padding: 5px 0 !important;
    }
}


@media (min-width: 768px) and (max-width: 991px) {

  .payment-plans-container {
    height: auto;
    max-height: calc(100vh - 160px);
    min-width: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-section {
    flex: none;
    min-width: 0;
  }

  .filters-section .filters-container {
    .filter-container {
      min-width: 140px;
    }
  }

  .table-section .table-container {
    flex: none;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;

    &::-webkit-scrollbar {
      height: 8px;
    }
    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 4px;
    }
    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 4px;
      &:hover {
        background: #a8a8a8;
      }
    }

    .table-header .header-grid,
    .table-body .table-row .row-grid {
      grid-template-columns:
        minmax(200px, 2fr)
        minmax(150px, 1.5fr)
        minmax(120px, 1fr)
        minmax(120px, 1fr)
        minmax(130px, 1fr)
        minmax(110px, 1fr) !important;
      min-width: 830px;
    }

    .header-col.col-actions,
    .row-col.col-actions {
      position: sticky;
      right: 0;
      z-index: 2;
      box-shadow: -2px 0 6px rgba(0, 0, 0, 0.06);
    }

    .header-col.col-actions {
      background: #f8f9fa;
    }

    .row-col.col-actions {
      background: #ffffff;
    }

    .row-col.col-actions .actions-container {
      flex-wrap: nowrap;
    }
  }
}


@media (max-width: 767px) {

  .payment-plans-container {
    height: auto;
    max-height: calc(100vh - 160px);
    min-width: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-section {
    flex: none;
    min-width: 0;
  }

  .header-section {
    flex-wrap: wrap;
    row-gap: 12px;
  }

  .filters-section .filters-container {
    flex-direction: column;
    gap: 10px;

    .filter-container {
      min-width: 0;
      width: 100%;
    }
  }

  .table-section .table-container {
    flex: none;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;

    &::-webkit-scrollbar {
      height: 8px;
    }
    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 4px;
    }
    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 4px;
      &:hover {
        background: #a8a8a8;
      }
    }

    .table-header .header-grid,
    .table-body .table-row .row-grid {
      display: grid;
      grid-template-columns:
        minmax(200px, 2fr)
        minmax(150px, 1.5fr)
        minmax(120px, 1fr)
        minmax(120px, 1fr)
        minmax(130px, 1fr)
        minmax(110px, 1fr);
      min-width: 830px;
      padding: 16px;
    }

    .row-col {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .row-col.col-actions .actions-container {
      flex-wrap: nowrap;
      gap: 8px;
    }
  }

  .table-section .export-section {
    justify-content: stretch;

    .export-btn {
      width: 100%;
      justify-content: center;
    }
  }
}