/* 项目财务档案页面样式 - iOS风格 */

.finance-project-records {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  color: #333;
}

/* 顶部标题区 */
.page-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 80px;
  
  .header-left {
    flex: 1;
    
    .header-content {
      h1 {
        font-size: 28px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #111;
      }
      .subtitle {
        font-size: 14px;
        color: #888;
        margin: 0;
      }
    }
  }

  .header-right {
    .header-actions {
      display: flex;
      align-items: center;
      gap: 12px;

      .action-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        text-decoration: none;
        white-space: nowrap;

        svg {
          width: 16px;
          height: 16px;
          flex-shrink: 0;
        }

        &:hover {
          transform: translateY(-1px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        &:active {
          transform: translateY(0);
        }

        &.back-btn {
          background: #28a745;
          color: white;
          
          &:hover {
            background: #218838;
          }
        }
      }
    }
  }
}

// 保持原有的back-to-dashboard-btn样式以兼容其他地方的使用
.back-to-dashboard-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background-color: #F2F3F5;
  color: #1D2129;
  border: 1px solid #E5E6EB;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  text-decoration: none;
  min-height: 40px;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

  &:hover {
    background-color: #F7F8FA;
    color: #1D2129;
    border-color: rgba(22, 93, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  &:active {
    transform: translateY(0);
    background-color: #F2F3F5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
}

/* 搜索和筛选区 */
.search-filter-section {
  margin-bottom: 24px;
  .search-box {
    position: relative;
    margin-bottom: 16px;
    .search-input {
      width: 100%;
      padding: 12px 40px 12px 16px;
      border: 1px solid #e0e0e0;
      border-radius: 12px;
      font-size: 14px;
      background-color: #f9f9f9;
      transition: all 0.2s ease;
      &:focus {
        outline: none;
        border-color: #007aff;
        background-color: #fff;
        box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
      }
    }
    .search-icon {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
      color: #888;
      font-size: 16px;
    }
  }
  .filter-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    .filter-btn {
      padding: 8px 16px;
      border: 1px solid #e0e0e0;
      border-radius: 20px;
      background-color: #fff;
      color: #888;
      font-size: 14px;
      cursor: pointer;
      transition: all 0.2s ease;
      white-space: nowrap;
      &:hover {
        background-color: #f0f0f0;
      }
      &.active {
        background-color: #007aff;
        color: #fff;
        border-color: #007aff;
      }
    }
  }
}

/* 项目列表 */
.project-list {
  .list-header {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 16px;
    padding: 12px 16px;
    background-color: #f5f5f5;
    border-radius: 12px;
    margin-bottom: 12px;
    .header-item {
      font-size: 14px;
      font-weight: 600;
      color: #666;
      &:nth-child(1) { /* 项目信息 */
        justify-self: start;
      }
      &:nth-child(2) { /* 财务状态 */
        text-align: center;
      }
      &:nth-child(3) { /* 价格 */
        text-align: right;
      }
      &:nth-child(4) { /* 操作 */
        text-align: right;
      }
    }
  }
  
  .project-items {
    .project-item {
      display: grid;
      grid-template-columns: 1fr auto auto auto;
      gap: 16px;
      align-items: center;
      padding: 16px;
      background-color: #fff;
      border: 1px solid #e0e0e0;
      border-radius: 12px;
      margin-bottom: 12px;
      transition: all 0.2s ease;
      &:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        border-color: #d0d0d0;
      }
      
      .project-info {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        .project-id {
          font-size: 12px;
          color: #888;
          font-weight: 500;
          min-width: 80px;
        }
        .project-main {
          flex: 1;
          .project-name {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 4px;
            color: #111;
          }
          .project-meta {
            display: flex;
            gap: 16px;
            font-size: 13px;
            color: #666;
            margin-bottom: 4px;
          }
          .project-details {
            display: flex;
            gap: 12px;
            font-size: 12px;
            color: #888;
          }
        }
        .quote-type-tag {
          padding: 4px 8px;
          border-radius: 4px;
          font-size: 12px;
          font-weight: 500;
          &.profit-tag {
            background-color: #e6f4ea;
            color: #34c759;
          }
          &.tail-tag {
            background-color: #fff2e8;
            color: #ff9500;
          }
        }
      }
      
      .project-status {
        .status-badge {
          padding: 6px 12px;
          border-radius: 16px;
          font-size: 13px;
          font-weight: 500;
          &.status-pending {
            background-color: #f5f5f5;
            color: #666;
          }
          &.status-quoted {
            background-color: #e6f4ea;
            color: #34c759;
          }
          &.status-pending-payment {
            background-color: #fff2e8;
            color: #ff9500;
          }
          &.status-partial-payment {
            background-color: #fff2e8;
            color: #ff9500;
          }
          &.status-full-payment {
            background-color: #e6f4ea;
            color: #34c759;
          }
          &.status-pending-settlement {
            background-color: #f0f7ff;
            color: #007aff;
          }
          &.status-settled {
            background-color: #f0f0f0;
            color: #666;
          }
        }
      }
      
      .project-price {
        text-align: right;
        .total-price {
          font-size: 16px;
          font-weight: 600;
          color: #111;
          margin-bottom: 4px;
        }
        .cost-info {
          font-size: 12px;
          color: #888;
          display: flex;
          flex-direction: column;
          gap: 2px;
        }
      }
      
      .project-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        .action-btn {
          padding: 8px 12px;
          border: none;
          border-radius: 8px;
          font-size: 13px;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.2s ease;
          &.quote-btn {
            background-color: #007aff;
            color: #fff;
            &:hover {
              background-color: #0062cc;
            }
          }
          &.status-btn {
            background-color: #34c759;
            color: #fff;
            &:hover {
              background-color: #28a745;
            }
          }
          &.log-btn {
            background-color: #f0f0f0;
            color: #666;
            &:hover {
              background-color: #e0e0e0;
            }
          }
        }
      }
    }
  }
}

/* 弹窗样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    h2 {
      font-size: 20px;
      font-weight: 600;
      color: #111;
    }
    .close-btn {
      background: none;
      border: none;
      font-size: 24px;
      color: #888;
      cursor: pointer;
      padding: 0;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      transition: background-color 0.2s ease;
      &:hover {
        background-color: #f0f0f0;
      }
    }
  }
  
  .modal-body {
    padding: 20px;
  }
}

/* 报价弹窗 */
.quote-modal {
  .quote-form {
    .form-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 16px;
    }
    .form-group {
      .label {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #333;
        margin-bottom: 8px;
      }
      input,
      select {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        font-size: 14px;
        transition: border-color 0.2s ease;
        &:focus {
          outline: none;
          border-color: #007aff;
        }
        &[readonly] {
          background-color: #f5f5f5;
          cursor: not-allowed;
        }
      }
      .profit-rate-display {
        text-align: center;
        font-size: 16px;
        font-weight: 600;
        color: #007aff;
        margin-top: 8px;
      }
    }
    .form-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      margin-top: 24px;
      .btn-cancel,
      .btn-primary {
        padding: 10px 20px;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
      }
      .btn-cancel {
        background-color: #f0f0f0;
        color: #666;
        &:hover {
          background-color: #e0e0e0;
        }
      }
      .btn-primary {
        background-color: #007aff;
        color: #fff;
        &:hover {
          background-color: #0062cc;
        }
      }
    }
  }
}

/* 沟通日志弹窗 */
.communication-log-modal {
  .log-header {
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 16px;
    .project-name {
      font-size: 16px;
      font-weight: 600;
      color: #111;
      margin-bottom: 4px;
    }
    .client-info,
    .sales-info {
      font-size: 13px;
      color: #666;
    }
  }
  
  .log-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
    .no-logs {
      text-align: center;
      color: #888;
      font-size: 14px;
      padding: 24px;
    }
    .log-item {
      padding: 12px;
      background-color: #f9f9f9;
      border-radius: 8px;
      margin-bottom: 8px;
      .log-content {
        font-size: 14px;
        color: #333;
        margin-bottom: 4px;
        &.has-red-line {
          font-weight: 500;
          color: #ff3b30;
        }
      }
      .log-time {
        font-size: 12px;
        color: #888;
      }
    }
  }
  
  .add-log-section {
    .log-input {
      width: 100%;
      padding: 12px;
      border: 1px solid #e0e0e0;
      border-radius: 8px;
      font-size: 14px;
      resize: vertical;
      transition: border-color 0.2s ease;
      &:focus {
        outline: none;
        border-color: #007aff;
      }
    }
    .log-actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 12px;
      .checkbox-label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 14px;
        color: #666;
        cursor: pointer;
        input {
          width: 16px;
          height: 16px;
          cursor: pointer;
        }
      }
      .btn-add-log {
        padding: 8px 16px;
        background-color: #007aff;
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.2s ease;
        &:hover {
          background-color: #0062cc;
        }
      }
    }
  }
}

/* 动画 */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .finance-project-records {
    padding: 12px;
  }
  
  .project-list {
    .list-header {
      grid-template-columns: 1fr;
      .header-item {
        display: none;
      }
    }
    .project-item {
      grid-template-columns: 1fr;
      gap: 12px;
      .project-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
      }
      .project-status,
      .project-price {
        text-align: left;
      }
      .project-actions {
        flex-direction: row;
        flex-wrap: wrap;
      }
    }
  }
  
  .modal-content {
    width: 95%;
    margin: 20px;
    .quote-form {
      .form-row {
        grid-template-columns: 1fr;
      }
    }
  }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}